import './CustomTimePicker.styles.scss'; import { Color } from '@signozhq/design-tokens'; import { Button } from 'antd'; import cx from 'classnames'; import ROUTES from 'constants/routes'; import { DateTimeRangeType } from 'container/TopNav/CustomDateTimeModal'; import { LexicalContext, Option, RelativeDurationSuggestionOptions, } from 'container/TopNav/DateTimeSelectionV2/config'; import { Clock, PenLine } from 'lucide-react'; import { useTimezone } from 'providers/Timezone'; import { Dispatch, SetStateAction, useMemo } from 'react'; import { useLocation } from 'react-router-dom'; import RangePickerModal from './RangePickerModal'; import TimezonePicker from './TimezonePicker'; interface CustomTimePickerPopoverContentProps { options: any[]; setIsOpen: Dispatch>; customDateTimeVisible: boolean; setCustomDTPickerVisible: Dispatch>; onCustomDateHandler: ( dateTimeRange: DateTimeRangeType, lexicalContext?: LexicalContext, ) => void; onSelectHandler: (label: string, value: string) => void; handleGoLive: () => void; selectedTime: string; activeView: 'datetime' | 'timezone'; setActiveView: Dispatch>; isOpenedFromFooter: boolean; setIsOpenedFromFooter: Dispatch>; } // eslint-disable-next-line sonarjs/cognitive-complexity function CustomTimePickerPopoverContent({ options, setIsOpen, customDateTimeVisible, setCustomDTPickerVisible, onCustomDateHandler, onSelectHandler, handleGoLive, selectedTime, activeView, setActiveView, isOpenedFromFooter, setIsOpenedFromFooter, }: CustomTimePickerPopoverContentProps): JSX.Element { const { pathname } = useLocation(); const isLogsExplorerPage = useMemo(() => pathname === ROUTES.LOGS_EXPLORER, [ pathname, ]); const { timezone } = useTimezone(); const activeTimezoneOffset = timezone.offset; function getTimeChips(options: Option[]): JSX.Element { return (
{options.map((option) => ( ))}
); } const handleTimezoneHintClick = (): void => { setActiveView('timezone'); setIsOpenedFromFooter(true); }; if (activeView === 'timezone') { return (
); } return ( <>
{isLogsExplorerPage && ( )} {options.map((option) => ( ))}
{selectedTime === 'custom' || customDateTimeVisible ? ( ) : (
RELATIVE TIMES
{getTimeChips(RelativeDurationSuggestionOptions)}
)}
Current timezone
); } export default CustomTimePickerPopoverContent;