2024-02-23 13:40:45 +00:00
|
|
|
import { createContext } from "react";
|
|
|
|
// mobx store
|
|
|
|
import { GanttStore } from "store/issue/issue_gantt_view.store";
|
2023-05-20 12:00:15 +00:00
|
|
|
|
2024-02-23 13:40:45 +00:00
|
|
|
let ganttViewStore = new GanttStore();
|
2023-05-20 12:00:15 +00:00
|
|
|
|
2024-02-23 13:40:45 +00:00
|
|
|
export const GanttStoreContext = createContext<GanttStore>(ganttViewStore);
|
2023-08-28 07:55:47 +00:00
|
|
|
|
2024-02-23 13:40:45 +00:00
|
|
|
const initializeStore = () => {
|
|
|
|
const _ganttStore = ganttViewStore ?? new GanttStore();
|
|
|
|
if (typeof window === "undefined") return _ganttStore;
|
|
|
|
if (!ganttViewStore) ganttViewStore = _ganttStore;
|
|
|
|
return _ganttStore;
|
|
|
|
};
|
2023-08-28 07:55:47 +00:00
|
|
|
|
2024-02-23 13:40:45 +00:00
|
|
|
export const GanttStoreProvider = ({ children }: any) => {
|
|
|
|
const store = initializeStore();
|
|
|
|
return <GanttStoreContext.Provider value={store}>{children}</GanttStoreContext.Provider>;
|
2023-05-20 12:00:15 +00:00
|
|
|
};
|