Skip to content

Commit 53eeccc

Browse files
authored
Merge pull request codeit-13-3team#61 from codeit-13-3team/feature/profile
Feature/profile
2 parents 2f9a69f + 81f422e commit 53eeccc

2 files changed

Lines changed: 93 additions & 1 deletion

File tree

src/api/user.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
import axiosInstance from './axiosInstance';
2-
import { GetFolloweeListResponse, GetUserRankingResponse } from '../types/user';
2+
import { GetFolloweeListResponse, GetMeResponse, GetUserRankingResponse } from '../types/user';
33

44
export const getUserRanking = async () => {
55
const response = await axiosInstance.get<GetUserRankingResponse[]>('/users/ranking');
66
return response.data;
77
};
88

9+
export const getUserProfile = async (): Promise<GetMeResponse> => {
10+
const response = await axiosInstance.get<GetMeResponse>('/users/me');
11+
return response.data;
12+
};
13+
914
export const getFollowersList = async (userId: number) => {
1015
const response = await axiosInstance.get<GetFolloweeListResponse>(`/users/${userId}/followers`);
1116
return response.data;

src/components/Profile.tsx

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import { GetMeResponse } from '@/types/user';
2+
import Image from 'next/image';
3+
4+
interface ProfileProp {
5+
profileData: GetMeResponse;
6+
isMyProfile?: boolean;
7+
editProfile?: () => void;
8+
logout?: () => void;
9+
onClickFollowBtn?: () => void;
10+
}
11+
12+
function Profile({ profileData, isMyProfile=false, editProfile, logout, onClickFollowBtn }: ProfileProp) {
13+
return (
14+
<div className="mb-[60px] px-[20px] py-[30px] w-full h-auto rounded-[8px] bg-[#252530] md:px-[30px] lg:w-[340px] lg:mb-0">
15+
<div className="w-full h-auto flex flex-col items-center gap-[30px] lg:gap-[40px]">
16+
<div className="w-[120px] h-[120px] relative rounded-full lg:w-[180px] lg:h-[180px]">
17+
{profileData?.image ? (
18+
<Image src={profileData.image} alt="유저 이미지" fill />
19+
) : (
20+
<Image src="/img/profileimage/img=profile1.png" alt="유저 이미지" fill />
21+
)}
22+
</div>
23+
<div className="w-full flex flex-col gap-[10px] lg:gap-[20px]">
24+
<span className="text-center text-[20px] font-semibold text-[#F1F1F5] lg:text-[24px]">
25+
{profileData?.nickname}
26+
</span>
27+
<p className="text-[14px] font-normal text-[#6E6E82] lg:text-[16px]">
28+
{profileData?.description}
29+
</p>
30+
</div>
31+
<div className="w-full px-[51px] flex justify-between relative md:px-[108px] lg:px-[58px]">
32+
<div className="flex flex-col items-center gap-[10px]">
33+
<span className="text-[18px] font-semibold text-[#F1F1F5] lg:text-[20px]">
34+
{profileData?.followersCount}
35+
</span>
36+
<span className="text-[14px] font-normal text-[#9FA6B2] lg:text-[16px]">팔로워</span>
37+
</div>
38+
<div className="absolute left-1/2 top-0 w-px h-full bg-[#353542]"></div>
39+
<div className="flex flex-col items-center gap-[10px]">
40+
<span className="text-[18px] font-semibold text-[#F1F1F5] lg:text-[20px]">
41+
{profileData?.followeesCount}
42+
</span>
43+
<span className="text-[14px] font-normal text-[#9FA6B2] lg:text-[16px]">팔로잉</span>
44+
</div>
45+
</div>
46+
{isMyProfile ? (
47+
profileData.isFollowing ? (
48+
<div
49+
className="w-full h-[50px] flex justify-center items-center rounded-lg border border-gray-100 text-gray-100 text-[16px] font-semibold hover:cursor-pointer
50+
md:h-[55px] lg:h-[65px] lg:text-[18px]"
51+
onClick={onClickFollowBtn}
52+
>
53+
팔로우 취소
54+
</div>
55+
) : (
56+
<div
57+
className="w-full h-[50px] flex justify-center items-center rounded-lg bg-main-blue text-gray-50 text-[16px] font-semibold hover:cursor-pointer
58+
md:h-[55px] lg:h-[65px] lg:text-[18px]"
59+
onClick={onClickFollowBtn}
60+
>
61+
팔로우
62+
</div>
63+
)
64+
) : (
65+
<div className="w-full flex flex-col gap-[10px] md:gap-[15px] lg:gap-[20px]">
66+
<div
67+
className="w-full h-[50px] flex justify-center items-center rounded-lg bg-main-blue text-gray-50 text-[16px] font-semibold hover:cursor-pointer
68+
md:h-[55px] lg:h-[65px] lg:text-[18px]"
69+
onClick={editProfile}
70+
>
71+
프로필 편집
72+
</div>
73+
<div
74+
className="w-full h-[50px] flex justify-center items-center rounded-lg border border-gray-100 text-gray-100 text-[16px] font-semibold hover:cursor-pointer
75+
md:h-[55px] lg:h-[65px] lg:text-[18px]"
76+
onClick={logout}
77+
>
78+
로그아웃
79+
</div>
80+
</div>
81+
)}
82+
</div>
83+
</div>
84+
);
85+
}
86+
87+
export default Profile;

0 commit comments

Comments
 (0)