import { createContext, useContext } from "react";

interface OAuthContextValues {
  active: boolean;
  clientID: string;
  redirectURI: string;
  scope: string[];
  state: string;
  nonce: string;
  setActive: (state: boolean) => void;
  setClientID: (id: string) => void;
  setRedirectURI: (uri: string) => void;
  setScope: (scopes: string[]) => void;
  setState: (state: string) => void;
  setNonce: (nonce: string) => void;
  selectSession: (token: string) => Promise<void>;
}

export const OAuthContext = createContext<OAuthContextValues>({
  active: false,
  clientID: "",
  redirectURI: "",
  scope: [],
  state: "",
  nonce: "",
  setActive: () => {},
  setClientID: () => {},
  setRedirectURI: () => {},
  setScope: () => {},
  setState: () => {},
  setNonce: () => {},
  selectSession: async () => {},
});

export const useOAuthContext = () => useContext(OAuthContext);
