"use client";

import { useAuth } from "@/lib/auth-context";
import { Loader2 } from "lucide-react";

interface AuthLoadingProps {
  children: React.ReactNode;
}

export function AuthLoading({ children }: AuthLoadingProps) {
  const { isLoading } = useAuth();

  if (isLoading) {
    return (
      <div className="flex min-h-screen flex-col items-center justify-center p-4 text-center">
        <Loader2 className="mb-4 h-8 w-8 animate-spin text-primary" />
        <h1 className="mb-2 text-xl font-semibold">Chargement...</h1>
        <p className="text-muted-foreground">Veuillez patienter pendant que nous vérifions votre authentification.</p>
      </div>
    );
  }

  return <>{children}</>;
}