feat(settings): every date picker starts its week on the day you pick

Settings > General > Language & region gets "Week starts on" (Monday,
Sunday or Saturday), and Admin > User Defaults a default for everyone who
has not picked one. Monday stays the built-in value, so nothing changes
for anyone who leaves it alone.

Both calendar implementations follow it: CustomDatePicker, used by trip
dates, bookings, costs, to-dos and the admin school holidays on desktop
and phone, and the journey date picker, whose weekday headers were
hardcoded English and now speak the app language. The grid math and the
header row live in one helper (utils/calendarWeek.ts). The day names on
the options come from Intl, so only the label and a hint needed
translating. Vacay keeps its own per-plan week start.

The value is validated like the other regional settings: VALID_VALUES for
admin defaults, the display-settings MCP tool, and the managed key list.

Addresses discussion #2029.
This commit is contained in:
Maurice
2026-09-24 21:56:10 +02:00
parent 196dc12762
commit 7ce31756a3
84 changed files with 511 additions and 106 deletions
@@ -1,4 +1,4 @@
// FE-ADMIN-DUS-001 to FE-ADMIN-DUS-027
// FE-ADMIN-DUS-001 to FE-ADMIN-DUS-028
import { render, screen, waitFor, within, fireEvent } from '../../../tests/helpers/render';
import userEvent from '@testing-library/user-event';
import { http, HttpResponse } from 'msw';
@@ -453,3 +453,18 @@ describe('DefaultUserSettingsTab', () => {
expect(screen.queryByText('Shared CARTO key')).not.toBeInTheDocument();
});
});
describe('DefaultUserSettingsTab week start (#2029)', () => {
it('FE-ADMIN-DUS-028: the week-start default saves its own key and can be reset', async () => {
const user = userEvent.setup();
const { puts } = stubDefaults();
render(<DefaultUserSettingsTab />);
await screen.findByText('Default User Settings');
await user.click(screen.getByRole('button', { name: 'Sunday' }));
await waitFor(() => expect(resetLink('Week starts on')).toBeInTheDocument());
await user.click(resetLink('Week starts on'));
await waitFor(() => expect(puts).toEqual([{ week_start: 'sunday' }, { week_start: null }]));
});
});
@@ -7,7 +7,8 @@ import Section from '../Settings/Section'
import CustomSelect from '../shared/CustomSelect'
import { MapView } from '../Map/MapView'
import { SYMBOLS, currenciesWith } from '../Budget/BudgetPanel.constants'
import type { DistanceUnit, Place } from '../../types'
import type { DistanceUnit, Place, WeekStart } from '../../types'
import { weekStartOptions } from '../../utils/calendarWeek'
import { normalizeTileUrl, withTileApiKey } from '../../utils/tileUrl'
import {
MAPBOX_DEFAULT_STYLE,
@@ -40,6 +41,7 @@ type Defaults = RoutingDefaults & {
distance_unit?: DistanceUnit
dark_mode?: string | boolean
time_format?: string
week_start?: WeekStart
default_currency?: string
blur_booking_codes?: boolean
map_tile_url?: string
@@ -112,7 +114,7 @@ function OptionButton({
}
export default function DefaultUserSettingsTab(): React.ReactElement {
const { t } = useTranslation()
const { t, locale } = useTranslation()
const toast = useToast()
const [defaults, setDefaults] = useState<Defaults>({})
const [loaded, setLoaded] = useState(false)
@@ -302,6 +304,15 @@ export default function DefaultUserSettingsTab(): React.ReactElement {
))}
</OptionRow>
{/* Week start: the first column of every date picker (#2029) */}
<OptionRow label={<>{t('settings.weekStart')} <ResetButton field="week_start" /></>}>
{weekStartOptions(locale).map(opt => (
<OptionButton key={opt.value} active={defaults.week_start === opt.value} onClick={() => save({ week_start: opt.value })}>
{opt.label}
</OptionButton>
))}
</OptionRow>
{/* Default Currency */}
<div>
<label className="block text-sm font-medium mb-1.5 text-content-secondary">