mirror of
https://github.com/umami-software/umami.git
synced 2026-02-15 01:55:36 +01:00
25 lines
900 B
TypeScript
25 lines
900 B
TypeScript
import { useState } from 'react';
|
|
import { DateFilter } from '@/components/input/DateFilter';
|
|
import { Button, Row } from '@umami/react-zen';
|
|
import { useMessages } from '@/components/hooks';
|
|
import { DATE_RANGE_CONFIG, DEFAULT_DATE_RANGE_VALUE } from '@/lib/constants';
|
|
import { setItem, getItem } from '@/lib/storage';
|
|
|
|
export function DateRangeSetting() {
|
|
const { formatMessage, 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);
|
|
|
|
return (
|
|
<Row gap="3">
|
|
<DateFilter value={date} onChange={handleChange} placement="bottom start" />
|
|
<Button onPress={handleReset}>{formatMessage(labels.reset)}</Button>
|
|
</Row>
|
|
);
|
|
}
|