diff --git a/apps/web/src/components/forms/poll-options-form/month-calendar/month-calendar.tsx b/apps/web/src/components/forms/poll-options-form/month-calendar/month-calendar.tsx index 1b1ea6add..52891b448 100644 --- a/apps/web/src/components/forms/poll-options-form/month-calendar/month-calendar.tsx +++ b/apps/web/src/components/forms/poll-options-form/month-calendar/month-calendar.tsx @@ -22,11 +22,14 @@ import { } from "lucide-react"; import { useTranslation } from "next-i18next"; import * as React from "react"; +import { useFormContext } from "react-hook-form"; +import { NewEventData } from "@/components/forms"; import { Trans } from "@/components/trans"; import { expectTimeOption, + getBrowserTimeZone, getDateProps, removeAllOptionsForDay, } from "../../../../utils/date-time-utils"; @@ -49,6 +52,8 @@ const MonthCalendar: React.FunctionComponent = ({ const { t } = useTranslation(); const isTimedEvent = options.some((option) => option.type === "timeSlot"); + const form = useFormContext(); + const optionsByDay = React.useMemo(() => { const res: Record< string, @@ -221,6 +226,7 @@ const MonthCalendar: React.FunctionComponent = ({ checked={isTimedEvent} onCheckedChange={(checked) => { if (checked) { + form.setValue("timeZone", getBrowserTimeZone()); // convert dates to time slots onChange( options.map((option) => { @@ -242,6 +248,7 @@ const MonthCalendar: React.FunctionComponent = ({ }), ); } else { + form.setValue("timeZone", ""); onChange( datepicker.selection.map((date) => ({ type: "date", diff --git a/apps/web/src/components/forms/poll-options-form/poll-options-form.tsx b/apps/web/src/components/forms/poll-options-form/poll-options-form.tsx index a5242bd8d..6f0130e68 100644 --- a/apps/web/src/components/forms/poll-options-form/poll-options-form.tsx +++ b/apps/web/src/components/forms/poll-options-form/poll-options-form.tsx @@ -168,21 +168,6 @@ const PollOptionsForm = ({ }} onChange={(options) => { field.onChange(options); - if ( - length === 0 || - options.every((option) => option.type === "date") - ) { - // unset the timeZone if we only have date option - setValue("timeZone", ""); - } - if ( - options.length > 0 && - !formState.touchedFields.timeZone && - options.every((option) => option.type === "timeSlot") - ) { - // set timeZone if we are adding time ranges and we haven't touched the timeZone field - setValue("timeZone", getBrowserTimeZone()); - } }} duration={watchDuration} onChangeDuration={(duration) => {