2024-03-06 13:09:14 +00:00
|
|
|
import { observer } from "mobx-react";
|
2024-02-12 09:38:17 +00:00
|
|
|
import { Expand, Shrink } from "lucide-react";
|
|
|
|
// hooks
|
|
|
|
// helpers
|
2024-03-06 13:09:14 +00:00
|
|
|
import { VIEWS_LIST } from "components/gantt-chart/data";
|
2024-02-12 09:38:17 +00:00
|
|
|
import { cn } from "helpers/common.helper";
|
|
|
|
// types
|
2024-03-06 13:09:14 +00:00
|
|
|
import { useGanttChart } from "../hooks/use-gantt-chart";
|
2024-02-12 09:38:17 +00:00
|
|
|
import { IGanttBlock, TGanttViews } from "../types";
|
2024-02-23 13:40:45 +00:00
|
|
|
// constants
|
2024-02-12 09:38:17 +00:00
|
|
|
|
|
|
|
type Props = {
|
2024-03-18 07:42:10 +00:00
|
|
|
blockIds: string[];
|
2024-02-12 09:38:17 +00:00
|
|
|
fullScreenMode: boolean;
|
|
|
|
handleChartView: (view: TGanttViews) => void;
|
|
|
|
handleToday: () => void;
|
|
|
|
loaderTitle: string;
|
|
|
|
title: string;
|
|
|
|
toggleFullScreenMode: () => void;
|
|
|
|
};
|
|
|
|
|
2024-02-23 13:40:45 +00:00
|
|
|
export const GanttChartHeader: React.FC<Props> = observer((props) => {
|
2024-03-18 07:42:10 +00:00
|
|
|
const { blockIds, fullScreenMode, handleChartView, handleToday, loaderTitle, title, toggleFullScreenMode } = props;
|
2024-02-12 09:38:17 +00:00
|
|
|
// chart hook
|
2024-02-23 13:40:45 +00:00
|
|
|
const { currentView } = useGanttChart();
|
2024-02-12 09:38:17 +00:00
|
|
|
|
|
|
|
return (
|
2024-03-11 15:30:05 +00:00
|
|
|
<div className="relative flex w-full flex-shrink-0 flex-wrap items-center gap-2 whitespace-nowrap px-2.5 py-2">
|
2024-02-12 09:38:17 +00:00
|
|
|
<div className="flex items-center gap-2 text-lg font-medium">{title}</div>
|
|
|
|
<div className="ml-auto">
|
2024-03-18 07:42:10 +00:00
|
|
|
<div className="ml-auto text-sm font-medium">
|
|
|
|
{blockIds ? `${blockIds.length} ${loaderTitle}` : "Loading..."}
|
|
|
|
</div>
|
2024-02-12 09:38:17 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className="flex flex-wrap items-center gap-2">
|
2024-02-23 13:40:45 +00:00
|
|
|
{VIEWS_LIST.map((chartView: any) => (
|
2024-02-12 09:38:17 +00:00
|
|
|
<div
|
|
|
|
key={chartView?.key}
|
|
|
|
className={cn("cursor-pointer rounded-sm p-1 px-2 text-xs", {
|
|
|
|
"bg-custom-background-80": currentView === chartView?.key,
|
|
|
|
"hover:bg-custom-background-90": currentView !== chartView?.key,
|
|
|
|
})}
|
|
|
|
onClick={() => handleChartView(chartView?.key)}
|
|
|
|
>
|
|
|
|
{chartView?.title}
|
|
|
|
</div>
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<button type="button" className="rounded-sm p-1 px-2 text-xs hover:bg-custom-background-80" onClick={handleToday}>
|
|
|
|
Today
|
|
|
|
</button>
|
|
|
|
|
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
className="flex items-center justify-center rounded-sm border border-custom-border-200 p-1 transition-all hover:bg-custom-background-80"
|
|
|
|
onClick={toggleFullScreenMode}
|
|
|
|
>
|
|
|
|
{fullScreenMode ? <Shrink className="h-4 w-4" /> : <Expand className="h-4 w-4" />}
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
);
|
2024-02-23 13:40:45 +00:00
|
|
|
});
|