"use client";

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

type AuthContextType = {
  did: string | null;
};

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

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

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