|
| 1 | +'use client' |
| 2 | + |
1 | 3 | import { |
2 | 4 | Avatar, |
3 | 5 | CategoryListItem, |
4 | 6 | FollowListButton, |
5 | 7 | ProfileEditButton, |
| 8 | + Spinner, |
6 | 9 | } from '@/components' |
7 | 10 | import { CATEGORIES_RENDER, PROFILE_MSG } from '@/constants' |
8 | | -import { fetchGetUserProfile } from '@/services/users/useUsers' |
| 11 | +import { useGetUserProfile } from '@/services/users/useUsers' |
9 | 12 | import { UserLayoutProps } from './layout' |
10 | 13 |
|
11 | | -export default async function UserPage({ |
12 | | - params: { userId }, |
13 | | -}: UserLayoutProps) { |
14 | | - const user = await fetchGetUserProfile({ memberId: userId }) |
| 14 | +export default function UserPage({ params: { userId } }: UserLayoutProps) { |
| 15 | + const { data: user, isFetching: isUserLoading } = useGetUserProfile( |
| 16 | + Number(userId), |
| 17 | + ) |
15 | 18 |
|
16 | 19 | return ( |
17 | 20 | <> |
18 | | - <div className="flex flex-col gap-4 px-4 py-6"> |
19 | | - <div className="flex gap-3"> |
20 | | - {user?.profileImagePath && ( |
21 | | - <div className="relative h-20 w-20"> |
22 | | - <Avatar |
23 | | - src={user.profileImagePath} |
24 | | - alt="profile" |
25 | | - /> |
| 21 | + {isUserLoading ? ( |
| 22 | + <Spinner /> |
| 23 | + ) : ( |
| 24 | + <div className="flex flex-col gap-4 px-4 py-6"> |
| 25 | + <div className="flex gap-3"> |
| 26 | + {user?.profileImagePath && ( |
| 27 | + <div className="relative h-20 w-20"> |
| 28 | + <Avatar |
| 29 | + src={user.profileImagePath} |
| 30 | + alt="profile" |
| 31 | + /> |
| 32 | + </div> |
| 33 | + )} |
| 34 | + <div className="flex flex-col gap-1 py-0.5"> |
| 35 | + <div className="text-xl font-semibold text-gray9"> |
| 36 | + {user?.nickname} |
| 37 | + </div> |
| 38 | + <div className="text-xs font-medium text-gray6"> |
| 39 | + {user?.newsEmail} |
| 40 | + </div> |
| 41 | + <div className="flex gap-1 text-xs font-medium text-gray6"> |
| 42 | + <FollowListButton user={user} /> |
| 43 | + </div> |
26 | 44 | </div> |
27 | | - )} |
28 | | - <div className="flex flex-col gap-1 py-0.5"> |
29 | | - <div className="text-xl font-semibold text-gray9"> |
30 | | - {user?.nickname} |
31 | | - </div> |
32 | | - <div className="text-xs font-medium text-gray6"> |
33 | | - {user?.newsEmail} |
| 45 | + </div> |
| 46 | + <ProfileEditButton user={user} /> |
| 47 | + <div className="flex flex-col "> |
| 48 | + <div className="py-3 text-sm font-semibold text-gray9"> |
| 49 | + {PROFILE_MSG.FAVORITE_CATEGORY} |
34 | 50 | </div> |
35 | | - <div className="flex gap-1 text-xs font-medium text-gray6"> |
36 | | - <FollowListButton user={user} /> |
| 51 | + <div> |
| 52 | + <CategoryListItem |
| 53 | + label={ |
| 54 | + user?.favoriteCategory |
| 55 | + ? CATEGORIES_RENDER[user.favoriteCategory] |
| 56 | + : '없음' |
| 57 | + } |
| 58 | + active={true} |
| 59 | + disabled={true} |
| 60 | + /> |
37 | 61 | </div> |
38 | 62 | </div> |
39 | | - </div> |
40 | | - <ProfileEditButton user={user} /> |
41 | | - <div className="flex flex-col "> |
42 | | - <div className="py-3 text-sm font-semibold text-gray9"> |
43 | | - {PROFILE_MSG.FAVORITE_CATEGORY} |
44 | | - </div> |
45 | 63 | <div> |
46 | | - <CategoryListItem |
47 | | - label={ |
48 | | - user?.favoriteCategory |
49 | | - ? CATEGORIES_RENDER[user.favoriteCategory] |
50 | | - : '없음' |
51 | | - } |
52 | | - active={true} |
53 | | - disabled={true} |
54 | | - /> |
55 | | - </div> |
56 | | - </div> |
57 | | - <div> |
58 | | - <div className="py-3 text-sm font-semibold text-gray9"> |
59 | | - {PROFILE_MSG.DESCRIPTION} |
| 64 | + <div className="py-3 text-sm font-semibold text-gray9"> |
| 65 | + {PROFILE_MSG.DESCRIPTION} |
| 66 | + </div> |
| 67 | + <div className="text-sm font-normal text-gray9"> |
| 68 | + {user?.aboutMe} |
| 69 | + </div> |
60 | 70 | </div> |
61 | | - <div className="text-sm font-normal text-gray9">{user?.aboutMe}</div> |
62 | 71 | </div> |
63 | | - </div> |
| 72 | + )} |
64 | 73 | </> |
65 | 74 | ) |
66 | 75 | } |
0 commit comments