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 7ad179d265..1650607f0c 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 0000000000..9c6e55594f --- /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 0000000000..efa8c553e9 --- /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 0000000000..0c53083bd1 --- /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 0000000000..93336fb8c9 --- /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