Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions apps/app/components/cycles/delete-cycle-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { DangerButton, SecondaryButton } from "components/ui";
// icons
import { ExclamationTriangleIcon } from "@heroicons/react/24/outline";
// types
import type { ICurrentUserResponse, ICycle } from "types";
import type { ICurrentUserResponse, ICycle, IProject } from "types";
type TConfirmCycleDeletionProps = {
isOpen: boolean;
setIsOpen: React.Dispatch<React.SetStateAction<boolean>>;
Expand All @@ -27,6 +27,7 @@ import {
CURRENT_CYCLE_LIST,
CYCLES_LIST,
DRAFT_CYCLES_LIST,
PROJECT_DETAILS,
UPCOMING_CYCLES_LIST,
} from "constants/fetch-keys";
import { getDateRangeStatus } from "helpers/date-time.helper";
Expand All @@ -50,7 +51,7 @@ export const DeleteCycleModal: React.FC<TConfirmCycleDeletionProps> = ({
};

const handleDeletion = async () => {
if (!data || !workspaceSlug) return;
if (!data || !workspaceSlug || !projectId) return;

setIsDeleteLoading(true);

Expand Down Expand Up @@ -85,6 +86,21 @@ export const DeleteCycleModal: React.FC<TConfirmCycleDeletionProps> = ({
},
false
);

// update total cycles count in the project details
mutate<IProject>(
PROJECT_DETAILS(projectId.toString()),
(prevData) => {
if (!prevData) return prevData;

return {
...prevData,
total_cycles: prevData.total_cycles - 1,
};
},
false
);

handleClose();

setToastAlert({
Expand Down
17 changes: 16 additions & 1 deletion apps/app/components/cycles/modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ import { CycleForm } from "components/cycles";
// helper
import { getDateRangeStatus } from "helpers/date-time.helper";
// types
import type { CycleDateCheckData, ICurrentUserResponse, ICycle } from "types";
import type { CycleDateCheckData, ICurrentUserResponse, ICycle, IProject } from "types";
// fetch keys
import {
COMPLETED_CYCLES_LIST,
CURRENT_CYCLE_LIST,
CYCLES_LIST,
DRAFT_CYCLES_LIST,
INCOMPLETE_CYCLES_LIST,
PROJECT_DETAILS,
UPCOMING_CYCLES_LIST,
} from "constants/fetch-keys";

Expand Down Expand Up @@ -66,6 +67,20 @@ export const CreateUpdateCycleModal: React.FC<CycleModalProps> = ({
mutate(INCOMPLETE_CYCLES_LIST(projectId.toString()));
mutate(CYCLES_LIST(projectId.toString()));

// update total cycles count in the project details
mutate<IProject>(
PROJECT_DETAILS(projectId.toString()),
(prevData) => {
if (!prevData) return prevData;

return {
...prevData,
total_cycles: prevData.total_cycles + 1,
};
},
false
);

setToastAlert({
type: "success",
title: "Success!",
Expand Down
20 changes: 11 additions & 9 deletions apps/app/hooks/use-issue-properties.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { useState, useEffect, useCallback } from "react";

import useSWR from "swr";

// services
import issueServices from "services/issues.service";
// hooks
Expand All @@ -9,17 +11,17 @@ import { IssuePriorities, Properties } from "types";

const initialValues: Properties = {
assignee: true,
due_date: false,
due_date: true,
key: true,
labels: false,
priority: false,
labels: true,
priority: true,
state: true,
sub_issue_count: false,
attachment_count: false,
link: false,
estimate: false,
created_on: false,
updated_on: false,
sub_issue_count: true,
attachment_count: true,
link: true,
estimate: true,
created_on: true,
updated_on: true,
};

const useIssuesProperties = (workspaceSlug?: string, projectId?: string) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ const ProjectCycles: NextPage = () => {
</Tab.List>
<div className="justify-end sm:justify-start flex items-center gap-x-1">
{cycleViews.map((view) => {
if (view.key === "gantt" && (cycleTab === "Active" || cycleTab === "Drafts"))
return null;
if (cycleTab === "Active") return null;
if (view.key === "gantt" && cycleTab === "Drafts") return null;

return (
<button
Expand Down