import { useState, type ReactNode } from "react";
import type { NPEDUser, ReducedSightingType } from "../../types/types";
import { NPEDUserContext } from "../NPEDUserContext";

type NPEDUserProviderType = {
  children: ReactNode;
};

export const NPEDUserProvider = ({ children }: NPEDUserProviderType) => {
  const [user, setUser] = useState<NPEDUser | null>(null);
  const [sessionStarted, setSessionStarted] = useState(false);
  const [sessionList, setSessionList] = useState<ReducedSightingType[]>([]);

  return (
    <NPEDUserContext.Provider
      value={{
        user,
        setUser,
        setSessionStarted,
        sessionStarted,
        sessionList,
        setSessionList,
      }}
    >
      {children}
    </NPEDUserContext.Provider>
  );
};
