2023-05-20 12:00:15 +00:00
|
|
|
import { FC, useEffect, useState } from "react";
|
|
|
|
// helpers
|
|
|
|
import { ChartDraggable } from "../helpers/draggable";
|
|
|
|
// data
|
|
|
|
import { datePreview } from "../data";
|
|
|
|
|
|
|
|
export const GanttChartBlocks: FC<{
|
|
|
|
itemsContainerWidth: number;
|
|
|
|
blocks: null | any[];
|
|
|
|
sidebarBlockRender: FC;
|
|
|
|
blockRender: FC;
|
|
|
|
}> = ({ itemsContainerWidth, blocks, sidebarBlockRender, blockRender }) => {
|
|
|
|
const handleChartBlockPosition = (block: any) => {
|
|
|
|
// setChartBlocks((prevData: any) =>
|
|
|
|
// prevData.map((_block: any) => (_block?.data?.id == block?.data?.id ? block : _block))
|
|
|
|
// );
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div
|
2023-06-29 12:46:01 +00:00
|
|
|
className="relative z-[5] mt-[58px] h-full w-[4000px] divide-x divide-gray-300 overflow-hidden overflow-y-auto"
|
2023-05-20 12:00:15 +00:00
|
|
|
style={{ width: `${itemsContainerWidth}px` }}
|
|
|
|
>
|
2023-05-20 17:40:04 +00:00
|
|
|
<div className="w-full">
|
2023-05-20 12:00:15 +00:00
|
|
|
{blocks &&
|
|
|
|
blocks.length > 0 &&
|
|
|
|
blocks.map((block: any, _idx: number) => (
|
|
|
|
<>
|
|
|
|
{block.start_date && block.target_date && (
|
|
|
|
<ChartDraggable
|
2023-05-20 17:40:04 +00:00
|
|
|
className="relative flex h-[40px] items-center"
|
2023-05-20 12:00:15 +00:00
|
|
|
key={`blocks-${_idx}`}
|
|
|
|
block={block}
|
|
|
|
handleBlock={handleChartBlockPosition}
|
|
|
|
>
|
|
|
|
<div
|
|
|
|
className="relative group inline-flex cursor-pointer items-center font-medium transition-all"
|
|
|
|
style={{ marginLeft: `${block?.position?.marginLeft}px` }}
|
|
|
|
>
|
|
|
|
<div className="flex-shrink-0 relative w-0 h-0 flex items-center invisible group-hover:visible whitespace-nowrap">
|
2023-07-10 07:17:00 +00:00
|
|
|
<div className="absolute right-0 mr-[5px] rounded-sm bg-custom-background-90 px-2 py-0.5 text-xs font-medium">
|
2023-05-21 13:07:26 +00:00
|
|
|
{block?.start_date ? datePreview(block?.start_date) : "-"}
|
2023-05-20 12:00:15 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div
|
2023-07-17 07:30:44 +00:00
|
|
|
className="rounded shadow-sm bg-custom-background-100 overflow-hidden relative flex items-center h-[34px] border border-custom-border-300"
|
2023-05-20 12:00:15 +00:00
|
|
|
style={{
|
|
|
|
width: `${block?.position?.width}px`,
|
|
|
|
}}
|
|
|
|
>
|
2023-05-22 16:39:52 +00:00
|
|
|
{blockRender({
|
|
|
|
...block?.data,
|
|
|
|
infoToggle: block?.infoToggle ? true : false,
|
|
|
|
})}
|
2023-05-20 12:00:15 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className="flex-shrink-0 relative w-0 h-0 flex items-center invisible group-hover:visible whitespace-nowrap">
|
2023-07-10 07:17:00 +00:00
|
|
|
<div className="absolute left-0 ml-[5px] mr-[5px] rounded-sm bg-custom-background-90 px-2 py-0.5 text-xs font-medium">
|
2023-05-21 13:07:26 +00:00
|
|
|
{block?.target_date ? datePreview(block?.target_date) : "-"}
|
2023-05-20 12:00:15 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</ChartDraggable>
|
|
|
|
)}
|
|
|
|
</>
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{/* sidebar */}
|
2023-07-17 07:30:44 +00:00
|
|
|
{/* <div className="fixed top-0 bottom-0 w-[300px] flex-shrink-0 divide-y divide-custom-border-300 border-r border-custom-border-300 overflow-y-auto">
|
2023-05-20 12:00:15 +00:00
|
|
|
{blocks &&
|
|
|
|
blocks.length > 0 &&
|
|
|
|
blocks.map((block: any, _idx: number) => (
|
2023-07-10 07:17:00 +00:00
|
|
|
<div className="relative h-[40px] bg-custom-background-100" key={`sidebar-blocks-${_idx}`}>
|
2023-05-20 12:00:15 +00:00
|
|
|
{sidebarBlockRender(block?.data)}
|
|
|
|
</div>
|
|
|
|
))}
|
|
|
|
</div> */}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|