mirror of
https://github.com/umami-software/umami.git
synced 2026-02-06 21:57:16 +01:00
Website components. Update chart component.
This commit is contained in:
parent
d81ee3932d
commit
bdcdcd9d13
9 changed files with 165 additions and 43 deletions
22
components/DateFilter.js
Normal file
22
components/DateFilter.js
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
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 name={option}>{option}</option>
|
||||
))}
|
||||
</select>
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue