diff --git a/src/app/application/[id]/page.tsx b/src/app/application/[id]/page.tsx index 491ce5c..6a878d6 100644 --- a/src/app/application/[id]/page.tsx +++ b/src/app/application/[id]/page.tsx @@ -6,6 +6,7 @@ import { getApplicationDetail, getMe, getUser } from '@/services' import { ApplicationType, UserType } from '@/types' import Link from 'next/link' import { useEffect, useState } from 'react' +import { useRouter } from 'next/navigation' export default function Detail({ params }: { params: { id: number } }) { const [open, setOpen] = useState(false) @@ -13,6 +14,7 @@ export default function Detail({ params }: { params: { id: number } }) { const [detailData, setDetailData] = useState() const [userData, setUserData] = useState() const [myData, setMyData] = useState() + const route = useRouter() const getData = async () => { const data: ApplicationType = await getApplicationDetail(params.id) @@ -94,7 +96,14 @@ export default function Detail({ params }: { params: { id: number } }) { {detailData?.post_title}
-

{userData?.name}

+

+ route.push(`/profile/${detailData?.post_writer_id}`) + } + className="cursor-pointer" + > + {userData?.name} +

{DateFormat()}

diff --git a/src/app/profile/[id]/page.tsx b/src/app/profile/[id]/page.tsx new file mode 100644 index 0000000..b45f1ee --- /dev/null +++ b/src/app/profile/[id]/page.tsx @@ -0,0 +1,138 @@ +'use client' + +import { useEffect, useState } from 'react' +import { Bag, DefaultProfile, GradientImg, User } from '@/assets' +import { ApplicationBox, Button, TipBox } from '@/components' +import { applicationData, tipData } from '@/constants' +import { getUser, userFollow } from '@/services' +import Image from 'next/image' +import { UserType } from '@/types' + +export default function AnotherProfilePage({ + params, +}: { + params: { id: number } +}) { + const [userData, setUserData] = useState() + const [follow, setFollow] = useState(false) + console.log(follow) + + const getData = async () => { + const user: UserType = await getUser(String(params.id)) + setUserData(user) + } + + const HandleFollow = async () => { + if (userData) { + const res = await userFollow(userData?.oauth_id) + console.log(res) + setFollow(true) + } + } + + useEffect(() => { + const fetchData = async () => { + await getData() + } + fetchData() + }, []) + + return ( +
+
+ Profile Banner + User Profile +
+
+
+

{userData?.name}

+

팔로잉 0 | 팔로워 0

+
+
+ {follow ? ( + + ) : ( + + )} +
+
+
기본 정보
+
+
+
+ +
+
+

기수

+

+ {userData?.generation}기 +

+
+
+
+
+ +
+
+

전공

+

+ {userData?.major} +

+
+
+
+
+
+
+
+
공유한 지원서 자료
+
+ {/*
+ {applicationData.map((value, index) => ( + + ))} +
*/} +
+

+ 아직 공유한 지원서가 없어요. +

+
+
+
+
+
+
공유한 지원서 팁
+
+ {/*
+ {tipData.map((value, index) => ( + + ))} +
*/} +
+

+ 아직 공유한 지원서 팁이 없어요. +

+
+
+
+
+ ) +} diff --git a/src/services/index.ts b/src/services/index.ts index 44fb8da..97b67e4 100644 --- a/src/services/index.ts +++ b/src/services/index.ts @@ -6,5 +6,6 @@ export { getApplicationDetail } from './getApplicationDetail' export { getMe } from './getMe' export { getUser } from './getUser' export { deleteApplication } from './deleteApplication' +export { userFollow } from './userFollow' -export * from './post' \ No newline at end of file +export * from './post' diff --git a/src/services/userFollow.ts b/src/services/userFollow.ts new file mode 100644 index 0000000..809f5b5 --- /dev/null +++ b/src/services/userFollow.ts @@ -0,0 +1,18 @@ +'use server' + +import { instance } from './interceptor' +import { cookies } from 'next/headers' + +export const userFollow = async (oauthId: string) => { + const token = cookies().get('access_token') + + return await instance({ + method: 'POST', + url: `/users/follow/${oauthId}`, + headers: { + Authorization: token?.value, + }, + }).then((response) => { + return response.data + }) +}