import type { FC } from 'react'; import { DropdownItem } from 'reactstrap'; import { DropdownBtn } from '../../../shlink-frontend-kit/src'; import type { Settings } from '../../../shlink-web-component/src'; import { rangeOrIntervalToString } from '../../../shlink-web-component/src/utils/dates/helpers/dateIntervals'; import type { Defined } from '../types'; type DateInterval = Defined['defaultInterval']; export interface DateIntervalSelectorProps { active?: DateInterval; allText: string; onChange: (interval: DateInterval) => void; } const INTERVAL_TO_STRING_MAP: Record, string> = { today: 'Today', yesterday: 'Yesterday', last7Days: 'Last 7 days', last30Days: 'Last 30 days', last90Days: 'Last 90 days', last180Days: 'Last 180 days', last365Days: 'Last 365 days', }; export const DateIntervalSelector: FC = ({ onChange, active, allText }) => ( onChange('all')}> {allText} {Object.entries(INTERVAL_TO_STRING_MAP).map( ([interval, name]) => ( onChange(interval as DateInterval)}> {name} ), )} );