mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-27 11:28:22 +03:00
26 lines
859 B
TypeScript
26 lines
859 B
TypeScript
import type { FC } from 'react';
|
|
import { DropdownItem } from 'reactstrap';
|
|
import type { DateInterval } from './helpers/dateIntervals';
|
|
import { DATE_INTERVALS, rangeOrIntervalToString } from './helpers/dateIntervals';
|
|
|
|
export interface DateIntervalDropdownProps {
|
|
active?: DateInterval;
|
|
allText: string;
|
|
onChange: (interval: DateInterval) => void;
|
|
}
|
|
|
|
export const DateIntervalDropdownItems: FC<DateIntervalDropdownProps> = ({ active, allText, onChange }) => (
|
|
<>
|
|
<DropdownItem active={active === 'all'} onClick={() => onChange('all')}>
|
|
{allText}
|
|
</DropdownItem>
|
|
<DropdownItem divider />
|
|
{DATE_INTERVALS.map(
|
|
(interval) => (
|
|
<DropdownItem key={interval} active={active === interval} onClick={() => onChange(interval)}>
|
|
{rangeOrIntervalToString(interval)}
|
|
</DropdownItem>
|
|
),
|
|
)}
|
|
</>
|
|
);
|