diff --git a/src/pages/lesson-list/components/lessons-form.tsx b/src/pages/lesson-list/components/lessons-form.tsx index b1ead84..d727860 100644 --- a/src/pages/lesson-list/components/lessons-form.tsx +++ b/src/pages/lesson-list/components/lessons-form.tsx @@ -45,6 +45,22 @@ export const LessonForm = ({ title, nameButton, }: LessonFormProps) => { + const getNearestTimeSlot = () => { + const now = new Date(); + const minutes = now.getMinutes(); + + if (minutes < 30) { + // Округляем до начала текущего часа + now.setMinutes(0, 0, 0); + } else { + // Округляем до начала следующего часа + now.setHours(now.getHours() + 1); + now.setMinutes(0, 0, 0); + } + + return dateToCalendarFormat(now.toISOString()); + }; + const { control, handleSubmit, @@ -56,7 +72,7 @@ export const LessonForm = ({ date: dateToCalendarFormat(lesson.date), }) || { name: '', - date: dateToCalendarFormat(), + date: getNearestTimeSlot(), }, })