From 088e7452e80a24bf6768f331474a6685a39003a3 Mon Sep 17 00:00:00 2001 From: beom Date: Wed, 5 Feb 2025 16:27:36 +0900 Subject: [PATCH 1/7] =?UTF-8?q?Refactor:=20=ED=83=80=EC=9D=B8=20=ED=94=84?= =?UTF-8?q?=EB=A1=9C=ED=95=84=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=9D=B4?= =?UTF-8?q?=EB=AF=B8=EC=A7=80=20=EC=B5=9C=EC=A0=81=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- next.config.ts | 1 + .../UserProfile/UserProfileContent/index.tsx | 35 ++++++++----------- .../UserProfile/UserProfileHeader/index.tsx | 2 +- 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/next.config.ts b/next.config.ts index bcd6923..7529341 100644 --- a/next.config.ts +++ b/next.config.ts @@ -20,6 +20,7 @@ const nextConfig: NextConfig = { hostname: 'zzikzzik-bucket.s3.ap-northeast-2.amazonaws.com', }, ], + formats: ['image/avif', 'image/webp'], // AVIF 우선 적용 }, }; diff --git a/src/components/UserProfile/UserProfileContent/index.tsx b/src/components/UserProfile/UserProfileContent/index.tsx index dea4264..f5df5f0 100644 --- a/src/components/UserProfile/UserProfileContent/index.tsx +++ b/src/components/UserProfile/UserProfileContent/index.tsx @@ -3,14 +3,13 @@ import Image from 'next/image'; import { useRouter } from 'next/navigation'; import { useUserProfileQuery } from '@/hooks/apis/Auth/useUserProfileQuery'; -import { Spinner } from '@/components/common/Spinner'; interface UserProfileContent { userId: string; } export const UserProfileContent = ({ userId }: UserProfileContent) => { - const { completeResponses, isLoading } = useUserProfileQuery(Number(userId)); + const { completeResponses } = useUserProfileQuery(Number(userId)); const router = useRouter(); @@ -18,33 +17,29 @@ export const UserProfileContent = ({ userId }: UserProfileContent) => { router.push(`/completes/${completeId}`); }; - if (isLoading) { - return ( -
- -
- ); - } - return (
{completeResponses.map((complete) => complete.completePic ? ( - 인증한 이미지 handleClick(complete.completeId)} - /> + > + 인증한 이미지 +
) : (
), )} diff --git a/src/components/UserProfile/UserProfileHeader/index.tsx b/src/components/UserProfile/UserProfileHeader/index.tsx index d53d403..deb6486 100644 --- a/src/components/UserProfile/UserProfileHeader/index.tsx +++ b/src/components/UserProfile/UserProfileHeader/index.tsx @@ -40,7 +40,7 @@ export const UserProfileHeader = ({ userId }: UserProfileHeader) => { Date: Wed, 5 Feb 2025 16:28:59 +0900 Subject: [PATCH 2/7] =?UTF-8?q?Feat:=20=ED=83=80=EC=9D=B8=20=ED=94=84?= =?UTF-8?q?=EB=A1=9C=ED=95=84=20=ED=8E=98=EC=9D=B4=EC=A7=80=20SSR=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/UserProfile/getUserProfile.ts | 23 ++++++++++++++++++ src/app/(route)/userProfile/[userId]/page.tsx | 24 +++++++++++++++++-- 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 src/apis/UserProfile/getUserProfile.ts diff --git a/src/apis/UserProfile/getUserProfile.ts b/src/apis/UserProfile/getUserProfile.ts new file mode 100644 index 0000000..031fe4a --- /dev/null +++ b/src/apis/UserProfile/getUserProfile.ts @@ -0,0 +1,23 @@ +import axios from 'axios'; +import { API_ENDPOINTS } from '@/constants/ApiEndpoints'; + +const apiUrl = process.env.NEXT_PUBLIC_API_URL; + +export const getUserProfile = async (userId: number, token: string) => { + try { + const response = await axios.get( + apiUrl + API_ENDPOINTS.AUTH.USER_PROFILE(userId), + { + headers: { + token: token, + 'Content-Type': 'application/json', + Accept: '*/*', + }, + }, + ); + return response.data; + } catch (error) { + console.error('❌ API 요청 실패:', error); + throw new Error('사용자 프로필을 가져오는 중 문제가 발생했습니다.'); + } +}; diff --git a/src/app/(route)/userProfile/[userId]/page.tsx b/src/app/(route)/userProfile/[userId]/page.tsx index 55d62a1..61750a6 100644 --- a/src/app/(route)/userProfile/[userId]/page.tsx +++ b/src/app/(route)/userProfile/[userId]/page.tsx @@ -1,6 +1,14 @@ +import { + dehydrate, + HydrationBoundary, + QueryClient, +} from '@tanstack/react-query'; +import { cookies } from 'next/headers'; import { PageContainer } from '@/components/common/PageContainer'; import { UserProfileContent } from '@/components/UserProfile/UserProfileContent'; import { UserProfileHeader } from '@/components/UserProfile/UserProfileHeader'; +import { QUERY_KEYS } from '@/constants/QueryKeys'; +import { getUserProfile } from '@/apis/UserProfile/getUserProfile'; interface UserProfileProps { userId: string; @@ -13,10 +21,22 @@ export default async function userProfile({ }) { const { userId } = await params; + const cookieStore = await cookies(); + const token = cookieStore.get('token')?.value || ''; + + const queryClient = new QueryClient(); + + await queryClient.prefetchQuery({ + queryKey: [QUERY_KEYS.USER_PROFILE, Number(userId)], + queryFn: () => getUserProfile(Number(userId), token), + }); + return ( - - + + + + ); } From affaead364c77142ad58de1c39af71a39e2b3266 Mon Sep 17 00:00:00 2001 From: beom Date: Wed, 5 Feb 2025 16:45:17 +0900 Subject: [PATCH 3/7] =?UTF-8?q?Refactor:=20=EB=B9=8C=EB=93=9C=EC=98=A4?= =?UTF-8?q?=EB=A5=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/storybook.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/storybook.yml b/.github/workflows/storybook.yml index 4874529..b11bfca 100644 --- a/.github/workflows/storybook.yml +++ b/.github/workflows/storybook.yml @@ -22,11 +22,10 @@ jobs: with: fetch-depth: 0 - - name: Corepack 활성화 - run: corepack enable - - - name: pnpm 설치 - run: corepack prepare pnpm@latest --activate + - name: pnpm 직접 설치 + run: npm install -g pnpm + pnpm --version + - name: 캐시 종속성 id: cache From 9804e9644bda6c425caf0ace5e3d911a9db62fc6 Mon Sep 17 00:00:00 2001 From: beom Date: Wed, 5 Feb 2025 16:50:35 +0900 Subject: [PATCH 4/7] =?UTF-8?q?Fix:=20=EB=B9=8C=EB=93=9C=EC=98=A4=EB=A5=98?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/storybook.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/storybook.yml b/.github/workflows/storybook.yml index b11bfca..01c4651 100644 --- a/.github/workflows/storybook.yml +++ b/.github/workflows/storybook.yml @@ -22,8 +22,15 @@ jobs: with: fetch-depth: 0 + - name: Node.js 설정 + uses: actions/setup-node@v3 + with: + node-version: 18 + cache: 'pnpm' + - name: pnpm 직접 설치 - run: npm install -g pnpm + run: | + npm install -g pnpm pnpm --version From 9e30cb080f19392341a90bdb2d42b77466cfe049 Mon Sep 17 00:00:00 2001 From: beom Date: Wed, 5 Feb 2025 16:53:01 +0900 Subject: [PATCH 5/7] =?UTF-8?q?Fix=20:=20=EB=B9=8C=EB=93=9C=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=20=EC=88=98=EC=A0=95(2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/storybook.yml | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/.github/workflows/storybook.yml b/.github/workflows/storybook.yml index 01c4651..908d289 100644 --- a/.github/workflows/storybook.yml +++ b/.github/workflows/storybook.yml @@ -22,16 +22,11 @@ jobs: with: fetch-depth: 0 - - name: Node.js 설정 - uses: actions/setup-node@v3 - with: - node-version: 18 - cache: 'pnpm' - - - name: pnpm 직접 설치 - run: | - npm install -g pnpm - pnpm --version + - name: Corepack 활성화 + run: corepack enable + + - name: pnpm 설치 + run: corepack prepare pnpm@latest --activate - name: 캐시 종속성 From 1cde93406eb28223a25336afdca24b689c67a19d Mon Sep 17 00:00:00 2001 From: beom Date: Thu, 6 Feb 2025 16:15:07 +0900 Subject: [PATCH 6/7] =?UTF-8?q?Fix:=20=EB=B9=8C=EB=93=9C=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=20=EC=88=98=EC=A0=95(3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/storybook.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/storybook.yml b/.github/workflows/storybook.yml index 908d289..ac75ec3 100644 --- a/.github/workflows/storybook.yml +++ b/.github/workflows/storybook.yml @@ -22,12 +22,14 @@ jobs: with: fetch-depth: 0 - - name: Corepack 활성화 - run: corepack enable - - - name: pnpm 설치 - run: corepack prepare pnpm@latest --activate + - name: Corepack 최신 버전 설치 + run: npm install -g corepack@latest + - name: Corepack 활성화 및 PNPM 설치 + run: | + corepack enable + corepack prepare pnpm@latest-10 --activate + npm install -g pnpm@latest - name: 캐시 종속성 id: cache From 52fd41b4c9ce8746f79c71819aee0e8bc2e7a409 Mon Sep 17 00:00:00 2001 From: beom Date: Thu, 6 Feb 2025 16:22:44 +0900 Subject: [PATCH 7/7] =?UTF-8?q?Fix:=20=EB=B9=8C=EB=93=9C=EC=98=A4=EB=A5=98?= =?UTF-8?q?=20=EC=88=98=EC=A0=95(4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/storybook.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/storybook.yml b/.github/workflows/storybook.yml index ac75ec3..4347ea0 100644 --- a/.github/workflows/storybook.yml +++ b/.github/workflows/storybook.yml @@ -25,11 +25,19 @@ jobs: - name: Corepack 최신 버전 설치 run: npm install -g corepack@latest - - name: Corepack 활성화 및 PNPM 설치 + - name: 기존 pnpm 제거 (필요한 경우만) + run: | + if command -v pnpm &> /dev/null; then + echo "pnpm detected, removing..." + npm uninstall -g pnpm + fi + + - name: Corepack 활성화 및 최신 pnpm 설치 run: | corepack enable corepack prepare pnpm@latest-10 --activate - npm install -g pnpm@latest + npm install -g pnpm@latest || echo "pnpm already installed" + - name: 캐시 종속성 id: cache