Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

🐛 Allow changing the time zone on polls without votes (#2436)

Charles Rossia0f4713d1101
diff --git a/apps/web/public/locales/en/app.json b/apps/web/public/locales/en/app.json
index daede3183..859a5f22b 100644
--- a/apps/web/public/locales/en/app.json
+++ b/apps/web/public/locales/en/app.json
@@ -64,6 +64,7 @@
"authErrorsUserBanned": "This account has been banned. Please contact support if you believe this is an error.",
"authErrorsUserNotFound": "No account found with this email address. Please check the email or register for a new account.",
"autoTimeZone": "Automatic Time Zone Conversion",
+ "autoTimeZoneDisabledHelp": "The time zone can't be changed after votes have been cast.",
"autoTimeZoneHelp": "Enable this setting to automatically adjust event times to each participant's local time zone.",
"back": "Back",
"banned": "Banned",
diff --git a/apps/web/src/app/[locale]/(optional-space)/poll/[urlId]/edit-options/page.tsx b/apps/web/src/app/[locale]/(optional-space)/poll/[urlId]/edit-options/page.tsx
index ce0a6a773..8c977eb0c 100644
--- a/apps/web/src/app/[locale]/(optional-space)/poll/[urlId]/edit-options/page.tsx
+++ b/apps/web/src/app/[locale]/(optional-space)/poll/[urlId]/edit-options/page.tsx
@@ -38,6 +38,9 @@ const convertOptionToString = (
const Page = () => {
const { poll } = usePoll();
const { participants } = useParticipants();
+ const hasVotes = participants.some(
+ (participant) => participant.votes.length > 0,
+ );
const { mutate: updatePollMutation, isPending: isUpdating } =
useUpdatePollMutation();
const { t } = useTranslation();
@@ -150,7 +153,7 @@ const Page = () => {
}
})}
>
- <PollOptionsForm disableTimeZoneChange={true}>
+ <PollOptionsForm disableTimeZoneChange={hasVotes}>
<CardFooter className="justify-between">
<Link href={pollLink} className={buttonVariants()}>
<Trans i18nKey="cancel" />
diff --git a/apps/web/src/features/poll/components/forms/poll-options-form/poll-options-form.tsx b/apps/web/src/features/poll/components/forms/poll-options-form/poll-options-form.tsx
index 8410b8579..aa23ed7bd 100644
--- a/apps/web/src/features/poll/components/forms/poll-options-form/poll-options-form.tsx
+++ b/apps/web/src/features/poll/components/forms/poll-options-form/poll-options-form.tsx
@@ -221,7 +221,12 @@ const PollOptionsForm = ({
}
}}
/>
- <Label htmlFor="timeZone">
+ <Label
+ htmlFor="timeZone"
+ className={
+ disableTimeZoneChange ? "text-muted-foreground" : undefined
+ }
+ >
<Trans
i18nKey="autoTimeZone"
defaults="Automatic Time Zone Conversion"
@@ -232,10 +237,17 @@ const PollOptionsForm = ({
<InfoIcon className="size-4 text-muted-foreground" />
</TooltipTrigger>
<TooltipContent className="w-72">
- <Trans
- i18nKey="autoTimeZoneHelp"
- defaults="Enable this setting to automatically adjust event times to each participant's local time zone."
- />
+ {disableTimeZoneChange ? (
+ <Trans
+ i18nKey="autoTimeZoneDisabledHelp"
+ defaults="The time zone can't be changed after votes have been cast."
+ />
+ ) : (
+ <Trans
+ i18nKey="autoTimeZoneHelp"
+ defaults="Enable this setting to automatically adjust event times to each participant's local time zone."
+ />
+ )}
</TooltipContent>
</Tooltip>
</div>