2023-05-20 12:00:15 +00:00
|
|
|
import { FC } from "react";
|
2023-08-11 10:29:13 +00:00
|
|
|
|
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
|
|
|
|
import useGanttChartViewIssues from "hooks/gantt-chart/view-issues-view";
|
2023-08-11 10:29:13 +00:00
|
|
|
import useUser from "hooks/use-user";
|
|
|
|
import { updateGanttIssue } from "components/gantt-chart/hooks/block-update";
|
|
|
|
// components
|
|
|
|
import {
|
|
|
|
GanttChartRoot,
|
|
|
|
IssueGanttBlock,
|
|
|
|
renderIssueBlocksStructure,
|
|
|
|
} from "components/gantt-chart";
|
|
|
|
// types
|
|
|
|
import { IIssue } from "types";
|
2023-05-20 12:00:15 +00:00
|
|
|
|
|
|
|
type Props = {};
|
|
|
|
|
|
|
|
export const ViewIssuesGanttChartView: FC<Props> = ({}) => {
|
|
|
|
const router = useRouter();
|
|
|
|
const { workspaceSlug, projectId, viewId } = router.query;
|
|
|
|
|
2023-08-11 10:29:13 +00:00
|
|
|
const { user } = useUser();
|
|
|
|
|
2023-05-20 12:00:15 +00:00
|
|
|
const { ganttIssues, mutateGanttIssues } = useGanttChartViewIssues(
|
|
|
|
workspaceSlug as string,
|
|
|
|
projectId as string,
|
|
|
|
viewId as string
|
|
|
|
);
|
|
|
|
|
|
|
|
// rendering issues on gantt sidebar
|
|
|
|
const GanttSidebarBlockView = ({ data }: any) => (
|
|
|
|
<div className="relative flex w-full h-full items-center p-1 overflow-hidden gap-1">
|
|
|
|
<div
|
|
|
|
className="rounded-sm flex-shrink-0 w-[10px] h-[10px] flex justify-center items-center"
|
2023-07-17 10:58:23 +00:00
|
|
|
style={{ backgroundColor: data?.state_detail?.color || "rgb(var(--color-primary-100))" }}
|
2023-05-20 12:00:15 +00:00
|
|
|
/>
|
2023-07-10 07:17:00 +00:00
|
|
|
<div className="text-custom-text-100 text-sm">{data?.name}</div>
|
2023-05-20 12:00:15 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="w-full h-full p-3">
|
|
|
|
<GanttChartRoot
|
|
|
|
title="Issue Views"
|
|
|
|
loaderTitle="Issue Views"
|
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-05-20 12:00:15 +00:00
|
|
|
sidebarBlockRender={(data: any) => <GanttSidebarBlockView data={data} />}
|
2023-08-11 10:29:13 +00:00
|
|
|
blockRender={(data: any) => <IssueGanttBlock issue={data as IIssue} />}
|
2023-05-20 12:00:15 +00:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|