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
@ -1,4 +1,4 @@
|
||||
import { availableTimeZoneOptions } from '@/settings/accounts/constants/timeZoneSelectOptions';
|
||||
import { AVAILABLE_TIMEZONE_OPTIONS } from '@/settings/accounts/constants/AvailableTimezoneOptions';
|
||||
import { detectTimeZone } from '@/settings/accounts/utils/detectTimeZone';
|
||||
import { findAvailableTimeZoneOption } from '@/settings/accounts/utils/findAvailableTimeZoneOption';
|
||||
import { Select } from '@/ui/input/components/Select';
|
||||
@ -18,7 +18,7 @@ export const SettingsAccountsCalendarTimeZoneSelect = ({
|
||||
label="Time zone"
|
||||
fullWidth
|
||||
value={findAvailableTimeZoneOption(value)?.value}
|
||||
options={availableTimeZoneOptions}
|
||||
options={AVAILABLE_TIMEZONE_OPTIONS}
|
||||
onChange={onChange}
|
||||
withSearchInput
|
||||
/>
|
||||
|
||||
@ -3,7 +3,10 @@ import styled from '@emotion/styled';
|
||||
import { ColorPickerButton } from '@/ui/input/button/components/ColorPickerButton';
|
||||
import { Card } from '@/ui/layout/card/components/Card';
|
||||
import { CardContent } from '@/ui/layout/card/components/CardContent';
|
||||
import { mainColorNames, ThemeColor } from '@/ui/theme/constants/colors';
|
||||
import {
|
||||
MAIN_COLOR_NAMES,
|
||||
ThemeColor,
|
||||
} from '@/ui/theme/constants/MainColorNames';
|
||||
|
||||
type SettingsAccountsColorSettingCardProps = {
|
||||
onChange: (nextValue: ThemeColor) => void;
|
||||
@ -22,7 +25,7 @@ export const SettingsAccountsColorSettingCard = ({
|
||||
}: SettingsAccountsColorSettingCardProps) => (
|
||||
<Card>
|
||||
<StyledCardContent>
|
||||
{mainColorNames.map((colorName) => (
|
||||
{MAIN_COLOR_NAMES.map((colorName) => (
|
||||
<ColorPickerButton
|
||||
colorName={colorName}
|
||||
isSelected={value === colorName}
|
||||
|
||||
@ -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',
|
||||
@ -1,4 +1,4 @@
|
||||
import { availableTimeZoneOptionsByLabel } from '@/settings/accounts/constants/timeZoneSelectOptions';
|
||||
import { AVAILABLE_TIME_ZONE_OPTIONS_BY_LABEL } from '@/settings/accounts/constants/AvailableTimezoneOptionsByLabel';
|
||||
import { formatTimeZoneLabel } from '@/settings/accounts/utils/formatTimeZoneLabel';
|
||||
|
||||
/**
|
||||
@ -7,4 +7,4 @@ import { formatTimeZoneLabel } from '@/settings/accounts/utils/formatTimeZoneLab
|
||||
* @returns the matching available IANA time zone select option or undefined
|
||||
*/
|
||||
export const findAvailableTimeZoneOption = (value: string) =>
|
||||
availableTimeZoneOptionsByLabel[formatTimeZoneLabel(value)];
|
||||
AVAILABLE_TIME_ZONE_OPTIONS_BY_LABEL[formatTimeZoneLabel(value)];
|
||||
|
||||
Reference in New Issue
Block a user