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

const DireContext = createContext(undefined);

export const DireProvider = ({ children }) => {
  const [dirActions, setDirActions] = useState([]);

  return (
    <DireContext.Provider value={{ dirActions, setDirActions }}>
      {children}
    </DireContext.Provider>
  );
};

export const useDir = () => {
  const context = useContext(DireContext);
  if (!context) {
    throw new Error("useDir must be used within a <DireProvider>");
  }
  return context;
};
