chore: Active cycle muatation when current cycle creation when current_date is in between start_date and end_date (#5050)

This commit is contained in:
guru_sainath 2024-07-05 12:13:28 +05:30 committed by GitHub
parent a36d1a753e
commit 156f1011f3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 1 deletions

View file

@ -98,4 +98,4 @@ const ProjectCyclesPage = observer(() => {
);
});
export default ProjectCyclesPage;
export default ProjectCyclesPage;

View file

@ -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<CycleModalProps> = (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!",