'use client'; import { useState, useEffect } from 'react'; import Link from 'next/link'; export default function Home() { const [loggedIn, setLoggedIn] = useState(false); const [password, setPassword] = useState(''); useEffect(() => { if (localStorage.getItem('auth')) setLoggedIn(true); }, []); const handleLogin = async () => { const response = await fetch('/api/auth', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ password }), }); if (response.ok) { const auth = btoa(`admin:${password}`); localStorage.setItem('auth', auth); setLoggedIn(true); } else { alert('Wrong password'); } }; if (!loggedIn) { return (