import { createListCollection } from '@chakra-ui/react'; import React from 'react'; import type { StatsInterval, StatsIntervalIds } from 'types/client/stats'; import { Select } from 'toolkit/chakra/select'; import { Skeleton } from 'toolkit/chakra/skeleton'; import type { TagProps } from 'toolkit/chakra/tag'; import TagGroupSelect from 'ui/shared/tagGroupSelect/TagGroupSelect'; import { STATS_INTERVALS } from 'ui/stats/constants'; const intervalCollection = createListCollection({ items: Object.keys(STATS_INTERVALS).map((id: string) => ({ value: id, label: STATS_INTERVALS[id as StatsIntervalIds].title, })), }); const intervalListShort = Object.keys(STATS_INTERVALS).map((id: string) => ({ id: id, title: STATS_INTERVALS[id as StatsIntervalIds].shortTitle, })) as Array; type Props = { interval: StatsIntervalIds; onIntervalChange: (newInterval: StatsIntervalIds) => void; isLoading?: boolean; selectTagSize?: TagProps['size']; }; const ChartIntervalSelect = ({ interval, onIntervalChange, isLoading, selectTagSize }: Props) => { const handleItemSelect = React.useCallback(({ value }: { value: Array }) => { onIntervalChange(value[0] as StatsIntervalIds); }, [ onIntervalChange ]); return ( <> items={ intervalListShort } onChange={ onIntervalChange } value={ interval } tagSize={ selectTagSize }/>