import {useCallback} from 'react'; import styled from '@emotion/styled'; import type {TimeWindow} from 'sentry/components/checkInTimeline/types'; import {SegmentedControl} from 'sentry/components/segmentedControl'; import {t} from 'sentry/locale'; import {space} from 'sentry/styles/space'; import {useLocation} from 'sentry/utils/useLocation'; import {useNavigate} from 'sentry/utils/useNavigate'; interface Props { className?: string; } export function ResolutionSelector({className}: Props) { const location = useLocation(); const navigate = useNavigate(); const handleResolutionChange = useCallback( (value: TimeWindow) => navigate( {...location, query: {...location.query, timeWindow: value}}, {replace: true} ), [location, navigate] ); const timeWindow = (location.query?.timeWindow as TimeWindow) ?? '24h'; return ( value={timeWindow} onChange={handleResolutionChange} size="xs" aria-label={t('Time Scale')} > {t('Hour')} {t('Day')} {t('Week')} {t('Month')} ); } const ListFilters = styled('div')` display: flex; gap: ${space(1)}; `;