From bfd3b98dca14cd8c41e5802d4ba0ac05286c39e5 Mon Sep 17 00:00:00 2001 From: Primakov Alexandr Alexandrovich Date: Wed, 12 Mar 2025 17:30:01 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B1=D0=BB=D0=B8=D0=B6=D0=B0=D0=B9=D1=88?= =?UTF-8?q?=D0=B8=D0=B9=20=D0=BF=D0=BE=D0=BB=D1=83=D1=87=D0=B0=D1=81=D0=BE?= =?UTF-8?q?=D0=B2=D0=BE=D0=B9=20=D1=81=D0=BB=D0=BE=D1=82=20=D0=BF=D1=80?= =?UTF-8?q?=D0=B8=20=D1=81=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8=D0=B8=20?= =?UTF-8?q?=D0=BB=D0=B5=D0=BA=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lesson-list/components/lessons-form.tsx | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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(), }, })