From 1e143dcc7d4d8e43c426255b2ededdb4b8462a1a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 4 Sep 2024 02:48:45 +0000 Subject: [PATCH 1/6] Create draft PR for #639 From ef0520121e2327bac4c11eb4043d922be2c3a170 Mon Sep 17 00:00:00 2001 From: Kim Da Eun Date: Mon, 9 Sep 2024 19:47:43 +0900 Subject: [PATCH 2/6] =?UTF-8?q?=08fix:=20=EB=8C=80=EC=8B=9C=EB=B3=B4?= =?UTF-8?q?=EB=93=9C=20=EA=B4=80=EB=A0=A8=20=EC=9A=94=EC=B2=AD=EC=9D=98=20?= =?UTF-8?q?clubId=20=ED=95=84=EB=93=9C=EC=97=90=20dashboardId=EA=B0=80=20?= =?UTF-8?q?=EB=93=A4=EC=96=B4=EA=B0=80=EB=8A=94=20=EB=B2=84=EA=B7=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - url 패턴 리팩토링: 대시보드 생성, 특정 공고의 대시보드 페이지 url, 공고 목록 페이지의 url이 변경됨. - url 상수화 - 대시보드 응답 body의 postUrl 삭제 및 dashboardId와 postId를 전달하는 것으로 변경 - clubId가 들어가야 할 곳에 dashboardId가 들어가는 오류 픽스 - API 명세 변경에 따른 mock data 변경(postUrl 제거, id 정보를 전달하는 것으로 변경) - clubId 관리 기능(useClubId) 추가 --- frontend/src/api/domain/dashboard.ts | 6 ++-- frontend/src/api/domain/process.ts | 4 +-- .../common/ApiErrorBoundary/index.tsx | 7 ++++ .../DashboardCreate/Finish/Finish.stories.tsx | 6 ++-- .../DashboardCreate/Finish/index.tsx | 13 ++++---- .../DashboardSidebar.stories.tsx | 12 ++++--- .../dashboard/DashboardSidebar/index.tsx | 16 +++++----- .../RecruitmentCard.stories.tsx | 4 +-- .../recruitment/RecruitmentCard/index.tsx | 6 ++-- frontend/src/constants/constants.ts | 1 + frontend/src/hooks/apply.ts | 3 +- frontend/src/hooks/service/useClubId.ts | 32 +++++++++++++++++++ .../hooks/useDashboardCreateForm/index.tsx | 22 ++++++------- frontend/src/hooks/useGetDashboards/index.tsx | 12 +++---- frontend/src/hooks/useProcess/index.ts | 6 ++-- frontend/src/hooks/useSignIn/index.tsx | 6 +++- frontend/src/hooks/useSignOut/index.ts | 6 +++- frontend/src/mocks/dashboardList.json | 6 ++-- .../src/mocks/handlers/dashboardHandlers.ts | 4 +-- frontend/src/mocks/processMockData.json | 2 +- frontend/src/pages/ConfirmApply/index.tsx | 5 +-- frontend/src/pages/DashBoardList/index.tsx | 19 ++++++----- frontend/src/pages/Dashboard/index.tsx | 4 +-- frontend/src/pages/DashboardCreate/index.tsx | 14 +++----- frontend/src/pages/DashboardLayout/index.tsx | 13 ++++---- frontend/src/pages/ErrorPage/index.tsx | 10 ++++-- frontend/src/pages/Landing/index.tsx | 3 +- frontend/src/router/AppRouter.tsx | 23 ++++++------- frontend/src/router/path.ts | 27 ++++++++++++++++ frontend/src/types/dashboard.ts | 2 +- frontend/src/types/process.ts | 2 +- frontend/tsconfig.json | 3 +- frontend/webpack.config.js | 1 + 33 files changed, 192 insertions(+), 108 deletions(-) create mode 100644 frontend/src/hooks/service/useClubId.ts create mode 100644 frontend/src/router/path.ts diff --git a/frontend/src/api/domain/dashboard.ts b/frontend/src/api/domain/dashboard.ts index 87af9e577..bc0f38a67 100644 --- a/frontend/src/api/domain/dashboard.ts +++ b/frontend/src/api/domain/dashboard.ts @@ -6,9 +6,9 @@ import APIClient from '../APIClient'; const apiClient = new APIClient(DASHBOARDS); const dashboardApis = { - get: async ({ dashboardId }: { dashboardId: string }) => { + get: async ({ clubId }: { clubId: string }) => { const queryParams = { - clubId: dashboardId, + clubId, }; return apiClient.get({ @@ -18,7 +18,7 @@ const dashboardApis = { create: async ({ clubId, dashboardFormInfo }: { clubId: string; dashboardFormInfo: DashboardFormInfo }) => apiClient.post<{ - postUrl: string; + dashboardId: string; postId: string; }>({ path: `?${convertParamsToQueryString({ clubId })}`, diff --git a/frontend/src/api/domain/process.ts b/frontend/src/api/domain/process.ts index e8dd34fa8..079e7903e 100644 --- a/frontend/src/api/domain/process.ts +++ b/frontend/src/api/domain/process.ts @@ -6,9 +6,9 @@ import APIClient from '../APIClient'; const apiClient = new APIClient(PROCESSES); const processApis = { - get: async ({ id }: { id: string }): Promise => + get: async ({ dashboardId }: { dashboardId: string }): Promise => apiClient.get({ - path: `?${createParams({ dashboardId: id })}`, + path: `?${createParams({ dashboardId })}`, }), create: async (params: { dashboardId: number; orderIndex: number; name: string; description?: string }) => diff --git a/frontend/src/components/common/ApiErrorBoundary/index.tsx b/frontend/src/components/common/ApiErrorBoundary/index.tsx index 85c40f983..d3299a855 100644 --- a/frontend/src/components/common/ApiErrorBoundary/index.tsx +++ b/frontend/src/components/common/ApiErrorBoundary/index.tsx @@ -2,12 +2,15 @@ import ApiError from '@api/ApiError'; import { QueryErrorResetBoundary } from '@tanstack/react-query'; import { ErrorBoundary, ErrorBoundaryPropsWithComponent, FallbackProps } from 'react-error-boundary'; import * as Sentry from '@sentry/react'; +import useClubId from '@hooks/service/useClubId'; interface ApiErrorBoundaryProps extends ErrorBoundaryPropsWithComponent { FallbackComponent: React.ComponentType; } export default function ApiErrorBoundary({ FallbackComponent, children }: ApiErrorBoundaryProps) { + const { clearClubId } = useClubId(); + const fallbackRender = (props: FallbackProps) => { if (!(props.error instanceof ApiError)) { throw props.error; @@ -24,6 +27,10 @@ export default function ApiErrorBoundary({ FallbackComponent, children }: ApiErr onError={(error, info) => { const apiError = error as ApiError; + if (apiError.statusCode === 401) { + clearClubId(); + } + Sentry.withScope((scope) => { scope.setLevel('error'); scope.setTag('statusCode', apiError.statusCode); diff --git a/frontend/src/components/dashboard/DashboardCreate/Finish/Finish.stories.tsx b/frontend/src/components/dashboard/DashboardCreate/Finish/Finish.stories.tsx index ca995218a..c92709a8f 100644 --- a/frontend/src/components/dashboard/DashboardCreate/Finish/Finish.stories.tsx +++ b/frontend/src/components/dashboard/DashboardCreate/Finish/Finish.stories.tsx @@ -23,8 +23,8 @@ const meta: Meta = { }, tags: ['autodocs'], argTypes: { - postUrl: { - description: '게시된 공고의 URL입니다.', + dashboardId: { + description: '게시된 공고의 대시보드 ID입니다.', control: { type: 'text' }, table: { type: { summary: 'string' }, @@ -45,7 +45,7 @@ type Story = StoryObj; export const Template: Story = { args: { - postUrl: 'https://www.cruru.kr/123543920/recruit', + dashboardId: '1', postId: '1', }, }; diff --git a/frontend/src/components/dashboard/DashboardCreate/Finish/index.tsx b/frontend/src/components/dashboard/DashboardCreate/Finish/index.tsx index 6c23c8ffd..2c7057b6e 100644 --- a/frontend/src/components/dashboard/DashboardCreate/Finish/index.tsx +++ b/frontend/src/components/dashboard/DashboardCreate/Finish/index.tsx @@ -1,27 +1,28 @@ import Button from '@components/common/Button'; import ChevronButton from '@components/common/ChevronButton'; -import { useNavigate, useParams } from 'react-router-dom'; +import { routes } from '@router/path'; +import { useNavigate } from 'react-router-dom'; +import { DOMAIN_URL } from '@constants/constants'; import SharePost from '../SharePost'; import S from './style'; interface FinishProps { - postUrl: string; + dashboardId: string; postId: string; } -export default function Finish({ postUrl, postId }: FinishProps) { +export default function Finish({ dashboardId, postId }: FinishProps) { const navigate = useNavigate(); - const { dashboardId } = useParams() as { dashboardId: string }; const handleClickButton = () => { - navigate(`/dashboard/${dashboardId}/${postId}`); + navigate(routes.dashboard.post({ dashboardId, postId })); }; return ( 🎉 공고가 게시됐어요! - +