From 156f1011f319cf9309c0f3f84d2d1a57d1c14d1f Mon Sep 17 00:00:00 2001 From: guru_sainath Date: Fri, 5 Jul 2024 12:13:28 +0530 Subject: [PATCH] chore: Active cycle muatation when current cycle creation when current_date is in between start_date and end_date (#5050) --- .../(detail)/[projectId]/cycles/(list)/page.tsx | 2 +- web/core/components/cycles/modal.tsx | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/cycles/(list)/page.tsx b/web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/cycles/(list)/page.tsx index 9cebd29ce90..5c046d95c12 100644 --- a/web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/cycles/(list)/page.tsx +++ b/web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/cycles/(list)/page.tsx @@ -98,4 +98,4 @@ const ProjectCyclesPage = observer(() => { ); }); -export default ProjectCyclesPage; \ No newline at end of file +export default ProjectCyclesPage; diff --git a/web/core/components/cycles/modal.tsx b/web/core/components/cycles/modal.tsx index c6f78a25673..ab011046704 100644 --- a/web/core/components/cycles/modal.tsx +++ b/web/core/components/cycles/modal.tsx @@ -1,6 +1,7 @@ "use client"; import React, { useEffect, useState } from "react"; +import { mutate } from "swr"; // types import type { CycleDateCheckData, ICycle, TCycleTabOptions } from "@plane/types"; // ui @@ -43,6 +44,16 @@ export const CycleCreateUpdateModal: React.FC = (props) => { const selectedProjectId = payload.project_id ?? projectId.toString(); await createCycle(workspaceSlug, selectedProjectId, payload) .then((res) => { + // mutate when the current cycle creation is active + if (payload.start_date && payload.end_date) { + const currentDate = new Date(); + const cycleStartDate = new Date(payload.start_date); + const cycleEndDate = new Date(payload.end_date); + if (currentDate >= cycleStartDate && currentDate <= cycleEndDate) { + mutate(`PROJECT_ACTIVE_CYCLE_${selectedProjectId}`); + } + } + setToast({ type: TOAST_TYPE.SUCCESS, title: "Success!",