From d7c406a930b8437be19790d032939173723a9bcb Mon Sep 17 00:00:00 2001 From: Sergey Elpashev Date: Tue, 22 Apr 2025 12:39:34 +0300 Subject: [PATCH] feat: calendar on create --- src/components/ModalCalendar.tsx | 5 ++++- src/pages/profile_tasks.tsx | 17 ++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/components/ModalCalendar.tsx b/src/components/ModalCalendar.tsx index 16316f9..3f1e596 100644 --- a/src/components/ModalCalendar.tsx +++ b/src/components/ModalCalendar.tsx @@ -33,7 +33,10 @@ const ModalCalendar: FunctionComponent = ({ isOpen, setIsOpe { + onClose!(); + setShowTime(false); + }} className="md:h-[40rem] md:w-[30rem]" zIndex={60} > diff --git a/src/pages/profile_tasks.tsx b/src/pages/profile_tasks.tsx index e656585..4d81969 100644 --- a/src/pages/profile_tasks.tsx +++ b/src/pages/profile_tasks.tsx @@ -78,7 +78,7 @@ const ProfileTasks: FunctionComponent = () => { isOpen={openModalCalendar} setIsOpen={setOpenModalCalendar} onClose={() => { - setCalendarDate(null); + if (isEdit) setCalendarDate(null); }} onChange={(e) => isCreating && setCalendarDate(e.value)} value={calendarDate!} @@ -148,7 +148,13 @@ const ProfileTasks: FunctionComponent = () => { ref={taskDescriptionRef} /> - + { + setOpenModalCalendar(true); + setCalendarDate(calendarDate ?? new Date()); + }} + />
@@ -168,16 +174,21 @@ const ProfileTasks: FunctionComponent = () => { alert("Заполните все поля"); return; } + if (!calendarDate) { + alert("Заполните дату и время"); + return; + } const task: ITask = { id: tasks.length + 1, name: taskNameRef.current.value, description: taskDescriptionRef.current.value, - date: new Date(), + date: calendarDate, checked: false, tags: ["Математика", "Домашнее задание"], }; setTasks([...tasks, task]); setIsOpen(false); + setCalendarDate(null); } }} >