import React, { createContext, useReducer } from "react";
import { useDataReducer } from "../useReducer/reducers";

const initialState = {
  cases: [{}],
};

const DataContext = createContext({
  state: initialState,
  dispatch: () => null,
});

const DataProvider = ({ children }) => {
  const [dataState, dataDispatch] = useReducer(useDataReducer, initialState);
  return (
    <DataContext.Provider value={{ dataState, dataDispatch }}>
      {children}
    </DataContext.Provider>
  );
};

export { DataContext, DataProvider };
