'use client'; import { useState, type ReactNode } from 'react'; import Link from 'next/link'; import { User } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; /** * Client component that gates content behind a guest name prompt. * If the user already has a name in localStorage, it skips the gate. * Only renders children after the guest confirms their name. */ export function GuestGate({ children }: { children: ReactNode }) { const [guestName, setGuestName] = useState(() => { if (typeof window === 'undefined') return ''; return localStorage.getItem('openframe_guest_name') ?? ''; }); const [confirmed, setConfirmed] = useState(() => { if (typeof window === 'undefined') return false; return Boolean(localStorage.getItem('openframe_guest_name')); }); if (confirmed) { return <>{children}; } const confirm = () => { if (!guestName.trim()) return; localStorage.setItem('openframe_guest_name', guestName.trim()); setConfirmed(true); }; return (

Welcome to OpenFrame

Enter your name to view and comment on this project

setGuestName(e.target.value)} onKeyDown={(e) => { if (e.key === 'Enter') confirm(); }} autoFocus />

Or{' '} sign in {' '} with your account

); }