import { createContext, useContext, useRef, useState } from "react";
const preview = {
categoryGroup: {},
groupTasks: [],
groupTasksSteps: [],
startGroupTasksOpenModalRememberIdRef: null,
paginationPage: 1,
totalPages: 0,
previousParamCategory: null,
paginationPageRef: null,
selectInputs: {},
};
const GroupTasksContext = createContext(preview);
export const useGroupTasksContext = () => useContext(GroupTasksContext);
export function GroupTasksProvider({ children }) {
// will be set on open a category on side menu
const [categoryGroup, setCategoryGroup] = useState({});
// will be set on open a category on side menu - shown on the table
const [groupTasks, setGroupTasks] = useState([]);
// will be set on viewing the steps of a group task
const [groupTasksSteps, setGroupTasksSteps] = useState([]);
const startGroupTasksOpenModalRememberIdRef = useRef(null);
// pagination
const [paginationPage, setPaginationPage] = useState(1);
const paginationPageRef = useRef(paginationPage);
const [totalPages, setTotalPages] = useState(0);
const previousParamCategory = useRef(null);
// this is used for the inputs as there is no way to manipulate the select value via the DOM (like we do on the text inputs) as it is needed by the websocket
const [selectInputs, setSelectInputs] = useState({});
return (
{children}
);
}