2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-10-03 15:52:51 +00:00

Fix locale formatting for calendar display (#10418)

- Cannot accept underscore
This commit is contained in:
Oliver
2025-09-28 14:01:34 +10:00
committed by GitHub
parent 922827227c
commit bcc386aecf

View File

@@ -27,7 +27,7 @@ import {
IconDownload, IconDownload,
IconFilter IconFilter
} from '@tabler/icons-react'; } from '@tabler/icons-react';
import { useCallback, useEffect, useState } from 'react'; import { useCallback, useEffect, useMemo, useState } from 'react';
import { useShallow } from 'zustand/react/shallow'; import { useShallow } from 'zustand/react/shallow';
import type { CalendarState } from '../../hooks/UseCalendar'; import type { CalendarState } from '../../hooks/UseCalendar';
import { useLocalState } from '../../states/LocalState'; import { useLocalState } from '../../states/LocalState';
@@ -59,6 +59,9 @@ export default function Calendar({
const [locale] = useLocalState(useShallow((s) => [s.language])); const [locale] = useLocalState(useShallow((s) => [s.language]));
// Ensure underscore is replaced with dash
const calendarLocale = useMemo(() => locale.replace('_', '-'), [locale]);
const selectMonth = useCallback( const selectMonth = useCallback(
(date: DateValue) => { (date: DateValue) => {
state.selectMonth(date); state.selectMonth(date);
@@ -186,7 +189,7 @@ export default function Calendar({
plugins={[dayGridPlugin, interactionPlugin]} plugins={[dayGridPlugin, interactionPlugin]}
initialView='dayGridMonth' initialView='dayGridMonth'
locales={allLocales} locales={allLocales}
locale={locale} locale={calendarLocale}
headerToolbar={false} headerToolbar={false}
footerToolbar={false} footerToolbar={false}
{...calendarProps} {...calendarProps}