Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.
TypeScript i18nextnext-authnextjspostgresqlprismareact-emailt3-stacktailwindcsstrpcturborepotypescriptzod
🐛 Fix timezone behaviour in month calendar (#1043)
Luke Vellafc3c0c3e3552
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.tsxindex 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<DateTimePickerProps> = ({const { t } = useTranslation();const isTimedEvent = options.some((option) => option.type === "timeSlot");+ const form = useFormContext<NewEventData>();+const optionsByDay = React.useMemo(() => {const res: Record<string,@@ -221,6 +226,7 @@ const MonthCalendar: React.FunctionComponent<DateTimePickerProps> = ({checked={isTimedEvent}onCheckedChange={(checked) => {if (checked) {+ form.setValue("timeZone", getBrowserTimeZone());// convert dates to time slotsonChange(options.map<DateTimeOption>((option) => {@@ -242,6 +248,7 @@ const MonthCalendar: React.FunctionComponent<DateTimePickerProps> = ({}),);} 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.tsxindex 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) => {