From 290318603dc0cce52ef60032ef5c7d0819e7e9cc Mon Sep 17 00:00:00 2001 From: Aaryan Khandelwal <65252264+aaryan610@users.noreply.github.com> Date: Mon, 15 May 2023 11:35:07 +0530 Subject: [PATCH] fix: calendar view mutation (#1042) --- .../core/calendar-view/calendar-header.tsx | 79 ++++----- .../core/calendar-view/calendar.tsx | 158 +++++++----------- .../core/calendar-view/single-issue.tsx | 33 ++-- .../components/issues/delete-issue-modal.tsx | 26 +-- apps/app/components/issues/modal.tsx | 55 ++---- apps/app/constants/fetch-keys.ts | 13 +- apps/app/contexts/issue-view.context.tsx | 50 ++++++ apps/app/hooks/use-calendar-issues-view.tsx | 124 ++++++++++++++ apps/app/hooks/use-issues-view.tsx | 4 + apps/app/types/issues.d.ts | 1 - apps/app/types/projects.d.ts | 1 + 11 files changed, 337 insertions(+), 207 deletions(-) create mode 100644 apps/app/hooks/use-calendar-issues-view.tsx 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) => (