import { useForm } from 'react-hook-form'; import { zodResolver } from '@hookform/resolvers/zod'; import { z } from 'zod'; import { loginUser } from '../services/auth-api'; import { useAuthStore } from '../hooks/use-auth'; import { useNavigate } from 'react-router-dom'; import { useState } from 'react'; import { Hexagon, Lock, Mail, ArrowRight } from 'lucide-react'; import { motion } from 'framer-motion'; const loginSchema = z.object({ email: z.string().email({ message: 'Invalid email address' }), password: z.string().min(6, { message: 'Password must be at least 6 characters' }), }); type LoginFormValues = z.infer; export const LoginPage = () => { const [error, setError] = useState(null); const setAuth = useAuthStore((state) => state.setAuth); const navigate = useNavigate(); const { register, handleSubmit, formState: { errors, isSubmitting }, } = useForm({ resolver: zodResolver(loginSchema), }); const onSubmit = async (data: LoginFormValues) => { try { setError(null); const response = await loginUser({ email: data.email, password: data.password }); setAuth(response); if (response.user.role === 'ADMIN') { navigate('/admin'); } else { navigate('/client'); } } catch (err: any) { setError(err.response?.data?.error || 'Authentication failed. Verify credentials.'); } }; return (
{/* Monochromatic Soft Background Blurs */}

Channel Portal

Authorized Access Only

{error && (
{error} )}
{errors.email &&

{errors.email.message}

}
RECOVERY?
{errors.password &&

{errors.password.message}

}

© 2026 Tech4Biz Solutions.

); }; export default LoginPage;