Skip to content

Commit

Permalink
chore: Active cycle muatation when current cycle creation when curren…
Browse files Browse the repository at this point in the history
…t_date is in between start_date and end_date (#5050)
  • Loading branch information
gurusainath authored Jul 5, 2024
1 parent a36d1a7 commit 156f101
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,4 @@ const ProjectCyclesPage = observer(() => {
);
});

export default ProjectCyclesPage;
export default ProjectCyclesPage;
11 changes: 11 additions & 0 deletions web/core/components/cycles/modal.tsx
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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!",
Expand Down

0 comments on commit 156f101

Please sign in to comment.