From a1af535eb7ba1ded25c230b2cdb4f89ff87152ed Mon Sep 17 00:00:00 2001 From: Luke Vella Date: Wed, 19 Jun 2024 12:14:30 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Improved=20time=20picker=20logic=20?= =?UTF-8?q?(#1166)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../month-calendar/time-picker.tsx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/apps/web/src/components/forms/poll-options-form/month-calendar/time-picker.tsx b/apps/web/src/components/forms/poll-options-form/month-calendar/time-picker.tsx index 27c8957aa..90aa89cd9 100644 --- a/apps/web/src/components/forms/poll-options-form/month-calendar/time-picker.tsx +++ b/apps/web/src/components/forms/poll-options-form/month-calendar/time-picker.tsx @@ -34,9 +34,19 @@ const TimePicker: React.FunctionComponent = ({ : dayjs(value).startOf("day"); const res: string[] = []; - while (cursor.isSame(value, "day")) { - res.push(cursor.toISOString()); - cursor = cursor.add(15, "minutes"); + + if (after) { + let cursor = dayjs(after).add(15, "minutes"); + while (cursor.diff(after, "hours") < 24) { + res.push(cursor.toISOString()); + cursor = cursor.add(15, "minutes"); + } + } else { + cursor = dayjs(value).startOf("day"); + while (cursor.isSame(value, "day")) { + res.push(cursor.toISOString()); + cursor = cursor.add(15, "minutes"); + } } return res; }, [after, open, value]);