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

interface RequestContextProps {
  requestSession: any;
  setRequestSession: (requestSession: any) => void;
}

const RequestContext = createContext<RequestContextProps>({
  requestSession: {},
  setRequestSession: () => {},
});

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

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

export { useRequests, RequestProvider };
