From 7c06be19fca89208f5c8f6a0e08d94798482cb4d Mon Sep 17 00:00:00 2001 From: Anmol Singh Bhatia <121005188+anmolsinghbhatia@users.noreply.github.com> Date: Thu, 9 Feb 2023 17:54:47 +0530 Subject: [PATCH] feat: cycle status (#265) * feat: cycle status and dates added in sidebar * feat: update status added --------- Co-authored-by: Anmol Singh Bhatia --- .../cycles/cycle-detail-sidebar/index.tsx | 45 +++++++++--- apps/app/components/project/cycles/index.ts | 3 + .../project/cycles/sidebar-select/index.ts | 1 + .../cycles/sidebar-select/select-status.tsx | 69 +++++++++++++++++++ apps/app/constants/cycle.ts | 5 ++ 5 files changed, 113 insertions(+), 10 deletions(-) create mode 100644 apps/app/components/project/cycles/index.ts create mode 100644 apps/app/components/project/cycles/sidebar-select/index.ts create mode 100644 apps/app/components/project/cycles/sidebar-select/select-status.tsx create mode 100644 apps/app/constants/cycle.ts 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 7ad179d26..1650607f0 100644 --- a/apps/app/components/project/cycles/cycle-detail-sidebar/index.tsx +++ b/apps/app/components/project/cycles/cycle-detail-sidebar/index.tsx @@ -10,6 +10,9 @@ import { Controller, useForm } from "react-hook-form"; // react-circular-progressbar import { CircularProgressbar } from "react-circular-progressbar"; import "react-circular-progressbar/dist/styles.css"; +// icons +import { CalendarDaysIcon, ChartPieIcon, LinkIcon, UserIcon } from "@heroicons/react/24/outline"; +import { CycleSidebarStatusSelect } from "components/project/cycles"; // ui import { Loader, CustomDatePicker } from "components/ui"; // hooks @@ -18,8 +21,6 @@ import useToast from "hooks/use-toast"; import cyclesService from "services/cycles.service"; // components import SidebarProgressStats from "components/core/sidebar/sidebar-progress-stats"; -// icons -import { CalendarDaysIcon, ChartPieIcon, LinkIcon, UserIcon } from "@heroicons/react/24/outline"; // helpers import { copyTextToClipboard } from "helpers/string.helper"; import { groupBy } from "helpers/array.helper"; @@ -28,6 +29,8 @@ import { CycleIssueResponse, ICycle, IIssue } from "types"; // fetch-keys import { CYCLE_DETAILS } from "constants/fetch-keys"; +import { renderShortNumericDateFormat } from "helpers/date-time.helper"; + type Props = { issues: IIssue[]; cycle: ICycle | undefined; @@ -35,20 +38,17 @@ type Props = { cycleIssues: CycleIssueResponse[]; }; -const defaultValues: Partial = { - start_date: new Date().toString(), - end_date: new Date().toString(), -}; - const CycleDetailSidebar: React.FC = ({ issues, cycle, isOpen, cycleIssues }) => { const router = useRouter(); const { workspaceSlug, projectId, cycleId } = router.query; const { setToastAlert } = useToast(); - const { reset, control } = useForm({ - defaultValues, - }); + const defaultValues: Partial = { + start_date: new Date().toString(), + end_date: new Date().toString(), + status: cycle?.status, + }; const groupedIssues = { backlog: [], @@ -59,6 +59,10 @@ const CycleDetailSidebar: React.FC = ({ issues, cycle, isOpen, cycleIssue ...groupBy(cycleIssues ?? [], "issue_detail.state_detail.group"), }; + const { reset, watch, control } = useForm({ + defaultValues, + }); + const submitChanges = (data: Partial) => { if (!workspaceSlug || !projectId || !cycleId) return; @@ -94,6 +98,22 @@ const CycleDetailSidebar: React.FC = ({ issues, cycle, isOpen, cycleIssue > {cycle ? ( <> +
+
+ {cycle.status} +
+
+ + {renderShortNumericDateFormat(`${cycle.start_date}`) + ? renderShortNumericDateFormat(`${cycle.start_date}`) + : "N/A"}{" "} + -{" "} + {renderShortNumericDateFormat(`${cycle.end_date}`) + ? renderShortNumericDateFormat(`${cycle.end_date}`) + : "N/A"} + +
+

{cycle.name}

@@ -219,6 +239,11 @@ 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 new file mode 100644 index 000000000..9c6e55594 --- /dev/null +++ b/apps/app/components/project/cycles/index.ts @@ -0,0 +1,3 @@ +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 new file mode 100644 index 000000000..efa8c553e --- /dev/null +++ b/apps/app/components/project/cycles/sidebar-select/index.ts @@ -0,0 +1 @@ +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 new file mode 100644 index 000000000..0c53083bd --- /dev/null +++ b/apps/app/components/project/cycles/sidebar-select/select-status.tsx @@ -0,0 +1,69 @@ +// 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} + + + ))} + + )} + /> +
+
+); diff --git a/apps/app/constants/cycle.ts b/apps/app/constants/cycle.ts new file mode 100644 index 000000000..93336fb8c --- /dev/null +++ b/apps/app/constants/cycle.ts @@ -0,0 +1,5 @@ +export const CYCLE_STATUS = [ + { label: "Started", value: "started", color: "#5e6ad2" }, + { label: "Completed", value: "completed", color: "#eb5757" }, + { label: "Draft", value: "draft", color: "#f2c94c" }, + ]; \ No newline at end of file