2021-03-06 18:54:43 +03:00
|
|
|
import { DropdownItem } from 'reactstrap';
|
|
|
|
import { FC } from 'react';
|
|
|
|
import { DATE_INTERVALS, DateInterval, rangeOrIntervalToString } from './types';
|
|
|
|
|
|
|
|
export interface DateIntervalDropdownProps {
|
|
|
|
active?: DateInterval;
|
2021-10-03 22:07:07 +03:00
|
|
|
allText: string;
|
2021-03-06 18:54:43 +03:00
|
|
|
onChange: (interval: DateInterval) => void;
|
|
|
|
}
|
|
|
|
|
2021-10-03 22:07:07 +03:00
|
|
|
export const DateIntervalDropdownItems: FC<DateIntervalDropdownProps> = ({ active, allText, onChange }) => (
|
2021-03-06 18:54:43 +03:00
|
|
|
<>
|
2021-10-03 22:07:07 +03:00
|
|
|
<DropdownItem active={active === 'all'} onClick={() => onChange('all')}>
|
|
|
|
{allText}
|
|
|
|
</DropdownItem>
|
|
|
|
<DropdownItem divider />
|
2021-03-06 18:54:43 +03:00
|
|
|
{DATE_INTERVALS.map(
|
|
|
|
(interval) => (
|
|
|
|
<DropdownItem key={interval} active={active === interval} onClick={() => onChange(interval)}>
|
|
|
|
{rangeOrIntervalToString(interval)}
|
|
|
|
</DropdownItem>
|
|
|
|
),
|
|
|
|
)}
|
|
|
|
</>
|
|
|
|
);
|