Files
umami/src/app/(main)/settings/preferences/DateRangeSetting.tsx
T
Mike CaoandClaude Opus 4.6 50edb71687 Simplify i18n: remove old react-intl artifacts, rename formatMessage to t, replace FormattedMessage with t.rich().
- Rewrite messages.ts to plain string key maps (remove MessageDescriptor)
- Rewrite useMessages hook to expose t from useTranslations() directly
- Rename formatMessage → t across 193 consumer files
- Replace custom FormattedMessage component with next-intl t.rich()
- Update 52 language files to use rich text tags (<b>, <a>)
- Remove all direct imports from @/components/messages in favor of useMessages()

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 11:19:04 -08:00

34 lines
994 B
TypeScript

import { Button, Row } from '@umami/react-zen';
import { useState } from 'react';
import { useMessages } from '@/components/hooks';
import { DateFilter } from '@/components/input/DateFilter';
import { DATE_RANGE_CONFIG, DEFAULT_DATE_RANGE_VALUE } from '@/lib/constants';
import { getItem, setItem } from '@/lib/storage';
export function DateRangeSetting() {
const { t, labels } = useMessages();
const [date, setDate] = useState(getItem(DATE_RANGE_CONFIG) || DEFAULT_DATE_RANGE_VALUE);
const handleChange = (value: string) => {
setItem(DATE_RANGE_CONFIG, value);
setDate(value);
};
const handleReset = () => {
setItem(DATE_RANGE_CONFIG, DEFAULT_DATE_RANGE_VALUE);
setDate(DEFAULT_DATE_RANGE_VALUE);
};
return (
<Row gap="3">
<DateFilter
value={date}
onChange={handleChange}
placement="bottom start"
style={{ minWidth: '250px' }}
/>
<Button onPress={handleReset}>{t(labels.reset)}</Button>
</Row>
);
}