From 4a28344cbceb244c3ad4c3091c236d8c9003a68e Mon Sep 17 00:00:00 2001 From: YUNHO Date: Thu, 6 Jul 2023 15:57:10 +0900 Subject: [PATCH] =?UTF-8?q?=EC=A3=BC=EB=AF=BC=EC=A6=9D=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20boadring=ED=8E=98=EC=9D=B4=EC=A7=80,=20=EC=A3=BC?= =?UTF-8?q?=EB=AF=BC=EC=A6=9D=EC=9D=B4=20=EC=97=86=EB=8A=94=20=EA=B2=BD?= =?UTF-8?q?=EC=9A=B0=20=EB=A7=88=EC=9D=B4=ED=8E=98=EC=9D=B4=EC=A7=80?= =?UTF-8?q?=EC=97=90=20=EC=A0=91=EA=B7=BC=ED=96=88=EC=9D=84=20=EB=95=8C=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC=20(#260)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: 주민증 생성 boadring페이지에 뒤로가기 버튼 * feat: checkIdCardServer * feat: CreateIdCardButton * refactor: MyPage 주민증이 없는 경우 마이페이지에 접근했을 때 처리 * refactor: EmptyPlanet에서 PlanetCreationButton 분리 --- src/api/domain/community.api.server.ts | 4 + .../components/MyPageIdCard/MyPageIdCard.tsx | 31 +++--- src/app/my-page/[communityId]/page.tsx | 15 +-- src/app/my-page/empty/page.tsx | 32 +----- .../CreateIdCardButton.client.tsx | 31 ++++++ .../CreateIdCardButton.stories.tsx | 17 ++++ src/modules/CreateIdCardButton/index.ts | 1 + .../Step/BoardingStep.client.tsx | 98 ++++++++++--------- 8 files changed, 138 insertions(+), 91 deletions(-) create mode 100644 src/modules/CreateIdCardButton/CreateIdCardButton.client.tsx create mode 100644 src/modules/CreateIdCardButton/CreateIdCardButton.stories.tsx create mode 100644 src/modules/CreateIdCardButton/index.ts diff --git a/src/api/domain/community.api.server.ts b/src/api/domain/community.api.server.ts index fd3f2e7b..92bfae6b 100644 --- a/src/api/domain/community.api.server.ts +++ b/src/api/domain/community.api.server.ts @@ -1,4 +1,5 @@ import { + CheckIdCardResponse, CommunityDetailResponse, CommunityIdCardsRequest, CommunityIdCardsResponse, @@ -24,3 +25,6 @@ export const getCommunityIdCardsServer = ({ export const getCommunityListServer = (userId: number) => privateApi.get(`/communities/users/${userId}`); + +export const checkIdCardServer = (communityId: number) => + privateApi.get(`/communities/${communityId}/users`); diff --git a/src/app/my-page/[communityId]/components/MyPageIdCard/MyPageIdCard.tsx b/src/app/my-page/[communityId]/components/MyPageIdCard/MyPageIdCard.tsx index a87c4382..ee02e76e 100644 --- a/src/app/my-page/[communityId]/components/MyPageIdCard/MyPageIdCard.tsx +++ b/src/app/my-page/[communityId]/components/MyPageIdCard/MyPageIdCard.tsx @@ -5,33 +5,40 @@ import { Suspense } from 'react'; import { getCommunityMyIdCardDetailServer } from '~/api/domain/idCard.api.server'; import RetryErrorBoundary from '~/components/ErrorBoundary/RetryErrorBoundary.client'; import { IdCard } from '~/modules/IdCard'; +import { IdCardEditButton } from '~/modules/IdCardEditButton'; type MyPageProps = { - id: number; + communityId: number; }; -const MyPageIdCardComponent = async ({ id }: MyPageProps) => { - const { idCardDetailsDto } = await getCommunityMyIdCardDetailServer(id); +const MyPageIdCardComponent = async ({ communityId }: MyPageProps) => { + const { idCardDetailsDto } = await getCommunityMyIdCardDetailServer(communityId); const { idCardId, nickname, aboutMe, characterType, keywords } = idCardDetailsDto; const keywordTitles = keywords.map(keyword => keyword.title); return ( - +
+
+

내 주민증

+ +
+ +
); }; -export const MyPageIdCard = ({ id }: MyPageProps) => { +export const MyPageIdCard = ({ communityId }: MyPageProps) => { return ( {/* @ts-expect-error Server Component */} - + ); diff --git a/src/app/my-page/[communityId]/page.tsx b/src/app/my-page/[communityId]/page.tsx index d453c3c5..cb6067b4 100644 --- a/src/app/my-page/[communityId]/page.tsx +++ b/src/app/my-page/[communityId]/page.tsx @@ -1,10 +1,13 @@ +import 'server-only'; + import Link from 'next/link'; +import { checkIdCardServer } from '~/api/domain/community.api.server'; import { MyPageIdCard } from '~/app/my-page/[communityId]/components/MyPageIdCard'; import { BottomNavigation } from '~/components/BottomNavigation'; import { GearFillIcon } from '~/components/Icon'; import { TopNavigation } from '~/components/TopNavigation'; -import { IdCardEditButton } from '~/modules/IdCardEditButton'; +import { CreateIdCardButton } from '~/modules/CreateIdCardButton'; import { PlanetCreationButton } from '~/modules/PlanetCreationButton'; import { PlanetSelector } from '~/modules/PlanetSelector'; @@ -14,7 +17,9 @@ type MyPageProps = { }; }; -const MyPage = ({ params: { communityId } }: MyPageProps) => { +const MyPage = async ({ params: { communityId } }: MyPageProps) => { + const { userMakeIdCard } = await checkIdCardServer(communityId); + const isUserMakeIdCard = userMakeIdCard; return (
@@ -29,11 +34,7 @@ const MyPage = ({ params: { communityId } }: MyPageProps) => {
-
-

내 주민증

- -
- + {isUserMakeIdCard ? : }
diff --git a/src/app/my-page/empty/page.tsx b/src/app/my-page/empty/page.tsx index 367361a9..dc7e30eb 100644 --- a/src/app/my-page/empty/page.tsx +++ b/src/app/my-page/empty/page.tsx @@ -1,29 +1,16 @@ -'use client'; import Link from 'next/link'; -import { useRouter } from 'next/navigation'; import { BottomNavigation } from '~/components/BottomNavigation'; -import { GearFillIcon, PlusIcon } from '~/components/Icon'; +import { GearFillIcon } from '~/components/Icon'; import { TopNavigation } from '~/components/TopNavigation'; +import { CreateIdCardButton } from '~/modules/CreateIdCardButton'; import { PlanetCreationButton } from '~/modules/PlanetCreationButton'; -import { PlanetSelector } from '~/modules/PlanetSelector'; -import { useCommunityStore } from '~/stores/community.store'; const EmptyPlanet = () => { - const { communityId } = useCommunityStore(); - const router = useRouter(); - - // TODO: communityId가 없는 경우 에러 처리가 필요해요( ex. 홈이나 다른 페이지로 보내기) - const onClickCreateIdCardButton = () => { - router.replace(`/planet/${communityId}/id-card/create`); - }; - return (
- - - + @@ -32,18 +19,7 @@ const EmptyPlanet = () => {
-

내 주민증

-
-
- - 주민증 만들기 -
-
+
diff --git a/src/modules/CreateIdCardButton/CreateIdCardButton.client.tsx b/src/modules/CreateIdCardButton/CreateIdCardButton.client.tsx new file mode 100644 index 00000000..c4f53e09 --- /dev/null +++ b/src/modules/CreateIdCardButton/CreateIdCardButton.client.tsx @@ -0,0 +1,31 @@ +'use client'; +import { useRouter } from 'next/navigation'; + +import { PlusIcon } from '~/components/Icon'; +import { useCommunityStore } from '~/stores/community.store'; + +export const CreateIdCardButton = () => { + const { communityId } = useCommunityStore(); + const router = useRouter(); + + // TODO: communityId가 없는 경우 에러 처리가 필요해요( ex. 홈이나 다른 페이지로 보내기) + const onClickCreateIdCardButton = () => { + router.replace(`/planet/${communityId}/id-card/create`); + }; + return ( +
+

내 주민증

+
+
+ + 주민증 만들기 +
+
+
+ ); +}; diff --git a/src/modules/CreateIdCardButton/CreateIdCardButton.stories.tsx b/src/modules/CreateIdCardButton/CreateIdCardButton.stories.tsx new file mode 100644 index 00000000..7348ab55 --- /dev/null +++ b/src/modules/CreateIdCardButton/CreateIdCardButton.stories.tsx @@ -0,0 +1,17 @@ +import type { Meta, StoryObj } from '@storybook/react'; + +import { CreateIdCardButton } from './index'; + +const meta: Meta = { + title: 'modules/CreateIdCardButton', + component: CreateIdCardButton, + args: {}, +}; + +export default meta; + +type Story = StoryObj; + +export const Primary: Story = { + render: () => , +}; diff --git a/src/modules/CreateIdCardButton/index.ts b/src/modules/CreateIdCardButton/index.ts new file mode 100644 index 00000000..8247c896 --- /dev/null +++ b/src/modules/CreateIdCardButton/index.ts @@ -0,0 +1 @@ +export * from './CreateIdCardButton.client'; diff --git a/src/modules/IdCardCreation/Step/BoardingStep.client.tsx b/src/modules/IdCardCreation/Step/BoardingStep.client.tsx index cf381528..e31b6481 100644 --- a/src/modules/IdCardCreation/Step/BoardingStep.client.tsx +++ b/src/modules/IdCardCreation/Step/BoardingStep.client.tsx @@ -5,6 +5,7 @@ import Image from 'next/image'; import BottomSheet, { useBottomSheet } from '~/components/BottomSheet'; import { Button, TextButton } from '~/components/Button'; import { QuestionCircleIcon } from '~/components/Icon'; +import { TopNavigation } from '~/components/TopNavigation'; type BoardingStepProps = { onNext: VoidFunction; @@ -17,56 +18,65 @@ export const BoardingStep = ({ onNext }: BoardingStepProps) => { }; return ( -
-

주민증으로 나를 소개해요!

-

- {`주민증에 담기는 내용을 언제든지\n수정할 수 있어요.`} -

-
-
- explain id card - onClickHelperText()}> - - 어떻게 수정하나요? - -
-
- - - 주민증 수정 - -
+
+ + + + + +
+

주민증으로 나를 소개해요!

+

+ {`주민증에 담기는 내용을 언제든지\n수정할 수 있어요.`} +

+
+
explain id card - 마이페이지에서 주민증을 수정할 수 있어요. + onClickHelperText()}> + + 어떻게 수정하나요? +
- - - - 확인했어요. - - - +
+ + + 주민증 수정 + +
+ explain id card + + 마이페이지에서 주민증을 수정할 수 있어요. + +
+
+ + + 확인했어요. + + +
+
); };