import { useWebAuth } from "@code/auth/web";
import { Navigate, Outlet } from "react-router";

export default function AuthLayout() {
  const auth = useWebAuth();

  if (auth.status === "loading") {
    return (
      <div className="grid min-h-svh place-items-center text-sm text-muted-foreground">
        Loading…
      </div>
    );
  }

  if (auth.status === "authenticated") {
    return <Navigate replace to="/" />;
  }

  return (
    <main className="grid min-h-svh place-items-center bg-muted/30 p-6 md:p-10">
      <div className="w-full max-w-sm">
        <Outlet />
      </div>
    </main>
  );
}
