// ───────────────────────────────────────────────────────────── // Login Page // ───────────────────────────────────────────────────────────── 'use client'; import { useState } from 'react'; import Link from 'next/link'; import { useRouter } from 'next/navigation'; import { Code2, Eye, EyeOff } from 'lucide-react'; import { authApi } from '../../../lib/api'; import { useAuthStore } from '../../../stores/authStore'; export default function LoginPage() { const router = useRouter(); const { setAuth } = useAuthStore(); const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [showPassword, setShowPassword] = useState(false); const [error, setError] = useState(''); const [isLoading, setIsLoading] = useState(false); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setError(''); setIsLoading(true); try { const data = await authApi.login({ email, password }) as any; setAuth(data.user, data.tokens); router.push('/rooms'); } catch (err: any) { setError(err.message || 'Login failed'); } finally { setIsLoading(false); } }; return (
{/* Logo */}

Welcome back

Sign in to your CodeSync account

{/* Form */}
{error && (
{error}
)}
setEmail(e.target.value)} required />
setPassword(e.target.value)} required />
{/* Divider */}
or
{/* Google OAuth */} {/* Sign up link */}

Don't have an account?{' '} Sign up

); }