Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 봉사자 신청현황 페이지 toast updatToast로 변경, onError 추가, toast 설명 폰트 속성 변경 #330

Merged
merged 2 commits into from
Dec 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 32 additions & 4 deletions apps/shelter/src/mocks/handlers/recruitment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -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({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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) =>
Expand All @@ -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: (
<Text w="100%">
<Text as="span" fontWeight="bold">
{volunteerName}
</Text>
님의 신청을{` `}
<Text as="span" fontWeight="bold">
{descriptionStatus}
</Text>
했습니다
</Text>
),
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: (
<Text>
<Text as="span" fontWeight="bold">
{volunteerName}
</Text>
님은 {error.response?.data.message}
</Text>
),
status: 'error',
duration: 1500,
isClosable: true,
},
});
},
});
Expand Down