mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-15 01:35:17 +01:00
25 lines
571 B
JavaScript
25 lines
571 B
JavaScript
import React, { useState } from 'react';
|
|
import { getDateRange } from 'lib/date';
|
|
|
|
const filterOptions = ['24h', '7d', '30d'];
|
|
|
|
export default function DateFilter({ onChange }) {
|
|
const [selected, setSelected] = useState('7d');
|
|
|
|
function handleChange(e) {
|
|
const value = e.target.value;
|
|
setSelected(value);
|
|
onChange(getDateRange(value));
|
|
}
|
|
|
|
return (
|
|
<select value={selected} onChange={handleChange}>
|
|
{filterOptions.map(option => (
|
|
<option key={option} name={option}>
|
|
{option}
|
|
</option>
|
|
))}
|
|
</select>
|
|
);
|
|
}
|