plane/web/components/gantt-chart/contexts/index.tsx
Aaryan Khandelwal ba6479674c
[WEB-306] fix: Gantt chart bugs, refactor Gantt context (#3775)
* chore: initialize gantt layout store

* fix: modules being refetched on creation

* fix: scrollLeft calculation logic

* chore: modules list item dropdown position

* refactor: active block logic

* refactor: main content block component

* chore: remove unnecessary conditions for duration
2024-02-23 19:10:45 +05:30

20 lines
651 B
TypeScript

import { createContext } from "react";
// mobx store
import { GanttStore } from "store/issue/issue_gantt_view.store";
let ganttViewStore = new GanttStore();
export const GanttStoreContext = createContext<GanttStore>(ganttViewStore);
const initializeStore = () => {
const _ganttStore = ganttViewStore ?? new GanttStore();
if (typeof window === "undefined") return _ganttStore;
if (!ganttViewStore) ganttViewStore = _ganttStore;
return _ganttStore;
};
export const GanttStoreProvider = ({ children }: any) => {
const store = initializeStore();
return <GanttStoreContext.Provider value={store}>{children}</GanttStoreContext.Provider>;
};