diff --git a/smart-frontend/app/src/components/uikit/DateRangePicker/Tabs/CalendarTab.tsx b/smart-frontend/app/src/components/uikit/DateRangePicker/Tabs/CalendarTab.tsx index 833774c648..fe8d369fe5 100644 --- a/smart-frontend/app/src/components/uikit/DateRangePicker/Tabs/CalendarTab.tsx +++ b/smart-frontend/app/src/components/uikit/DateRangePicker/Tabs/CalendarTab.tsx @@ -17,7 +17,7 @@ */ import { useEffect, useState } from 'react'; import Calendar from '@uikit/Calendar/Calendar'; -import { endOfDay, isBefore, startOfDay } from '@utils/date/calendarUtils'; +import { endOfDay, getToday, isBefore, startOfDay } from '@utils/date/calendarUtils'; import TabActions from './TabActions'; import ts from './Tabs.module.scss'; import FormField from '@uikit/FormField/FormField'; @@ -32,8 +32,8 @@ interface CalendarTabProps { const CalendarTab = ({ rangeFrom, rangeTo, onApply, onRevert }: CalendarTabProps) => { const [localDate, setLocalDate] = useState(undefined); - const [localRangeFrom, setLocalRangeFrom] = useState(rangeFrom); - const [localRangeTo, setLocalRangeTo] = useState(rangeTo); + const [localRangeFrom, setLocalRangeFrom] = useState(() => rangeFrom ?? startOfDay(getToday())); + const [localRangeTo, setLocalRangeTo] = useState(() => rangeTo ?? endOfDay(getToday())); useEffect(() => { if (localRangeFrom && localRangeTo) { diff --git a/smart-frontend/app/src/components/uikit/DateRangePicker/Tabs/RangesTab.tsx b/smart-frontend/app/src/components/uikit/DateRangePicker/Tabs/RangesTab.tsx index 9fe8989a12..0a50aadb60 100644 --- a/smart-frontend/app/src/components/uikit/DateRangePicker/Tabs/RangesTab.tsx +++ b/smart-frontend/app/src/components/uikit/DateRangePicker/Tabs/RangesTab.tsx @@ -33,14 +33,14 @@ interface RangesTabProps { } const RangesTab = ({ range, onApply, onRevert, rangesPreset }: RangesTabProps) => { - const [selectedRangeId, setSelectedRangeId] = useState(range); + const [selectedRangeId, setSelectedRangeId] = useState(range ?? rangesPreset[0].id); const handleClick = (item: RangePreset) => { setSelectedRangeId(item.id); }; const handleApply = () => { - selectedRangeId && onApply(selectedRangeId); + onApply(selectedRangeId); }; return ( @@ -61,10 +61,10 @@ const RangesTab = ({ range, onApply, onRevert, rangesPreset }: RangesTabProps) =
- + - +