2023-05-20 12:00:15 +00:00
|
|
|
import { FC } from "react";
|
2023-05-21 13:07:26 +00:00
|
|
|
// next imports
|
|
|
|
import Link from "next/link";
|
|
|
|
import { useRouter } from "next/router";
|
2023-05-20 12:00:15 +00:00
|
|
|
// components
|
|
|
|
import { GanttChartRoot } from "components/gantt-chart";
|
2023-05-22 16:39:52 +00:00
|
|
|
// ui
|
|
|
|
import { Tooltip } from "components/ui";
|
2023-05-20 12:00:15 +00:00
|
|
|
// types
|
|
|
|
import { ICycle } from "types";
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
cycles: ICycle[];
|
|
|
|
};
|
|
|
|
|
|
|
|
export const CyclesListGanttChartView: FC<Props> = ({ cycles }) => {
|
2023-05-21 13:07:26 +00:00
|
|
|
const router = useRouter();
|
|
|
|
const { workspaceSlug, projectId } = router.query;
|
|
|
|
|
2023-05-20 12:00:15 +00:00
|
|
|
// 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"
|
|
|
|
style={{ backgroundColor: "#858e96" }}
|
|
|
|
/>
|
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>
|
|
|
|
);
|
|
|
|
|
|
|
|
// rendering issues on gantt card
|
|
|
|
const GanttBlockView = ({ data }: { data: ICycle }) => (
|
2023-05-21 13:07:26 +00:00
|
|
|
<Link href={`/${workspaceSlug}/projects/${projectId}/cycles/${data?.id}`}>
|
|
|
|
<a className="relative flex items-center w-full h-full overflow-hidden shadow-sm">
|
|
|
|
<div className="flex-shrink-0 w-[4px] h-full" style={{ backgroundColor: "#858e96" }} />
|
2023-05-22 16:39:52 +00:00
|
|
|
<Tooltip tooltipContent={data?.name} className={`z-[999999]`}>
|
2023-07-10 07:17:00 +00:00
|
|
|
<div className="text-custom-text-100 text-[15px] whitespace-nowrap py-[4px] px-2.5 overflow-hidden w-full">
|
2023-05-22 16:39:52 +00:00
|
|
|
{data?.name}
|
|
|
|
</div>
|
|
|
|
</Tooltip>
|
2023-05-21 13:07:26 +00:00
|
|
|
</a>
|
|
|
|
</Link>
|
2023-05-20 12:00:15 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
// handle gantt issue start date and target date
|
|
|
|
const handleUpdateDates = async (data: any) => {
|
|
|
|
const payload = {
|
|
|
|
id: data?.id,
|
|
|
|
start_date: data?.start_date,
|
|
|
|
target_date: data?.target_date,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const blockFormat = (blocks: any) =>
|
|
|
|
blocks && blocks.length > 0
|
|
|
|
? blocks.map((_block: any) => {
|
|
|
|
if (_block?.start_date && _block.target_date) console.log("_block", _block);
|
|
|
|
return {
|
|
|
|
start_date: new Date(_block.created_at),
|
|
|
|
target_date: new Date(_block.updated_at),
|
|
|
|
data: _block,
|
|
|
|
};
|
|
|
|
})
|
|
|
|
: [];
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="w-full h-full overflow-y-auto">
|
|
|
|
<GanttChartRoot
|
|
|
|
title={"Cycles"}
|
|
|
|
loaderTitle="Cycles"
|
|
|
|
blocks={cycles ? blockFormat(cycles) : null}
|
|
|
|
blockUpdateHandler={handleUpdateDates}
|
|
|
|
sidebarBlockRender={(data: any) => <GanttSidebarBlockView data={data} />}
|
|
|
|
blockRender={(data: any) => <GanttBlockView data={data} />}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|