'use client' import { useState } from 'react' import { useRouter } from 'next/navigation' import Link from 'next/link' import { authAPI } from '@/lib/api' import { saveAuth } from '@/lib/auth' import { Button } from '@/components/ui/button' import { Input } from '@/components/ui/input' import { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter } from '@/components/ui/card' export default function LoginPage() { const router = useRouter() const [email, setEmail] = useState('') const [password, setPassword] = useState('') const [error, setError] = useState('') const [loading, setLoading] = useState(false) const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() setError('') setLoading(true) try { const data = await authAPI.login(email, password) saveAuth(data.token, data.user) router.push('/dashboard') } catch (err: any) { setError(err.response?.data?.message || 'Failed to login') } finally { setLoading(false) } } return (
{/* Subtle Background Pattern */}
Welcome back Sign in to your Website Monitor account
{error && (
{error}
)}
setEmail(e.target.value)} placeholder="you@example.com" required />
setPassword(e.target.value)} placeholder="••••••••" required />
Forgot password?

Don't have an account?{' '} Create account

) }