import { useState } from 'react'; import { Link, useNavigate } from 'react-router-dom'; import { useForm } from 'react-hook-form'; import { zodResolver } from '@hookform/resolvers/zod'; import { z } from 'zod'; import { useAuthStore } from '../../store/authStore'; import { Button, Input, Card, CardHeader, CardTitle, CardContent } from '../ui'; import { Eye, EyeOff, MessageSquare } from 'lucide-react'; import toast from 'react-hot-toast'; import { login } from '../../services/authService'; const loginSchema = z.object({ email: z.string().email('Please enter a valid email address'), password: z.string().min(6, 'Password must be at least 6 characters'), }); type LoginFormData = z.infer; export function LoginForm() { const navigate = useNavigate(); const { login: loginUser, setLoading } = useAuthStore(); const [showPassword, setShowPassword] = useState(false); const { register, handleSubmit, formState: { errors, isSubmitting }, } = useForm({ resolver: zodResolver(loginSchema), }); const onSubmit = async (data: LoginFormData) => { try { setLoading(true); const response = await login(data); loginUser(response.user, response.token); toast.success('Welcome back!'); navigate('/chat'); } catch (error: any) { toast.error(error.message || 'Login failed'); } finally { setLoading(false); } }; return (

Welcome back

Sign in to your account to continue

Sign In

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

); }