2023-05-20 12:00:15 +00:00
|
|
|
import { FC } from "react";
|
2023-08-11 10:29:13 +00:00
|
|
|
|
|
|
|
// hooks
|
2023-05-20 12:00:15 +00:00
|
|
|
import { useChart } from "../hooks";
|
2023-08-11 10:29:13 +00:00
|
|
|
// types
|
|
|
|
import { IMonthBlock } from "../views";
|
2023-05-20 12:00:15 +00:00
|
|
|
|
|
|
|
export const MonthChartView: FC<any> = () => {
|
2023-08-11 10:29:13 +00:00
|
|
|
const { currentViewData, renderView } = useChart();
|
|
|
|
|
|
|
|
const monthBlocks: IMonthBlock[] = renderView;
|
2023-05-20 12:00:15 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
2023-08-11 10:29:13 +00:00
|
|
|
<div className="absolute flex h-full flex-grow divide-x divide-custom-border-100/50">
|
|
|
|
{monthBlocks &&
|
|
|
|
monthBlocks.length > 0 &&
|
|
|
|
monthBlocks.map((block, _idxRoot) => (
|
|
|
|
<div key={`month-${block?.month}-${block?.year}`} className="relative flex flex-col">
|
2023-07-17 10:58:23 +00:00
|
|
|
<div className="relative border-b border-custom-border-200">
|
2023-05-20 12:00:15 +00:00
|
|
|
<div className="sticky left-0 inline-flex whitespace-nowrap px-2 py-1 text-sm font-medium capitalize">
|
2023-08-11 10:29:13 +00:00
|
|
|
{block?.title}
|
2023-05-20 12:00:15 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2023-08-11 10:29:13 +00:00
|
|
|
<div className="flex h-full w-full divide-x divide-custom-border-100/50">
|
|
|
|
{block?.children &&
|
|
|
|
block?.children.length > 0 &&
|
|
|
|
block?.children.map((monthDay, _idx) => (
|
2023-05-20 12:00:15 +00:00
|
|
|
<div
|
|
|
|
key={`sub-title-${_idxRoot}-${_idx}`}
|
|
|
|
className="relative flex h-full flex-col overflow-hidden whitespace-nowrap"
|
2023-08-11 10:29:13 +00:00
|
|
|
style={{ width: `${currentViewData?.data.width}px` }}
|
2023-05-20 12:00:15 +00:00
|
|
|
>
|
|
|
|
<div
|
|
|
|
className={`flex-shrink-0 border-b py-1 text-center text-sm capitalize font-medium ${
|
2023-08-11 10:29:13 +00:00
|
|
|
monthDay?.today
|
|
|
|
? `text-red-500 border-red-500`
|
|
|
|
: `border-custom-border-200`
|
2023-05-20 12:00:15 +00:00
|
|
|
}`}
|
|
|
|
>
|
2023-08-11 10:29:13 +00:00
|
|
|
<div>{monthDay?.title}</div>
|
2023-05-20 12:00:15 +00:00
|
|
|
</div>
|
|
|
|
<div
|
|
|
|
className={`relative h-full w-full flex-1 flex justify-center ${
|
2023-08-11 10:29:13 +00:00
|
|
|
["sat", "sun"].includes(monthDay?.dayData?.shortTitle || "")
|
2023-07-10 07:17:00 +00:00
|
|
|
? `bg-custom-background-90`
|
2023-05-20 12:00:15 +00:00
|
|
|
: ``
|
|
|
|
}`}
|
|
|
|
>
|
2023-08-11 10:29:13 +00:00
|
|
|
{monthDay?.today && (
|
|
|
|
<div className="absolute top-0 bottom-0 w-[1px] bg-red-500" />
|
2023-05-20 12:00:15 +00:00
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|