From 0c288b91641704195c100984468006f5d202c932 Mon Sep 17 00:00:00 2001 From: kyu <2066apple@naver.com> Date: Wed, 13 Sep 2023 22:13:32 +0900 Subject: [PATCH] =?UTF-8?q?[=20fix=20]=20=EC=8B=9C=EC=9E=91=EC=9D=BC,=20?= =?UTF-8?q?=EB=A7=88=EA=B0=90=EC=9D=BC=20=EB=8F=99=EC=9D=BC=ED=95=A0=20?= =?UTF-8?q?=EB=95=8C=20=EB=93=B1=EB=A1=9D=20=EB=AA=BB=ED=95=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/nottodo/NotTodoCreatePage.tsx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/pages/nottodo/NotTodoCreatePage.tsx b/src/pages/nottodo/NotTodoCreatePage.tsx index 808dab0..74356b9 100644 --- a/src/pages/nottodo/NotTodoCreatePage.tsx +++ b/src/pages/nottodo/NotTodoCreatePage.tsx @@ -12,11 +12,12 @@ import { currentNottodoState } from '@/recoil/nottodo/atom'; export default function NotTodoCreatePage() { const router = useNavigate(); const params = useParams(); + const today = new Date(); const endDateRef = useRef(null); const [title, setTitle] = useState(''); const [goal, setGoal] = useState(''); - const [startDate, setStartDate] = useState(new Date()); - const [endDate, setEndDate] = useState(new Date()); + const [startDate, setStartDate] = useState(new Date(today.getFullYear(), today.getMonth(), today.getDate())); + const [endDate, setEndDate] = useState(new Date(today.getFullYear(), today.getMonth(), today.getDate())); const [inputStartDate, setInputStartDate] = useState(''); const [inputEndDate, setInputEndDate] = useState(''); const [message1, setMessage1] = useState(''); @@ -101,14 +102,20 @@ export default function NotTodoCreatePage() { // 시작일, 종료일 계산 const startTime = startDate.getTime(); const endTime = endDate.getTime(); + if (startTime > endTime) { setDateHelpText('시작일이 종료일보다 늦을 수 없습니다'); return false; } - // 100일 초과 여부 검사 const diff = endTime - startTime; const dayTime = 1000 * 60 * 60 * 24; + // 1일 미만인지 검사 + if (diff < dayTime) { + setDateHelpText('도전일은 1일 이상이 되어야 합니다.'); + return false; + } + // 100일 초과 여부 검사 if (diff > dayTime * 100) { setDateHelpText('100일 이상은 등록하실 수 없습니다'); return false; @@ -222,7 +229,7 @@ export default function NotTodoCreatePage() { 필수
언제까지 도전하시나요?
-
총 {diffDay(startDate, endDate) + 1}일
+
총 {diffDay(startDate, endDate)}일