bb-plane-fork/apps/web/core/hooks/use-timeline-chart.ts
sriram veeraghanta 02d0ee3e0f
chore: add copyright (#8584)
* feat: adding new copyright info on all files

* chore: adding CI
2026-01-27 13:54:22 +05:30

32 lines
1.2 KiB
TypeScript

/**
* Copyright (c) 2023-present Plane Software, Inc. and contributors
* SPDX-License-Identifier: AGPL-3.0-only
* See the LICENSE file for details.
*/
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 { useTimeLineType } from "../components/gantt-chart/contexts";
export const useTimeLineChart = (timelineType: TTimelineType): IBaseTimelineStore => {
const context = useContext(StoreContext);
if (!context) throw new Error("useTimeLineChart must be used within StoreProvider");
return getTimelineStore(context.timelineStore, timelineType);
};
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 getTimelineStore(context.timelineStore, timelineType);
};