From 737bec7fe6c05d328cfdfb68ac4c5c7a2604fd95 Mon Sep 17 00:00:00 2001 From: sukvvon Date: Sat, 23 Dec 2023 09:09:35 +0900 Subject: [PATCH 1/2] =?UTF-8?q?feat(shelter):=20=EB=B4=89=EC=82=AC=20?= =?UTF-8?q?=EC=8B=A0=EC=B2=AD=20=EC=83=81=ED=83=9C=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?msw=EC=97=90=20403,=20404=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../shelter/src/mocks/handlers/recruitment.ts | 36 ++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/apps/shelter/src/mocks/handlers/recruitment.ts b/apps/shelter/src/mocks/handlers/recruitment.ts index 79ca0e06..86028bc2 100644 --- a/apps/shelter/src/mocks/handlers/recruitment.ts +++ b/apps/shelter/src/mocks/handlers/recruitment.ts @@ -32,10 +32,12 @@ export const DUMMY_APPLICANT = { applicantStatus: 'APPROVED', }; -export const DUMMY_APPLICANT_LIST = Array.from( - { length: 9 }, - () => DUMMY_APPLICANT, -); +export const DUMMY_APPLICANT_LIST = Array.from({ length: 9 }, (_, index) => { + return { + ...DUMMY_APPLICANT, + volunteerName: !(index % 2) ? '김철수' : '김영희', + }; +}); export const handlers = [ http.get('/shelters/recruitments', async () => { @@ -60,6 +62,32 @@ export const handlers = [ return HttpResponse.json({}, { status: 200 }); }, ), + http.patch( + '/shelters/recruitments/:recruitmentId/applicants/:applicantId', + async () => { + await delay(200); + return HttpResponse.json( + { + errorCode: 'AF301', + message: '해당 모집글에 대해 권한이 없습니다', + }, + { status: 403 }, + ); + }, + ), + http.patch( + '/shelters/recruitments/:recruitmentId/applicants/:applicantId', + async () => { + await delay(200); + return HttpResponse.json( + { + errorCode: 'AF401', + message: '해당 모집글을 신청한 봉사자가 아닙니다', + }, + { status: 404 }, + ); + }, + ), http.get('/shelters/recruitments/:recruitmentId/applicants', async () => { await delay(200); return HttpResponse.json({ From 7e3be70631c258f99fdd0115956fe7848248647e Mon Sep 17 00:00:00 2001 From: sukvvon Date: Sat, 23 Dec 2023 09:13:51 +0900 Subject: [PATCH 2/2] =?UTF-8?q?refactor(shelter):=20updateToast=EB=A1=9C,?= =?UTF-8?q?=20toast=20=EC=84=A4=EB=AA=85=EC=9D=98=20fontWeight=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD,=20useMutation=EC=97=90=20onError=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../apply/_components/ManageApplyItem.tsx | 57 +++++++++++++++++-- 1 file changed, 51 insertions(+), 6 deletions(-) diff --git a/apps/shelter/src/pages/manage/apply/_components/ManageApplyItem.tsx b/apps/shelter/src/pages/manage/apply/_components/ManageApplyItem.tsx index 89d1e00b..a82d849b 100644 --- a/apps/shelter/src/pages/manage/apply/_components/ManageApplyItem.tsx +++ b/apps/shelter/src/pages/manage/apply/_components/ManageApplyItem.tsx @@ -3,6 +3,7 @@ import { useMutation, useQueryClient } from '@tanstack/react-query'; import Label from 'shared/components/Label'; import { PERSON_GENDER_KOR } from 'shared/constants/gender'; import { getAge } from 'shared/utils/date'; +import { updateToast } from 'shared/utils/toast'; import { updateShelterRecruitmentApplicant } from '@/apis/recruitment'; import CkCheck from '@/assets/CkCheck'; @@ -34,6 +35,7 @@ export default function ManageApplyItem({ }, }: ManageApplyItemProps) { const toast = useToast(); + const manageApplyId = 'manage-apply'; const queryClient = useQueryClient(); const { mutate } = useMutation({ mutationFn: (data: RecruitmentApplicantUpdateRequest) => @@ -47,12 +49,55 @@ export default function ManageApplyItem({ ? APPLICANT_STATUS_KOR.APPROVE : APPLICANT_STATUS_KOR.REFUSE; - toast({ - position: 'top', - description: `${volunteerName}님의 봉사신청을 ${descriptionStatus}했습니다`, - status: 'success', - duration: 1000, - isClosable: true, + toast.close(manageApplyId); + + await new Promise((resolve) => setTimeout(resolve, 200)); + + updateToast({ + toast, + toastId: manageApplyId, + toastOptions: { + position: 'top', + description: ( + + + {volunteerName} + + 님의 신청을{` `} + + {descriptionStatus} + + 했습니다 + + ), + status: 'success', + duration: 1500, + isClosable: true, + }, + }); + }, + onError: async (error) => { + toast.close(manageApplyId); + + await new Promise((resolve) => setTimeout(resolve, 200)); + + updateToast({ + toast, + toastId: manageApplyId, + toastOptions: { + position: 'top', + description: ( + + + {volunteerName} + + 님은 {error.response?.data.message} + + ), + status: 'error', + duration: 1500, + isClosable: true, + }, }); }, });