import React, { createContext, useContext, useState, useEffect } from "react";

//create context
const MasterDataContext = createContext();

//custom hoo to use master data
export const useMasterData = () => {
  return useContext(MasterDataContext);
};

//context provider
export const MasterDataProvider = ({ children }) => {
  const [masterData, setMasterData] = useState({
    categories: [],
    priorities: [],
  });

  useEffect(() => {
    //fetch MasterData from API

    const fetchMasterData = async () => {
      try {
        // const response = await axiosClient.get("/api/project/list"); // Replace with your API URL
        // let projects = response.data;
        // setMasterData({ categories: [], priorities: [], projects: projects });
      } catch (err) {
        //setError("Failed to fetch data.");
      } finally {
        //setLoading(false);
      }
    };

    fetchMasterData();
  }, []);

  return <MasterDataContext.Provider>{children}</MasterDataContext.Provider>;
};
