umami/components/common/DateFilter.js

25 lines
738 B
JavaScript
Raw Normal View History

2020-07-31 05:11:43 +02:00
import React from 'react';
import { getDateRange } from 'lib/date';
2020-07-31 05:11:43 +02:00
import DropDown from './DropDown';
2020-07-31 05:11:43 +02:00
const filterOptions = [
{ label: 'Last 24 hours', value: '24hour' },
{ label: 'Last 7 days', value: '7day' },
{ label: 'Last 30 days', value: '30day' },
{ label: 'Last 90 days', value: '90day' },
2020-07-31 07:40:16 +02:00
{ label: 'Today', value: '1day' },
{ label: 'This week', value: '1week' },
{ label: 'This month', value: '1month' },
2020-07-31 08:08:33 +02:00
{ label: 'This year', value: '1year' },
2020-07-31 05:11:43 +02:00
];
2020-08-02 06:20:52 +02:00
export default function DateFilter({ value, onChange, className }) {
2020-07-31 05:11:43 +02:00
function handleChange(value) {
onChange(getDateRange(value));
}
2020-08-02 06:20:52 +02:00
return (
<DropDown className={className} value={value} options={filterOptions} onChange={handleChange} />
);
}