'use client' import { useState } from 'react' import { motion, AnimatePresence } from 'framer-motion' import { Lock, Loader2, ArrowLeft, RefreshCw, Calendar, Mail, Globe } from 'lucide-react' import { Button } from '@/components/ui/button' import Link from 'next/link' interface Lead { id: string email: string source: string referrer: string created_at: string } export default function AdminPage() { const [isAuthenticated, setIsAuthenticated] = useState(false) const [password, setPassword] = useState('') const [isLoading, setIsLoading] = useState(false) const [error, setError] = useState('') const [data, setData] = useState<{ total: number; leads: Lead[] } | null>(null) const handleLogin = async (e: React.FormEvent) => { e.preventDefault() setIsLoading(true) setError('') try { const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL || 'http://localhost:3002'}/api/waitlist/admin`, { headers: { 'x-admin-password': password } }) const result = await response.json() if (result.success) { setIsAuthenticated(true) setData(result) } else { setError('Invalid password') } } catch (err) { setError('Connection error') } finally { setIsLoading(false) } } const refreshData = async () => { setIsLoading(true) try { const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL || 'http://localhost:3002'}/api/waitlist/admin`, { headers: { 'x-admin-password': password } }) const result = await response.json() if (result.success) setData(result) } finally { setIsLoading(false) } } // LOGIN SCREEN if (!isAuthenticated) { return (
Back to Website

Admin Access

Enter password to view waitlist

setPassword(e.target.value)} className="w-full h-10 pl-10 pr-4 rounded-lg border border-border bg-background focus:ring-2 focus:ring-primary/20 outline-none transition-all" placeholder="Password" autoFocus />
{error && (
{error}
)}
) } // DASHBOARD return (
{/* Header */}

Waitlist Dashboard

Real-time stats and signups

{/* Stats Cards */}

Total Signups

{data?.total || 0}

Latest Signup

{data?.leads[0]?.email || 'N/A'}
{data?.leads[0] ? new Date(data.leads[0].created_at).toLocaleString() : '-'}
{/* Listings Table */}

Recent Signups

{data?.leads.map((lead) => ( ))} {data?.leads.length === 0 && ( )}
Email Source Date
{lead.email} {lead.source} {lead.referrer && via {new URL(lead.referrer).hostname}} {new Date(lead.created_at).toLocaleString()}
No signups yet.
) }