mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-15 01:35:17 +01:00
31 lines
688 B
JavaScript
31 lines
688 B
JavaScript
import React from 'react';
|
|
import classNames from 'classnames';
|
|
import { getDateRange } from 'lib/date';
|
|
import styles from './QuickButtons.module.css';
|
|
|
|
const options = {
|
|
'24hour': '24h',
|
|
'7day': '7d',
|
|
'30day': '30d',
|
|
};
|
|
|
|
export default function QuickButtons({ value, onChange }) {
|
|
function handleClick(value) {
|
|
onChange(getDateRange(value));
|
|
}
|
|
|
|
return (
|
|
<div className={styles.buttons}>
|
|
{Object.keys(options).map(key => (
|
|
<div
|
|
key={key}
|
|
className={classNames(styles.button, { [styles.active]: value === key })}
|
|
onClick={() => handleClick(key)}
|
|
>
|
|
{options[key]}
|
|
</div>
|
|
))}
|
|
</div>
|
|
);
|
|
}
|