bb-plane-fork/web/core/hooks/use-timeline-chart.ts
rahulramesha a88a39fb1e
[WEB-2442] feat: Revamp Timeline Layout (#5915)
* chore: added issue relations in issue listing

* chore: added pagination for issue detail endpoint

* chore: bulk date update endpoint

* chore: appended the target date

* chore: issue relation new types defined

* fix: order by and issue filters

* fix: passed order by in pagination

* chore: changed the key for issue dates

* Revamp Timeline Layout

* fix block dragging

* minor ui fixes

* improve auto scroll UX

* remove unused import

* fix timeline layout heights

* modify base timeline store

* Segregate issue relation types

---------

Co-authored-by: NarayanBavisetti <narayan3119@gmail.com>
2024-10-28 18:03:31 +05:30

26 lines
965 B
TypeScript

import { useContext } from "react";
// mobx store
// types
import { StoreContext } from "@/lib/store-context";
import { IBaseTimelineStore } from "ee/store/timeline/base-timeline.store";
import { ETimeLineTypeType, useTimeLineType } from "../components/gantt-chart/contexts";
export const useTimeLineChart = (timeLineType: ETimeLineTypeType): IBaseTimelineStore => {
const context = useContext(StoreContext);
if (context === undefined) 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;
}
};
export const useTimeLineChartStore = () => {
const timelineType = useTimeLineType();
if (!timelineType) throw new Error("useTimeLineChartStore must be used within TimeLineTypeContext");
return useTimeLineChart(timelineType);
};