* ESLint rule: const naming Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: KlingerMatheus <klinger.matheus@gitstart.dev> * Refactor according to review Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: KlingerMatheus <klinger.matheus@gitstart.dev> * refactor: Reverts changes on `twenty-server` Co-authored-by: KlingerMatheus <klinger.matheus@gitstart.dev> Co-authored-by: v1b3m <vibenjamin6@gmail.com> --------- Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com> Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: KlingerMatheus <klinger.matheus@gitstart.dev>
31 lines
1007 B
TypeScript
31 lines
1007 B
TypeScript
/* eslint-disable @typescript-eslint/naming-convention */
|
|
/* eslint-disable @nx/workspace-max-consts-per-file */
|
|
import { IANA_TIME_ZONES } from '@/settings/accounts/constants/IanaTimeZones';
|
|
import { formatTimeZoneLabel } from '@/settings/accounts/utils/formatTimeZoneLabel';
|
|
import { SelectOption } from '@/ui/input/components/Select';
|
|
|
|
export const AVAILABLE_TIME_ZONE_OPTIONS_BY_LABEL = IANA_TIME_ZONES.reduce<
|
|
Record<string, SelectOption<string>>
|
|
>((result, ianaTimeZone) => {
|
|
const timeZoneLabel = formatTimeZoneLabel(ianaTimeZone);
|
|
|
|
// Remove the '(GMT±00:00) ' prefix from the label.
|
|
const timeZoneName = timeZoneLabel.slice(11);
|
|
|
|
// Skip time zones with GMT, UTC, or UCT in their name,
|
|
// and duplicates.
|
|
if (
|
|
timeZoneName.includes('GMT') ||
|
|
timeZoneName.includes('UTC') ||
|
|
timeZoneName.includes('UCT') ||
|
|
timeZoneLabel in result
|
|
) {
|
|
return result;
|
|
}
|
|
|
|
return {
|
|
...result,
|
|
[timeZoneLabel]: { label: timeZoneLabel, value: ianaTimeZone },
|
|
};
|
|
}, {});
|