'use client'; import { useState, useEffect } from 'react'; import { useRouter, useSearchParams } from 'next/navigation'; import Link from 'next/link'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { authApi } from '@/lib/api'; import { useNotification } from '@/components/shared/NotificationContext'; export default function LoginPage() { const router = useRouter(); const searchParams = useSearchParams(); const { showNotification } = useNotification(); const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [error, setError] = useState(''); const [isLoading, setIsLoading] = useState(false); useEffect(() => { // Check if the user was redirected from signup if (searchParams.get('signup') === 'success') { showNotification('success', 'Account created successfully! Please log in.'); } }, [searchParams, showNotification]); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setError(''); setIsLoading(true); try { await authApi.login(email, password); showNotification('success', 'Logged in successfully!'); router.push('/dashboard'); } catch (err: any) { setError(err.message || 'Login failed'); } finally { setIsLoading(false); } }; return (