From 236d8f7efa1fd055fb4ce327b22aa650da8238f4 Mon Sep 17 00:00:00 2001 From: yeeZinu Date: Fri, 14 Jun 2024 13:43:37 +0900 Subject: [PATCH] =?UTF-8?q?doc:=20api=20fetching=EC=97=90=20=EB=94=B0?= =?UTF-8?q?=EB=A5=B8=20=ED=8F=B4=EB=8D=94=20=EB=84=A4=EC=9D=B4=EB=B0=8D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20(#35)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/(userpage)/types.tsx | 22 +++--- .../[userId]/UserPage.module.scss | 0 .../FollowList/FollowList.module.scss | 0 .../components/FollowList/FollowList.tsx | 0 .../FollowModal/FollowModal.module.scss | 0 .../components/FollowModal/FollowModal.tsx | 0 .../HTMLContent/HTMLContent.module.scss | 0 .../components/HTMLContent/HTMLContent.tsx | 0 .../TabButton/TabButton.module.scss | 0 .../components/TabButton/TabButton.tsx | 0 .../UserActivityList.module.scss | 0 .../UserActivityList/UserActivityList.tsx | 0 .../components/UserInfo/UserInfo.module.scss | 0 .../[userId]/components/UserInfo/UserInfo.tsx | 0 .../UserProductList.module.scss | 0 .../UserProductList/UserProductList.tsx | 0 src/app/(userpage)/user/[userId]/page.tsx | 76 +++++++++++++++++++ src/app/(userpage)/userpage/[userId]/page.tsx | 50 ------------ src/components/Gnb/Gnb.tsx | 2 +- 19 files changed, 88 insertions(+), 62 deletions(-) rename src/app/(userpage)/{userpage => user}/[userId]/UserPage.module.scss (100%) rename src/app/(userpage)/{userpage => user}/[userId]/components/FollowList/FollowList.module.scss (100%) rename src/app/(userpage)/{userpage => user}/[userId]/components/FollowList/FollowList.tsx (100%) rename src/app/(userpage)/{userpage => user}/[userId]/components/FollowModal/FollowModal.module.scss (100%) rename src/app/(userpage)/{userpage => user}/[userId]/components/FollowModal/FollowModal.tsx (100%) rename src/app/(userpage)/{userpage => user}/[userId]/components/HTMLContent/HTMLContent.module.scss (100%) rename src/app/(userpage)/{userpage => user}/[userId]/components/HTMLContent/HTMLContent.tsx (100%) rename src/app/(userpage)/{userpage => user}/[userId]/components/TabButton/TabButton.module.scss (100%) rename src/app/(userpage)/{userpage => user}/[userId]/components/TabButton/TabButton.tsx (100%) rename src/app/(userpage)/{userpage => user}/[userId]/components/UserActivityList/UserActivityList.module.scss (100%) rename src/app/(userpage)/{userpage => user}/[userId]/components/UserActivityList/UserActivityList.tsx (100%) rename src/app/(userpage)/{userpage => user}/[userId]/components/UserInfo/UserInfo.module.scss (100%) rename src/app/(userpage)/{userpage => user}/[userId]/components/UserInfo/UserInfo.tsx (100%) rename src/app/(userpage)/{userpage => user}/[userId]/components/UserProductList/UserProductList.module.scss (100%) rename src/app/(userpage)/{userpage => user}/[userId]/components/UserProductList/UserProductList.tsx (100%) create mode 100644 src/app/(userpage)/user/[userId]/page.tsx delete mode 100644 src/app/(userpage)/userpage/[userId]/page.tsx diff --git a/src/app/(userpage)/types.tsx b/src/app/(userpage)/types.tsx index d636765..7ea8a9a 100644 --- a/src/app/(userpage)/types.tsx +++ b/src/app/(userpage)/types.tsx @@ -1,20 +1,20 @@ export type UserDetail = { - updatedAt: Date; - createdAt: Date; - teamId: string; - image: string; - description: string; - nickname: string; id: number; + nickname: string; + description: string; + image: string; + createdAt: string; + updatedAt: string; + teamId: string; + isFollowing: boolean; + followersCount: number; + followeesCount: number; + reviewCount: number; + averageRating: number; mostFavoriteCategory: { name: string; id: number; }; - averageRating: number; - reviewCount: number; - followeesCount: number; - followersCount: number; - isFollowing: boolean; }; export type UserProduct = { diff --git a/src/app/(userpage)/userpage/[userId]/UserPage.module.scss b/src/app/(userpage)/user/[userId]/UserPage.module.scss similarity index 100% rename from src/app/(userpage)/userpage/[userId]/UserPage.module.scss rename to src/app/(userpage)/user/[userId]/UserPage.module.scss diff --git a/src/app/(userpage)/userpage/[userId]/components/FollowList/FollowList.module.scss b/src/app/(userpage)/user/[userId]/components/FollowList/FollowList.module.scss similarity index 100% rename from src/app/(userpage)/userpage/[userId]/components/FollowList/FollowList.module.scss rename to src/app/(userpage)/user/[userId]/components/FollowList/FollowList.module.scss diff --git a/src/app/(userpage)/userpage/[userId]/components/FollowList/FollowList.tsx b/src/app/(userpage)/user/[userId]/components/FollowList/FollowList.tsx similarity index 100% rename from src/app/(userpage)/userpage/[userId]/components/FollowList/FollowList.tsx rename to src/app/(userpage)/user/[userId]/components/FollowList/FollowList.tsx diff --git a/src/app/(userpage)/userpage/[userId]/components/FollowModal/FollowModal.module.scss b/src/app/(userpage)/user/[userId]/components/FollowModal/FollowModal.module.scss similarity index 100% rename from src/app/(userpage)/userpage/[userId]/components/FollowModal/FollowModal.module.scss rename to src/app/(userpage)/user/[userId]/components/FollowModal/FollowModal.module.scss diff --git a/src/app/(userpage)/userpage/[userId]/components/FollowModal/FollowModal.tsx b/src/app/(userpage)/user/[userId]/components/FollowModal/FollowModal.tsx similarity index 100% rename from src/app/(userpage)/userpage/[userId]/components/FollowModal/FollowModal.tsx rename to src/app/(userpage)/user/[userId]/components/FollowModal/FollowModal.tsx diff --git a/src/app/(userpage)/userpage/[userId]/components/HTMLContent/HTMLContent.module.scss b/src/app/(userpage)/user/[userId]/components/HTMLContent/HTMLContent.module.scss similarity index 100% rename from src/app/(userpage)/userpage/[userId]/components/HTMLContent/HTMLContent.module.scss rename to src/app/(userpage)/user/[userId]/components/HTMLContent/HTMLContent.module.scss diff --git a/src/app/(userpage)/userpage/[userId]/components/HTMLContent/HTMLContent.tsx b/src/app/(userpage)/user/[userId]/components/HTMLContent/HTMLContent.tsx similarity index 100% rename from src/app/(userpage)/userpage/[userId]/components/HTMLContent/HTMLContent.tsx rename to src/app/(userpage)/user/[userId]/components/HTMLContent/HTMLContent.tsx diff --git a/src/app/(userpage)/userpage/[userId]/components/TabButton/TabButton.module.scss b/src/app/(userpage)/user/[userId]/components/TabButton/TabButton.module.scss similarity index 100% rename from src/app/(userpage)/userpage/[userId]/components/TabButton/TabButton.module.scss rename to src/app/(userpage)/user/[userId]/components/TabButton/TabButton.module.scss diff --git a/src/app/(userpage)/userpage/[userId]/components/TabButton/TabButton.tsx b/src/app/(userpage)/user/[userId]/components/TabButton/TabButton.tsx similarity index 100% rename from src/app/(userpage)/userpage/[userId]/components/TabButton/TabButton.tsx rename to src/app/(userpage)/user/[userId]/components/TabButton/TabButton.tsx diff --git a/src/app/(userpage)/userpage/[userId]/components/UserActivityList/UserActivityList.module.scss b/src/app/(userpage)/user/[userId]/components/UserActivityList/UserActivityList.module.scss similarity index 100% rename from src/app/(userpage)/userpage/[userId]/components/UserActivityList/UserActivityList.module.scss rename to src/app/(userpage)/user/[userId]/components/UserActivityList/UserActivityList.module.scss diff --git a/src/app/(userpage)/userpage/[userId]/components/UserActivityList/UserActivityList.tsx b/src/app/(userpage)/user/[userId]/components/UserActivityList/UserActivityList.tsx similarity index 100% rename from src/app/(userpage)/userpage/[userId]/components/UserActivityList/UserActivityList.tsx rename to src/app/(userpage)/user/[userId]/components/UserActivityList/UserActivityList.tsx diff --git a/src/app/(userpage)/userpage/[userId]/components/UserInfo/UserInfo.module.scss b/src/app/(userpage)/user/[userId]/components/UserInfo/UserInfo.module.scss similarity index 100% rename from src/app/(userpage)/userpage/[userId]/components/UserInfo/UserInfo.module.scss rename to src/app/(userpage)/user/[userId]/components/UserInfo/UserInfo.module.scss diff --git a/src/app/(userpage)/userpage/[userId]/components/UserInfo/UserInfo.tsx b/src/app/(userpage)/user/[userId]/components/UserInfo/UserInfo.tsx similarity index 100% rename from src/app/(userpage)/userpage/[userId]/components/UserInfo/UserInfo.tsx rename to src/app/(userpage)/user/[userId]/components/UserInfo/UserInfo.tsx diff --git a/src/app/(userpage)/userpage/[userId]/components/UserProductList/UserProductList.module.scss b/src/app/(userpage)/user/[userId]/components/UserProductList/UserProductList.module.scss similarity index 100% rename from src/app/(userpage)/userpage/[userId]/components/UserProductList/UserProductList.module.scss rename to src/app/(userpage)/user/[userId]/components/UserProductList/UserProductList.module.scss diff --git a/src/app/(userpage)/userpage/[userId]/components/UserProductList/UserProductList.tsx b/src/app/(userpage)/user/[userId]/components/UserProductList/UserProductList.tsx similarity index 100% rename from src/app/(userpage)/userpage/[userId]/components/UserProductList/UserProductList.tsx rename to src/app/(userpage)/user/[userId]/components/UserProductList/UserProductList.tsx diff --git a/src/app/(userpage)/user/[userId]/page.tsx b/src/app/(userpage)/user/[userId]/page.tsx new file mode 100644 index 0000000..755f933 --- /dev/null +++ b/src/app/(userpage)/user/[userId]/page.tsx @@ -0,0 +1,76 @@ +"use client"; + +/* eslint-disable no-restricted-imports */ + +import { useSession } from "next-auth/react"; +import React, { useEffect, useState } from "react"; +// user mock data +// import { userMock } from "@/app/(userpage)/userMock"; +import Activity from "@/components/Card/Activity/Activity"; +import cn from "@/utils/classNames"; +// 추후 데이터 연결시 받아온데이터로 변환 예정 +import HttpClient from "@/utils/httpClient"; +import UserActivityList from "./components/UserActivityList/UserActivityList"; +import UserInfo from "./components/UserInfo/UserInfo"; +import styles from "./UserPage.module.scss"; +import { UserDetail } from "../../types"; + +export default function UserPage({ params }: { params: { userId: number } }) { + const { data: session } = useSession(); + const [userData, setUserData] = useState(); + + const httpClient = new HttpClient(process.env.NEXT_PUBLIC_BASE_URL!); + + const getUserData = async () => { + if (session) { + const ACCESS_TOKEN = session.accessToken; + setUserData( + await httpClient.get(`users/${params.userId}`, { + headers: { Authorization: ACCESS_TOKEN }, + cache: "no-cache", + }), + ); + } + }; + + useEffect(() => { + getUserData(); + }, []); + + return ( +
+ {userData && ( + <> + +
+
+

활동 내역

+
+ + + +
+
+ +
+ + )} +
+ ); +} diff --git a/src/app/(userpage)/userpage/[userId]/page.tsx b/src/app/(userpage)/userpage/[userId]/page.tsx deleted file mode 100644 index 3632755..0000000 --- a/src/app/(userpage)/userpage/[userId]/page.tsx +++ /dev/null @@ -1,50 +0,0 @@ -"use client"; - -// import { useParams } from "next/navigation"; -import React from "react"; -// user mock data -import { userMock } from "@/app/(userpage)/userMock"; -import Activity from "@/components/Card/Activity/Activity"; -import cn from "@/utils/classNames"; -// 추후 데이터 연결시 받아온데이터로 변환 예정 -import UserActivityList from "./components/UserActivityList/UserActivityList"; -import UserInfo from "./components/UserInfo/UserInfo"; -import styles from "./UserPage.module.scss"; - -export default function UserPage() { - // userId를 받아오는 useParams function - // const { userId } = useParams<{ userId: string }>(); - - return ( -
- -
-
-

활동 내역

-
- - - -
-
- -
-
- ); -} diff --git a/src/components/Gnb/Gnb.tsx b/src/components/Gnb/Gnb.tsx index 6a68103..4df62b2 100644 --- a/src/components/Gnb/Gnb.tsx +++ b/src/components/Gnb/Gnb.tsx @@ -65,7 +65,7 @@ export default function Gnb() { {status === "authenticated" ? ( <> 비교하기 - 내 프로필 + 내 프로필 ) : ( <>