2023-05-20 12:00:15 +00:00
|
|
|
import { useRouter } from "next/router";
|
2023-08-11 10:29:13 +00:00
|
|
|
|
2023-05-20 12:00:15 +00:00
|
|
|
// hooks
|
2023-08-11 10:29:13 +00:00
|
|
|
import useIssuesView from "hooks/use-issues-view";
|
|
|
|
import useUser from "hooks/use-user";
|
2023-05-20 12:00:15 +00:00
|
|
|
import useGanttChartIssues from "hooks/gantt-chart/issue-view";
|
2023-08-11 10:29:13 +00:00
|
|
|
import { updateGanttIssue } from "components/gantt-chart/hooks/block-update";
|
2023-09-04 07:38:49 +00:00
|
|
|
import useProjectDetails from "hooks/use-project-details";
|
2023-08-11 10:29:13 +00:00
|
|
|
// components
|
2023-08-28 07:55:47 +00:00
|
|
|
import { GanttChartRoot, renderIssueBlocksStructure } from "components/gantt-chart";
|
|
|
|
import { IssueGanttBlock, IssueGanttSidebarBlock } from "components/issues";
|
2023-08-11 10:29:13 +00:00
|
|
|
// types
|
|
|
|
import { IIssue } from "types";
|
|
|
|
|
|
|
|
export const IssueGanttChartView = () => {
|
2023-05-20 12:00:15 +00:00
|
|
|
const router = useRouter();
|
|
|
|
const { workspaceSlug, projectId } = router.query;
|
|
|
|
|
2023-08-11 10:29:13 +00:00
|
|
|
const { orderBy } = useIssuesView();
|
|
|
|
|
|
|
|
const { user } = useUser();
|
2023-09-04 07:38:49 +00:00
|
|
|
const { projectDetails } = useProjectDetails();
|
2023-08-11 10:29:13 +00:00
|
|
|
|
2023-05-20 12:00:15 +00:00
|
|
|
const { ganttIssues, mutateGanttIssues } = useGanttChartIssues(
|
|
|
|
workspaceSlug as string,
|
|
|
|
projectId as string
|
|
|
|
);
|
|
|
|
|
2023-09-04 07:38:49 +00:00
|
|
|
const isAllowed = projectDetails?.member_role === 20 || projectDetails?.member_role === 15;
|
|
|
|
|
2023-05-20 12:00:15 +00:00
|
|
|
return (
|
2023-05-21 13:57:08 +00:00
|
|
|
<div className="w-full h-full">
|
2023-05-20 12:00:15 +00:00
|
|
|
<GanttChartRoot
|
2023-05-21 13:57:08 +00:00
|
|
|
border={false}
|
2023-05-20 12:00:15 +00:00
|
|
|
title="Issues"
|
|
|
|
loaderTitle="Issues"
|
2023-08-11 10:29:13 +00:00
|
|
|
blocks={ganttIssues ? renderIssueBlocksStructure(ganttIssues as IIssue[]) : null}
|
|
|
|
blockUpdateHandler={(block, payload) =>
|
|
|
|
updateGanttIssue(block, payload, mutateGanttIssues, user, workspaceSlug?.toString())
|
|
|
|
}
|
2023-08-28 07:55:47 +00:00
|
|
|
BlockRender={IssueGanttBlock}
|
|
|
|
SidebarBlockRender={IssueGanttSidebarBlock}
|
2023-09-04 07:38:49 +00:00
|
|
|
enableBlockLeftResize={isAllowed}
|
|
|
|
enableBlockRightResize={isAllowed}
|
|
|
|
enableBlockMove={isAllowed}
|
|
|
|
enableReorder={orderBy === "sort_order" && isAllowed}
|
2023-08-28 07:55:47 +00:00
|
|
|
bottomSpacing
|
2023-05-20 12:00:15 +00:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|