diff --git a/apps/app/components/core/calendar-view/calendar-header.tsx b/apps/app/components/core/calendar-view/calendar-header.tsx index c8dd5e708..aab25506b 100644 --- a/apps/app/components/core/calendar-view/calendar-header.tsx +++ b/apps/app/components/core/calendar-view/calendar-header.tsx @@ -1,4 +1,17 @@ +import React from "react"; + +// headless ui import { Popover, Transition } from "@headlessui/react"; +// ui +import { CustomMenu, ToggleSwitch } from "components/ui"; +// icons +import { + CheckIcon, + ChevronDownIcon, + ChevronLeftIcon, + ChevronRightIcon, +} from "@heroicons/react/24/outline"; +// helpers import { addMonths, addSevenDaysToDate, @@ -14,26 +27,17 @@ import { updateDateWithMonth, updateDateWithYear, } from "helpers/calendar.helper"; -import React from "react"; +// constants import { MONTHS_LIST, YEARS_LIST } from "constants/calendar"; -import { ICalendarRange } from "types"; -import { - CheckIcon, - ChevronDownIcon, - ChevronLeftIcon, - ChevronRightIcon, -} from "@heroicons/react/24/outline"; -import { CustomMenu, ToggleSwitch } from "components/ui"; - type Props = { isMonthlyView: boolean; setIsMonthlyView: React.Dispatch>; currentDate: Date; setCurrentDate: React.Dispatch>; - setCalendarDateRange: React.Dispatch>; showWeekEnds: boolean; setShowWeekEnds: React.Dispatch>; + changeDateRange: (startDate: Date, endDate: Date) => void; }; export const CalendarHeader: React.FC = ({ @@ -41,18 +45,16 @@ export const CalendarHeader: React.FC = ({ isMonthlyView, currentDate, setCurrentDate, - setCalendarDateRange, showWeekEnds, setShowWeekEnds, + changeDateRange, }) => { const updateDate = (date: Date) => { setCurrentDate(date); - setCalendarDateRange({ - startDate: startOfWeek(date), - endDate: lastDayOfWeek(date), - }); + changeDateRange(startOfWeek(date), lastDayOfWeek(date)); }; + return (
@@ -93,9 +95,13 @@ export const CalendarHeader: React.FC = ({
{MONTHS_LIST.map((month) => (