From 27f258eaf7fcdb00775095a5c7c0160dd934c477 Mon Sep 17 00:00:00 2001 From: simeunseo Date: Wed, 11 Oct 2023 23:37:20 +0900 Subject: [PATCH 1/2] =?UTF-8?q?chore:=20=EB=A1=9C=EC=A7=81=20=ED=8C=8C?= =?UTF-8?q?=EC=95=85=20=EC=A3=BC=EC=84=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/scheduleComponents/utils/IsContainingAfternoon.ts | 0 src/components/scheduleComponents/utils/isMorningDinner.ts | 1 + src/pages/selectSchedule/components/SelectSchedule.tsx | 1 + 3 files changed, 2 insertions(+) create mode 100644 src/components/scheduleComponents/utils/IsContainingAfternoon.ts create mode 100644 src/components/scheduleComponents/utils/isMorningDinner.ts diff --git a/src/components/scheduleComponents/utils/IsContainingAfternoon.ts b/src/components/scheduleComponents/utils/IsContainingAfternoon.ts new file mode 100644 index 00000000..e69de29b diff --git a/src/components/scheduleComponents/utils/isMorningDinner.ts b/src/components/scheduleComponents/utils/isMorningDinner.ts new file mode 100644 index 00000000..000123a1 --- /dev/null +++ b/src/components/scheduleComponents/utils/isMorningDinner.ts @@ -0,0 +1 @@ +//아침 저녁인지를 확인하는 util diff --git a/src/pages/selectSchedule/components/SelectSchedule.tsx b/src/pages/selectSchedule/components/SelectSchedule.tsx index 30a46fc6..4c90f1f9 100644 --- a/src/pages/selectSchedule/components/SelectSchedule.tsx +++ b/src/pages/selectSchedule/components/SelectSchedule.tsx @@ -41,6 +41,7 @@ function SelectSchedule({ scheduleList, availableDates, preferTimes, setSchedule else if (compareTime(startTime,schedule.endTime)){ return { ...schedule, startTime }; } + //isMorningDinner가 true라면 isContainingAfternoon실행 else{ alert("종료 시간은 시작 시간 이후로 설정해주세요!"); } From fbcb358c9da1079676f3e707cdbb6e71e4556281 Mon Sep 17 00:00:00 2001 From: simeunseo Date: Mon, 16 Oct 2023 16:03:26 +0900 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=EC=98=A4=EC=A0=84/=EC=A0=80?= =?UTF-8?q?=EB=85=81=20=EC=8B=9C=EA=B0=84=ED=91=9C=EC=9D=BC=EC=8B=9C=20?= =?UTF-8?q?=EC=98=A4=ED=9B=84=20=EC=8B=9C=EA=B0=84=EB=8C=80=20=EC=84=A0?= =?UTF-8?q?=ED=83=9D=20=EB=B6=88=EA=B0=80=ED=95=98=EB=8F=84=EB=A1=9D=20ale?= =?UTF-8?q?rt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/SelectSchedule.tsx | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/src/pages/selectSchedule/components/SelectSchedule.tsx b/src/pages/selectSchedule/components/SelectSchedule.tsx index 4c90f1f9..75a1f96c 100644 --- a/src/pages/selectSchedule/components/SelectSchedule.tsx +++ b/src/pages/selectSchedule/components/SelectSchedule.tsx @@ -18,6 +18,11 @@ interface PropTypes { } function SelectSchedule({ scheduleList, availableDates, preferTimes, setScheduleList, deleteData }: PropTypes) { + + // 현재 선택된 가능시간이 아침/저녁 시간대인 경우를 확인하는 함수 + const isMorningDinner = +preferTimes.length === 2 && preferTimes.every((time) => time.startTime !== '12:00'); + const handleDate = (id: number, date: string) => { const updateDate: ScheduleStates[] = scheduleList?.map((schedule) => { @@ -34,18 +39,25 @@ function SelectSchedule({ scheduleList, availableDates, preferTimes, setSchedule const updateStartTime: ScheduleStates[] = scheduleList?.map((schedule) => { if (schedule?.id === id) { - if(schedule.endTime==="" ){ return { ...schedule, startTime }; } else if (compareTime(startTime,schedule.endTime)){ + + if (isMorningDinner){ + //오전,저녁 시간대이므로, 오후 시간대를 선택했는지 아닌지를 판별해야함 + //시작 시간이 11:30 이하이면서 종료 시간이 18:00이후인 경우 + if (compareTime(startTime, "11:30") && compareTime("18:00", schedule.endTime)) { + alert("12:00 부터 18:00는 선택지에 포함될 수 없습니다."); + return schedule; + } + } + return { ...schedule, startTime }; } - //isMorningDinner가 true라면 isContainingAfternoon실행 else{ alert("종료 시간은 시작 시간 이후로 설정해주세요!"); - } - + } return schedule; } @@ -63,6 +75,16 @@ function SelectSchedule({ scheduleList, availableDates, preferTimes, setSchedule return { ...schedule, endTime }; } else if (compareTime(schedule.startTime,endTime)){ + + if (isMorningDinner){ + //오전,저녁 시간대이므로, 오후 시간대를 선택했는지 아닌지를 판별해야함 + //시작 시간이 11:30 이하이면서 종료 시간이 18:00이후인 경우 + if (compareTime(schedule.startTime, "11:30") && compareTime("18:00", endTime)) { + alert("오후 12시부터 18시는 선택지에 포함될 수 없습니다."); + return schedule; + } + } + return { ...schedule, endTime }; } else {