File tree Expand file tree Collapse file tree 4 files changed +21
-25
lines changed
routes/(protected)/profile/[id] Expand file tree Collapse file tree 4 files changed +21
-25
lines changed Original file line number Diff line number Diff line change @@ -113,7 +113,7 @@ export default function WishlistEditor() {
113113 < Sparkles className = "w-8 h-8 text-blue-400" />
114114 </ div >
115115 < p className = "text-lg text-gray-300" >
116- Welcome back, < span className = "font-semibold text-white" > { user ?. firstName || user ?. email || 'User' } </ span > !
116+ Welcome back, < span className = "font-semibold text-white" > { user ?. name || user ?. email || 'User' } </ span > !
117117 </ p >
118118 < p className = "text-sm text-gray-400 mt-2" >
119119 { existingWishlist ? 'Edit your wishlist' : 'Create and share your dreams, goals, and what you can offer to the world' }
Original file line number Diff line number Diff line change @@ -302,6 +302,7 @@ export type GroupSuggestion = Suggestion;
302302
303303// Extended types for API responses
304304export type UserWithProfile = User & {
305+ name ?:string ;
305306 profile ?: Profile ;
306307 skills ?: Skill [ ] ;
307308 interests ?: Interest [ ] ;
Original file line number Diff line number Diff line change 1212 handleFollow,
1313 handleSinglePost,
1414 handleMessage,
15- isFollowing = $bindable (false )
15+ isFollowing = $bindable (false ),
16+ didFollowed = $bindable (false )
1617 }: {
1718 variant: ' user' | ' other' ;
1819 profileData: userProfile ;
1920 handleSinglePost: (post : PostData ) => void ;
2021 handleFollow: () => Promise <void >;
2122 handleMessage: () => Promise <void >;
2223 isFollowing: boolean ;
24+ didFollowed: boolean ;
2325 } = $props ();
2426
2527 let imgPosts = $derived (profileData .posts .filter ((e ) => e .imgUris && e .imgUris .length > 0 ));
26- let requestSent = $state (false );
2728
2829 const btnScale = new Spring (1 , { stiffness: 0.2 , damping: 0.4 });
2930
3031 async function wrappedFollow() {
31- if (isFollowing || requestSent ) return ;
32-
3332 btnScale .target = 0.95 ;
34-
35- try {
36- await handleFollow ();
37-
38- requestSent = true ;
39- btnScale .target = 1 ;
40-
41- setTimeout (() => {
42- requestSent = false ;
43- }, 2000 );
44- } catch (e ) {
45- console .error (e );
46- btnScale .target = 1 ;
47- }
33+ await handleFollow ();
34+ btnScale .target = 1 ;
4835 }
4936 </script >
5037
6956 variant ={' primary' }
7057 size =" sm"
7158 callback ={wrappedFollow }
72- disabled ={isFollowing || requestSent }
73- class ="min-w-[110px] transition-all duration-500 {requestSent
59+ class ="min-w-[110px] transition-all duration-500 {didFollowed
7460 ? ' opacity-80'
7561 : ' ' }"
7662 >
7763 <div class =" flex items-center justify-center gap-2" >
78- {#if requestSent }
64+ {#if didFollowed }
7965 <HugeiconsIcon icon ={Tick01Icon } size ={16 } />
80- <span >Followed </span >
66+ <span >Following </span >
8167 {:else if isFollowing }
8268 <span class =" flex gap-0.5" >
8369 <span class =" animate-bounce" >.</span >
Original file line number Diff line number Diff line change 2828 let loading = $state (true );
2929 let ownerId: string | null = $derived (getAuthId ());
3030 let isFollowing = $state (false );
31+ let didFollowed = $state (false );
3132 let ownerProfile = $derived .by (async () => {
3233 if (ownerId ) {
3334 const response = await apiClient .get <userProfile >(` /api/users/${ownerId } ` );
5253 async function handleFollow() {
5354 try {
5455 isFollowing = true ;
55- await apiClient .post (` /api/users/${profileId }/follow ` );
56- // await fetchProfile(); // Refresh profile to update follower count
56+ const response = await apiClient .post (` /api/users/${profileId }/follow ` );
57+ if (response ) {
58+ didFollowed = true ;
59+ setTimeout (async () => {
60+ await fetchProfile ();
61+ didFollowed = false ;
62+ }, 1000 );
63+ }
5764 } catch (err ) {
5865 error = err instanceof Error ? err .message : ' Failed to follow user' ;
66+ didFollowed = false ;
5967 } finally {
6068 isFollowing = false ;
6169 }
99107 {:else if profile }
100108 <Profile
101109 bind:isFollowing
110+ bind:didFollowed
102111 variant ={ownerId === profileId ? ' user' : ' other' }
103112 profileData ={profile }
104113 handleSinglePost ={(post ) => handlePostClick (post )}
You can’t perform that action at this time.
0 commit comments