TWNTY-3825 - ESLint rule: const naming (#4171)
* 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>
This commit is contained in:
committed by
GitHub
parent
a108d36040
commit
f543191552
@ -0,0 +1,18 @@
|
||||
/* eslint-disable @nx/workspace-max-consts-per-file */
|
||||
import { getTimezoneOffset } from 'date-fns-tz';
|
||||
|
||||
import { AVAILABLE_TIME_ZONE_OPTIONS_BY_LABEL } from '@/settings/accounts/constants/AvailableTimezoneOptionsByLabel';
|
||||
|
||||
export const AVAILABLE_TIMEZONE_OPTIONS = Object.values(
|
||||
AVAILABLE_TIME_ZONE_OPTIONS_BY_LABEL,
|
||||
).sort((optionA, optionB) => {
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
const difference =
|
||||
getTimezoneOffset(optionA.value) - getTimezoneOffset(optionB.value);
|
||||
|
||||
return difference === 0
|
||||
? // Sort alphabetically if the time zone offsets are the same.
|
||||
optionA.label.localeCompare(optionB.label)
|
||||
: // Sort by time zone offset if different.
|
||||
difference;
|
||||
});
|
||||
@ -1,10 +1,10 @@
|
||||
import { getTimezoneOffset } from 'date-fns-tz';
|
||||
|
||||
import { ianaTimeZones } from '@/settings/accounts/constants/ianaTimeZones';
|
||||
/* 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 availableTimeZoneOptionsByLabel = ianaTimeZones.reduce<
|
||||
export const AVAILABLE_TIME_ZONE_OPTIONS_BY_LABEL = IANA_TIME_ZONES.reduce<
|
||||
Record<string, SelectOption<string>>
|
||||
>((result, ianaTimeZone) => {
|
||||
const timeZoneLabel = formatTimeZoneLabel(ianaTimeZone);
|
||||
@ -28,16 +28,3 @@ export const availableTimeZoneOptionsByLabel = ianaTimeZones.reduce<
|
||||
[timeZoneLabel]: { label: timeZoneLabel, value: ianaTimeZone },
|
||||
};
|
||||
}, {});
|
||||
|
||||
export const availableTimeZoneOptions = Object.values(
|
||||
availableTimeZoneOptionsByLabel,
|
||||
).sort((optionA, optionB) => {
|
||||
const difference =
|
||||
getTimezoneOffset(optionA.value) - getTimezoneOffset(optionB.value);
|
||||
|
||||
return difference === 0
|
||||
? // Sort alphabetically if the time zone offsets are the same.
|
||||
optionA.label.localeCompare(optionB.label)
|
||||
: // Sort by time zone offset if different.
|
||||
difference;
|
||||
});
|
||||
@ -2,7 +2,7 @@
|
||||
* Standard IANA time zones.
|
||||
* @see https://www.iana.org/time-zones
|
||||
*/
|
||||
export const ianaTimeZones = [
|
||||
export const IANA_TIME_ZONES = [
|
||||
'Africa/Abidjan',
|
||||
'Africa/Accra',
|
||||
'Africa/Addis_Ababa',
|
||||
Reference in New Issue
Block a user