import React from 'react' import Button from '../Button/Button' import Icon from '../Icons/Icon' import Popover from '../Popover/Popover' import { SideDrawer } from '../SideDrawer/SideDrawer' import { useIsMobileView } from '../../hooks/useIsMobileView/useIsMobileView' import Timeframe, { type AlertPropsWithDates } from './Timeframe' import type { TimeframeProps } from './TimeframesType' import styles from './_timeframe-filter.module.scss' export type TimeframeFilterProps = { /** Function to be called when an option is clicked */ callout: () => void /** Selected time frame */ timeframe: TimeframeProps /** historical time frame options in a array */ historicalTimeframes?: TimeframeProps[] /** Show/hide the Current timeframe sections based on this boolean value */ currentTimeframe?: boolean /** Show/hide the Quarterly/Yearly timeframe sections based on this boolean value */ quarterlyTimeframe?: boolean alertProps?: AlertPropsWithDates /** Current path from the router */ currentPath?: string /** Optional prop to add a test id to the TimeframeFilter for QA testing */ qaTestId?: string } /** @deprecated */ const TimeframeFilter = ({ alertProps, callout, historicalTimeframes, timeframe, currentTimeframe, quarterlyTimeframe, currentPath, qaTestId = 'timeframe-filter', }: TimeframeFilterProps): React.JSX.Element => { const isMobileView = useIsMobileView() const [isDrawerOpen, setIsDrawerOpen] = React.useState(false) const PopoverOrDrawerContent = () => ( ) return isMobileView ? ( <> setIsDrawerOpen(false)} headerContent='' qaTestId={`${qaTestId}-drawer`} > {PopoverOrDrawerContent()} ) : ( {({ visible, setVisible }) => ( )} ) } export default TimeframeFilter