import * as React from 'react'
import { useRef, useState } from 'react'
import Alert from '../../Alerts/Alert'
import Button from '../../Button/Button'
import Icon from '../../Icons/Icon'
import Popover from '../../Popover/Popover'
import { SideDrawer } from '../../SideDrawer/SideDrawer'
import Tooltip from '../../Tooltip/Tooltip'
import { useMediaQuery } from '../../../hooks/responsiveHooks'
import type {
ComparisonDatePickerProps,
SelectionState,
SelectionStateBase,
SelectionStateDispatchActions,
} from './ComparisonDatePicker'
import { ComparisonDatePicker } from './ComparisonDatePicker'
import styles from './comparison_date_picker_popup.module.scss'
import type { SideDrawerBase } from '../../SideDrawer/SideDrawer'
import { type AlertPropsWithDates } from '../Timeframe'
import { c } from '../../../translations/LibraryTranslationService'
type ComparisonDatePickerPopupProps = ComparisonDatePickerProps & {
/** method will receive two values, `selectionState` and `selectionStateDispatch`; (selectionState, selectionStateDispatch) => void */
onApply: OnApply
/** indicates if the custom date range has been selected with valid dates */
selectedCustomDateRange?: boolean
/** Optionally add a layer position to the drawer to allow layered drawers. The number here will
* be the position in the stack of SideDrawer layers if there are multiple SideDrawers that
* need to be displayed. NOTE: Omit this prop if there is only 1 SideDrawer layer. This is
* important for styling. */
sideDrawerLayerPosition?: number
/** Passes any optional SideDrawer props to the ComparisonDatePicker SideDrawer */
cdpSideDrawerProps?: Omit<
SideDrawerBase,
'children' | 'isOpen' | 'closeCallout'
>
alertProps?: AlertPropsWithDates
/** Label for the first range */
firstRangeLabel?: string
/** Label for the second range */
secondRangeLabel?: string
}
const CheckIcon = () => (
)
const DateRangeDisplay = (
props: ComparisonDatePickerPopupProps,
): React.JSX.Element => {
const firstRange_startDate =
props?.initial_firstRange_startDate?.format('MM-DD-YY') ?? null
const firstRange_endDate =
props?.initial_firstRange_endDate?.format('MM-DD-YY') ?? null
const secondRange_startDate =
props?.initial_secondRange_startDate?.format('MM-DD-YY') ?? null
const secondRange_endDate =
props?.initial_secondRange_endDate?.format('MM-DD-YY') ?? null
return (