"use client"; /** 로그인하지 않았으면 화면 대신 로그인만 보여준다 */ import { useState } from "react"; import { usePathname } from "next/navigation"; import GoogleSignIn from "@/components/google-sign-in"; import { signIn, useMe } from "@/lib/auth"; // 완성본 구경은 로그인 없이 연다. 백엔드의 /api/archive 와 같은 규칙 const OPEN_PATHS = ["/archive", "/playreel/archive"]; export default function AuthGate({ children }: { children: React.ReactNode }) { const pathname = usePathname(); const { me, setMe } = useMe(); const [error, setError] = useState(null); if (OPEN_PATHS.some((open) => pathname === open || pathname.startsWith(`${open}/`))) { return <>{children}; } if (me === null) { return

확인하는 중…

; } if (me === false) { return (

로그인이 필요합니다

구글 계정으로 들어와 주세요.

{ setError(null); signIn(credential).then(setMe).catch((failure) => setError((failure as Error).message)); }} /> {error &&

{error}

}
); } return <>{children}; }