"use client";

import { createContext, useContext, ReactNode } from "react";

type AuthContextType = {
  didPromise: Promise<string | null>;
};

const AuthContext = createContext<AuthContextType | null>(null);

export function AuthProvider({
  children,
  didPromise,
}: {
  children: ReactNode;
  didPromise: Promise<string | null>;
}) {
  return <AuthContext.Provider value={{ didPromise }}>{children}</AuthContext.Provider>;
}

export function useAuthContext() {
  const context = useContext(AuthContext);
  if (!context) {
    throw new Error("useLoginModal must be used within a AuthProvider");
  }
  return context;
}
