From 2069c89bb9b073b0cb227a6f8af7f990d5832c17 Mon Sep 17 00:00:00 2001 From: Anmol Singh Bhatia Date: Mon, 13 Feb 2023 04:50:00 +0530 Subject: [PATCH 1/2] feat: range date picker added --- .../cycles/cycle-detail-sidebar/index.tsx | 123 +++++++++--------- 1 file changed, 63 insertions(+), 60 deletions(-) diff --git a/apps/app/components/project/cycles/cycle-detail-sidebar/index.tsx b/apps/app/components/project/cycles/cycle-detail-sidebar/index.tsx index cdbac8b17cf..64dad62b630 100644 --- a/apps/app/components/project/cycles/cycle-detail-sidebar/index.tsx +++ b/apps/app/components/project/cycles/cycle-detail-sidebar/index.tsx @@ -1,4 +1,4 @@ -import { useEffect } from "react"; +import React, { useEffect, useState } from "react"; import { useRouter } from "next/router"; import Image from "next/image"; @@ -10,11 +10,13 @@ import { Controller, useForm } from "react-hook-form"; // react-circular-progressbar import { CircularProgressbar } from "react-circular-progressbar"; import "react-circular-progressbar/dist/styles.css"; +import { Popover, Transition } from "@headlessui/react"; +import DatePicker from "react-datepicker"; // icons import { CalendarDaysIcon, ChartPieIcon, LinkIcon, UserIcon } from "@heroicons/react/24/outline"; import { CycleSidebarStatusSelect } from "components/project/cycles"; // ui -import { Loader, CustomDatePicker } from "components/ui"; +import { Loader } from "components/ui"; // hooks import useToast from "hooks/use-toast"; // services @@ -24,7 +26,7 @@ import { SidebarProgressStats } from "components/core"; // helpers import { copyTextToClipboard } from "helpers/string.helper"; import { groupBy } from "helpers/array.helper"; -import { renderShortNumericDateFormat } from "helpers/date-time.helper"; +import { renderDateFormat, renderShortNumericDateFormat } from "helpers/date-time.helper"; // types import { CycleIssueResponse, ICycle, IIssue } from "types"; // fetch-keys @@ -42,6 +44,9 @@ const CycleDetailSidebar: React.FC = ({ issues, cycle, isOpen, cycleIssue const router = useRouter(); const { workspaceSlug, projectId, cycleId } = router.query; + const [startDateRange, setStartDateRange] = useState(new Date()); + const [endDateRange, setEndDateRange] = useState(null); + const { setToastAlert } = useToast(); const defaultValues: Partial = { @@ -102,17 +107,61 @@ const CycleDetailSidebar: React.FC = ({ issues, cycle, isOpen, cycleIssue
{cycle.status}
-
- - {renderShortNumericDateFormat(`${cycle.start_date}`) - ? renderShortNumericDateFormat(`${cycle.start_date}`) - : "N/A"}{" "} - -{" "} - {renderShortNumericDateFormat(`${cycle.end_date}`) - ? renderShortNumericDateFormat(`${cycle.end_date}`) - : "N/A"} - -
+ + {({ open }) => ( + <> + + + + {renderShortNumericDateFormat(`${cycle.start_date}`) + ? renderShortNumericDateFormat(`${cycle.start_date}`) + : "N/A"}{" "} + -{" "} + {renderShortNumericDateFormat(`${cycle.end_date}`) + ? renderShortNumericDateFormat(`${cycle.end_date}`) + : "N/A"} + + + + + + { + const [start, end] = dates; + submitChanges({ + start_date: renderDateFormat(start), + end_date: renderDateFormat(end), + }); + if (setStartDateRange) { + setStartDateRange(start); + } + if (setEndDateRange) { + setEndDateRange(end); + } + }} + startDate={startDateRange} + endDate={endDateRange} + selectsRange + inline + /> + + + + )} +

{cycle.name}

@@ -193,52 +242,6 @@ const CycleDetailSidebar: React.FC = ({ issues, cycle, isOpen, cycleIssue
-
-
- -

Start date

-
-
- ( - - submitChanges({ - start_date: val, - }) - } - isClearable={false} - /> - )} - /> -
-
-
-
- -

End date

-
-
- ( - - submitChanges({ - end_date: val, - }) - } - isClearable={false} - /> - )} - /> -
-
Date: Mon, 13 Feb 2023 05:21:11 +0530 Subject: [PATCH 2/2] feat: cycle status ui improved --- .../cycles/cycle-detail-sidebar/index.tsx | 54 +++++++++++---- apps/app/components/project/cycles/index.ts | 1 - .../project/cycles/sidebar-select/index.ts | 1 - .../cycles/sidebar-select/select-status.tsx | 69 ------------------- 4 files changed, 39 insertions(+), 86 deletions(-) delete mode 100644 apps/app/components/project/cycles/sidebar-select/index.ts delete mode 100644 apps/app/components/project/cycles/sidebar-select/select-status.tsx diff --git a/apps/app/components/project/cycles/cycle-detail-sidebar/index.tsx b/apps/app/components/project/cycles/cycle-detail-sidebar/index.tsx index 64dad62b630..e1aa46692b8 100644 --- a/apps/app/components/project/cycles/cycle-detail-sidebar/index.tsx +++ b/apps/app/components/project/cycles/cycle-detail-sidebar/index.tsx @@ -13,10 +13,15 @@ import "react-circular-progressbar/dist/styles.css"; import { Popover, Transition } from "@headlessui/react"; import DatePicker from "react-datepicker"; // icons -import { CalendarDaysIcon, ChartPieIcon, LinkIcon, UserIcon } from "@heroicons/react/24/outline"; -import { CycleSidebarStatusSelect } from "components/project/cycles"; +import { + CalendarDaysIcon, + ChartPieIcon, + LinkIcon, + Squares2X2Icon, + UserIcon, +} from "@heroicons/react/24/outline"; // ui -import { Loader } from "components/ui"; +import { CustomSelect, Loader } from "components/ui"; // hooks import useToast from "hooks/use-toast"; // services @@ -32,6 +37,7 @@ import { CycleIssueResponse, ICycle, IIssue } from "types"; // fetch-keys import { CYCLE_DETAILS } from "constants/fetch-keys"; import ProgressChart from "components/core/sidebar/progress-chart"; +import { CYCLE_STATUS } from "constants/cycle"; type Props = { issues: IIssue[]; @@ -103,15 +109,40 @@ const CycleDetailSidebar: React.FC = ({ issues, cycle, isOpen, cycleIssue > {cycle ? ( <> -
-
- {cycle.status} +
+
+ ( + + + {watch("status")} + + } + value={value} + onChange={(value: any) => { + submitChanges({ status: value }); + }} + > + {CYCLE_STATUS.map((option) => ( + + {option.label} + + ))} + + )} + />
- + {({ open }) => ( <> @@ -241,13 +272,6 @@ const CycleDetailSidebar: React.FC = ({ issues, cycle, isOpen, cycleIssue
-
- -
diff --git a/apps/app/components/project/cycles/index.ts b/apps/app/components/project/cycles/index.ts index 9c6e55594fc..d330ba698f0 100644 --- a/apps/app/components/project/cycles/index.ts +++ b/apps/app/components/project/cycles/index.ts @@ -1,3 +1,2 @@ -export * from "./sidebar-select"; export * from "./stats-view"; export * from "./cycle-detail-sidebar"; \ No newline at end of file diff --git a/apps/app/components/project/cycles/sidebar-select/index.ts b/apps/app/components/project/cycles/sidebar-select/index.ts deleted file mode 100644 index efa8c553e91..00000000000 --- a/apps/app/components/project/cycles/sidebar-select/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./select-status"; \ No newline at end of file diff --git a/apps/app/components/project/cycles/sidebar-select/select-status.tsx b/apps/app/components/project/cycles/sidebar-select/select-status.tsx deleted file mode 100644 index 0c53083bd1d..00000000000 --- a/apps/app/components/project/cycles/sidebar-select/select-status.tsx +++ /dev/null @@ -1,69 +0,0 @@ -// react -import React from "react"; -// react-hook-form -import { Control, Controller, UseFormWatch } from "react-hook-form"; -// icons -import { Squares2X2Icon } from "@heroicons/react/24/outline"; -// ui -import { CustomSelect } from "components/ui"; -// types -import { ICycle } from "types"; -// common -// constants -import { CYCLE_STATUS } from "constants/cycle"; - -type Props = { - control: Control, any>; - submitChanges: (formData: Partial) => void; - watch: UseFormWatch>; -}; - -export const CycleSidebarStatusSelect: React.FC = ({ control, submitChanges, watch }) => ( -
-
- -

Status

-
-
- ( - - option.value === value)?.color, - }} - /> - {watch("status")} - - } - value={value} - onChange={(value: any) => { - submitChanges({ status: value }); - }} - > - {CYCLE_STATUS.map((option) => ( - - <> - - {option.label} - - - ))} - - )} - /> -
-
-);