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

const RequestContext = createContext<{
  // TODO: Remove any type
  requestSession: any;
  setRequestSession: (requestSession: any) => void;
}>({
  requestSession: {},
  setRequestSession: () => {},
});

const useRequests = () => {
  const requestContext = useContext(RequestContext);
  return requestContext;
};

const RequestProvider = ({ children }: { children: any }) => {
  const [requestSession, setRequestSession] = useState<any>({});
  return (
    <RequestContext.Provider
      value={{
        requestSession,
        setRequestSession,
      }}>
      {children}
    </RequestContext.Provider>
  );
};

export { useRequests, RequestProvider };
