[WEB-5390] refactor: gantt layout support in base layouts (#8089)
This commit is contained in:
parent
a04d3b5c29
commit
cbfdcd5638
20 changed files with 442 additions and 41 deletions
|
|
@ -1,31 +1,26 @@
|
|||
import { useContext } from "react";
|
||||
// types
|
||||
import type { TTimelineType } from "@plane/types";
|
||||
// lib
|
||||
import { StoreContext } from "@/lib/store-context";
|
||||
// Plane-web
|
||||
import { getTimelineStore } from "@/plane-web/hooks/use-timeline-chart";
|
||||
import type { IBaseTimelineStore } from "@/plane-web/store/timeline/base-timeline.store";
|
||||
//
|
||||
import { ETimeLineTypeType, useTimeLineType } from "../components/gantt-chart/contexts";
|
||||
import { useTimeLineType } from "../components/gantt-chart/contexts";
|
||||
|
||||
export const useTimeLineChart = (timeLineType: ETimeLineTypeType): IBaseTimelineStore => {
|
||||
export const useTimeLineChart = (timelineType: TTimelineType): IBaseTimelineStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useTimeLineChart must be used within StoreProvider");
|
||||
if (!context) throw new Error("useTimeLineChart must be used within StoreProvider");
|
||||
|
||||
switch (timeLineType) {
|
||||
case ETimeLineTypeType.ISSUE:
|
||||
return context.timelineStore.issuesTimeLineStore;
|
||||
case ETimeLineTypeType.MODULE:
|
||||
return context.timelineStore.modulesTimeLineStore as IBaseTimelineStore;
|
||||
case ETimeLineTypeType.PROJECT:
|
||||
return context.timelineStore.projectTimeLineStore as IBaseTimelineStore;
|
||||
case ETimeLineTypeType.GROUPED:
|
||||
return context.timelineStore.groupedTimeLineStore as IBaseTimelineStore;
|
||||
}
|
||||
return getTimelineStore(context.timelineStore, timelineType);
|
||||
};
|
||||
|
||||
export const useTimeLineChartStore = () => {
|
||||
export const useTimeLineChartStore = (): IBaseTimelineStore => {
|
||||
const context = useContext(StoreContext);
|
||||
const timelineType = useTimeLineType();
|
||||
|
||||
if (!context) throw new Error("useTimeLineChartStore must be used within StoreProvider");
|
||||
if (!timelineType) throw new Error("useTimeLineChartStore must be used within TimeLineTypeContext");
|
||||
|
||||
return useTimeLineChart(timelineType);
|
||||
return getTimelineStore(context.timelineStore, timelineType);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue