diff --git a/apps/web/test/lib/getTimezone.test.ts b/apps/web/test/lib/getTimezone.test.ts index 2f5f5d0d58..5055eed8fe 100644 --- a/apps/web/test/lib/getTimezone.test.ts +++ b/apps/web/test/lib/getTimezone.test.ts @@ -77,5 +77,5 @@ it("should render city name as option label if cityData is not empty", () => { }); it("should return timezone as option label if cityData is empty", () => { - expect(handleOptionLabel(option, [])).toMatchInlineSnapshot(`"America/Los_Angeles GMT -8:00"`); + expect(handleOptionLabel(option, [])).toMatchInlineSnapshot(`"America/Los Angeles GMT -8:00"`); }); diff --git a/packages/lib/timezone.ts b/packages/lib/timezone.ts index c6e064e398..f9159e00ed 100644 --- a/packages/lib/timezone.ts +++ b/packages/lib/timezone.ts @@ -35,5 +35,6 @@ export const addCitiesToDropdown = (cities: ICity[]) => { export const handleOptionLabel = (option: ITimezoneOption, cities: ICity[]) => { const timezoneValue = option.label.split(")")[0].replace("(", " ").replace("T", "T "); const cityName = option.label.split(") ")[1]; - return cities.length > 0 ? `${cityName}${timezoneValue}` : `${option.value}${timezoneValue}`; + const refactoredOption = option.value.replace(/_/g, " "); + return cities.length > 0 ? `${cityName}${timezoneValue}` : `${refactoredOption}${timezoneValue}`; }; diff --git a/packages/ui/components/form/timezone-select/TimezoneSelect.tsx b/packages/ui/components/form/timezone-select/TimezoneSelect.tsx index cbf20559a0..2f05968518 100644 --- a/packages/ui/components/form/timezone-select/TimezoneSelect.tsx +++ b/packages/ui/components/form/timezone-select/TimezoneSelect.tsx @@ -34,6 +34,13 @@ export function TimezoneSelect({ }); }, [components]); + // We use modifiedTimezones in place of the allTimezones object replacing any underscores in the curly braces + // with spaces and removing the America/Detroit timezone, adding the America/New_York timezone instead. + const modifiedTimezones = useMemo(() => { + const { "America/Detroit": _, ...rest } = allTimezones; + return { ...rest, "America/New_York": "New York" }; + }, []); + return (

{(option as ITimezoneOption).value}

} + formatOptionLabel={(option) => ( +

{(option as ITimezoneOption).value.replace(/_/g, " ")}

+ )} getOptionLabel={(option) => handleOptionLabel(option as ITimezoneOption, cities)} classNames={{ ...timezoneClassNames,