From e08906d84f9771b666653365f6dc56beae350966 Mon Sep 17 00:00:00 2001 From: Eosdia Date: Sat, 2 Dec 2023 18:36:06 +0900 Subject: [PATCH 1/3] =?UTF-8?q?fix(shelter):=20=EB=B3=B4=ED=98=B8=EC=86=8C?= =?UTF-8?q?=20address=20validation=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/shelter/src/pages/settings/account/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/shelter/src/pages/settings/account/index.tsx b/apps/shelter/src/pages/settings/account/index.tsx index 0c8e621f..0962e811 100644 --- a/apps/shelter/src/pages/settings/account/index.tsx +++ b/apps/shelter/src/pages/settings/account/index.tsx @@ -29,7 +29,7 @@ const phoneRegx2 = /^(0(2|3[1-3]|4[1-4]|5[1-5]|6[1-4]))-(\d{3,4})-(\d{4})$/; const accountSchema = z.object({ name: z.string().trim().min(2, { message: '이름은 2글자 이상입니다' }), - address: z.string().min(3, { message: '보호소 주소 정보는 필수입니다' }), + address: z.string().min(1, { message: '보호소 주소 정보는 필수입니다' }), addressDetail: z .string() .trim() From cca4254817708ad0cf01e7b75d0b65ff75c307b9 Mon Sep 17 00:00:00 2001 From: Eosdia Date: Sat, 2 Dec 2023 19:00:27 +0900 Subject: [PATCH 2/3] =?UTF-8?q?feat(shelter):=20=EB=B4=89=EC=82=AC?= =?UTF-8?q?=EB=AA=A8=EC=A7=91=20=EB=A7=88=EA=B0=90=20api=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 --- .../src/pages/volunteers/detail/index.tsx | 37 +++++++++++++++---- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/apps/shelter/src/pages/volunteers/detail/index.tsx b/apps/shelter/src/pages/volunteers/detail/index.tsx index 753e4668..a0fcb9ca 100644 --- a/apps/shelter/src/pages/volunteers/detail/index.tsx +++ b/apps/shelter/src/pages/volunteers/detail/index.tsx @@ -5,8 +5,10 @@ import { HStack, Text, useDisclosure, + useToast, VStack, } from '@chakra-ui/react'; +import { useMutation } from '@tanstack/react-query'; import { Suspense, useEffect, useState } from 'react'; import { useNavigate, useParams } from 'react-router-dom'; import AlertModal from 'shared/components/AlertModal'; @@ -21,16 +23,21 @@ import { getDDay, } from 'shared/utils/date'; +import { + closeShelterRecruitment, + deleteShelterRecruitment, +} from '@/apis/recruitment'; + import useGetVolunteerDetail from './_hooks/useGetVolunteerDetail'; const handleDeletePost = (postId: number) => { - // TODO: VolunteerPost delete API 호출 - console.log('[Delete Volunteer] postId:', postId); + deleteShelterRecruitment(postId); }; function VolunteersDetail() { const setOnDelete = useDetailHeaderStore((state) => state.setOnDelete); + const toast = useToast(); useEffect(() => { setOnDelete(handleDeletePost); @@ -40,11 +47,26 @@ function VolunteersDetail() { }, [setOnDelete]); const navigate = useNavigate(); - const { id: recruitmentId } = useParams(); + const { id } = useParams(); + const recruitmentId = Number(id); const { isOpen, onOpen, onClose } = useDisclosure(); - const { data: recruitment } = useGetVolunteerDetail(Number(recruitmentId)); + const { data: recruitment } = useGetVolunteerDetail(recruitmentId); + + const { mutate: closedRecruitment } = useMutation({ + mutationFn: async (recruitmentId: number) => + closeShelterRecruitment(recruitmentId), + onSuccess: () => { + setLabel({ labelTitle: '마감완료', type: 'GRAY' }); + toast({ + position: 'top', + description: '모집마감되었습니다.', + status: 'success', + duration: 1500, + }); + }, + }); const startDate = new Date(recruitment.startTime); const deadline = new Date(recruitment.deadline); @@ -72,10 +94,11 @@ function VolunteersDetail() { const goManageApply = () => navigate(`/manage/apply/${recruitmentId}`); const goManageAttendance = () => navigate(`/manage/attendance/${recruitmentId}`); - const onCloseRecruitment = () => { + const onCloseRecruitment = (recruitmentId: number) => { + closedRecruitment(recruitmentId); onClose(); setIsClosed(true); - setLabel({ labelTitle: '마감완료', type: 'GRAY' }); + // setLabel({ labelTitle: '마감완료', type: 'GRAY' }); }; return ( @@ -168,7 +191,7 @@ function VolunteersDetail() { btnTitle="마감하기" isOpen={isOpen} onClose={onClose} - onClick={onCloseRecruitment} + onClick={() => onCloseRecruitment(recruitmentId)} /> ); From ed51864ad6c2fb4c156f574abf8dae7e1e1e87b4 Mon Sep 17 00:00:00 2001 From: Eosdia Date: Sat, 2 Dec 2023 19:21:59 +0900 Subject: [PATCH 3/3] =?UTF-8?q?feat(shelter):=20=EB=B4=89=EC=82=AC?= =?UTF-8?q?=EB=AA=A8=EC=A7=91=EB=A7=88=EA=B0=90=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/pages/volunteers/detail/index.tsx | 41 +++++++++---------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/apps/shelter/src/pages/volunteers/detail/index.tsx b/apps/shelter/src/pages/volunteers/detail/index.tsx index a0fcb9ca..bb72913d 100644 --- a/apps/shelter/src/pages/volunteers/detail/index.tsx +++ b/apps/shelter/src/pages/volunteers/detail/index.tsx @@ -14,7 +14,7 @@ import { useNavigate, useParams } from 'react-router-dom'; import AlertModal from 'shared/components/AlertModal'; import ImageCarousel from 'shared/components/ImageCarousel'; import InfoTextList from 'shared/components/InfoTextList'; -import { LabelProps } from 'shared/components/Label'; +import Label from 'shared/components/Label'; import LabelText from 'shared/components/LabelText'; import useDetailHeaderStore from 'shared/store/detailHeaderStore'; import { @@ -58,19 +58,23 @@ function VolunteersDetail() { mutationFn: async (recruitmentId: number) => closeShelterRecruitment(recruitmentId), onSuccess: () => { - setLabel({ labelTitle: '마감완료', type: 'GRAY' }); toast({ position: 'top', description: '모집마감되었습니다.', status: 'success', duration: 1500, }); + setIsClosed(true); + }, + onError: (error) => { + console.error(error); }, }); const startDate = new Date(recruitment.startTime); const deadline = new Date(recruitment.deadline); const createdAt = new Date(recruitment.createdAt); + const volunteerDateDay = getDDay(recruitment.deadline); const volunteerDate = createFormattedTime(startDate); const volunteerDay = createWeekDayLocalString(startDate); @@ -78,18 +82,9 @@ function VolunteersDetail() { const deadlineDate = createFormattedTime(deadline); const deadlineDay = createWeekDayLocalString(deadline); - const [label, setLabel] = useState({ - labelTitle: '모집중', - type: 'GREEN', - }); - const [isClosed, setIsClosed] = useState(false); - - useEffect(() => { - if (recruitment.isClosed) { - setIsClosed(true); - setLabel({ labelTitle: '마감완료', type: 'GRAY' }); - } - }, [recruitment.isClosed]); + const [isClosed, setIsClosed] = useState( + recruitment.isClosed || volunteerDateDay < 0, + ); const goManageApply = () => navigate(`/manage/apply/${recruitmentId}`); const goManageAttendance = () => @@ -97,8 +92,6 @@ function VolunteersDetail() { const onCloseRecruitment = (recruitmentId: number) => { closedRecruitment(recruitmentId); onClose(); - setIsClosed(true); - // setLabel({ labelTitle: '마감완료', type: 'GRAY' }); }; return ( @@ -107,16 +100,20 @@ function VolunteersDetail() { )} - + {isClosed ? ( +