Files
twenty/packages/twenty-front/src/modules/settings/experience/components/DateTimeSettingsDateFormatSelect.tsx
T
Naifer ad69ed9aba feat: allow users to start the calendar week on Monday (#13295)
resolve twentyhq/core-team-issues#1255
- Introduced a new field isWeekStartMonday in the workspaceMember table.

- Added a function updateCalendarStartDay to update the
isWeekStartMonday value when the user toggles the corresponding field in
the settings.

The logic works for me, but I couldn’t find a way to create the column
locally in the database for the workspaceMember tables. Please let me
know if this approach looks good and how to properly create dynamic
columns that are not directly handled via migration.


https://github.com/user-attachments/assets/4eebada5-6a96-4a88-8e96-98f1501859e3

---------

Co-authored-by: Félix Malfait <felix.malfait@gmail.com>
Co-authored-by: Félix Malfait <felix@twenty.com>
2025-07-30 12:46:05 +02:00

74 lines
1.8 KiB
TypeScript

import { formatInTimeZone } from 'date-fns-tz';
import { DateFormat } from '@/localization/constants/DateFormat';
import { detectDateFormat } from '@/localization/utils/detectDateFormat';
import { detectTimeZone } from '@/localization/utils/detectTimeZone';
import { Select } from '@/ui/input/components/Select';
import { t } from '@lingui/core/macro';
type DateTimeSettingsDateFormatSelectProps = {
value: DateFormat;
onChange: (nextValue: DateFormat) => void;
timeZone: string;
};
export const DateTimeSettingsDateFormatSelect = ({
onChange,
timeZone,
value,
}: DateTimeSettingsDateFormatSelectProps) => {
const systemTimeZone = detectTimeZone();
const usedTimeZone = timeZone === 'system' ? systemTimeZone : timeZone;
const systemDateFormat = DateFormat[detectDateFormat()];
const systemDateFormatLabel = formatInTimeZone(
Date.now(),
usedTimeZone,
systemDateFormat,
);
return (
<Select
dropdownId="datetime-settings-date-format"
dropdownWidth={218}
label={t`Date format`}
fullWidth
dropdownWidthAuto
value={value}
options={[
{
label: t`System settings - ${systemDateFormatLabel}`,
value: DateFormat.SYSTEM,
},
{
label: `${formatInTimeZone(
Date.now(),
usedTimeZone,
DateFormat.MONTH_FIRST,
)}`,
value: DateFormat.MONTH_FIRST,
},
{
label: `${formatInTimeZone(
Date.now(),
usedTimeZone,
DateFormat.DAY_FIRST,
)}`,
value: DateFormat.DAY_FIRST,
},
{
label: `${formatInTimeZone(
Date.now(),
usedTimeZone,
DateFormat.YEAR_FIRST,
)}`,
value: DateFormat.YEAR_FIRST,
},
]}
onChange={onChange}
/>
);
};