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, Eye, EyeOff } from "lucide-react"; import { motion } from "framer-motion"; import { useToast } from "../hooks/use-toast"; 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 { success, error: toastError } = useToast(); const [error, setError] = useState(null); const [showPassword, setShowPassword] = useState(false); 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); success("Successfully signed in", `Welcome back, ${response.user.email}!`); if (response.user.role === "ADMIN") { navigate("/admin"); } else { navigate("/client"); } } catch (err: any) { const errMsg = err.response?.data?.error || "Authentication failed. Verify credentials."; setError(errMsg); toastError("Authentication failed", errMsg); } }; return (
{/* Monochromatic Soft Background Blurs */}
{/* Spacer to push content down slightly on desktop for better centering */}
{/* Left Column - Partner Explanation */}

Tech4Biz Channel Partner

Expand your business by partnering with Tech4Biz and unlock new opportunities for growth through our innovative technology solutions. Join our partner network to access exclusive resources, dedicated support, and a platform designed to help you succeed.

{/* Right Column - Login Component */}

Channel Portal

Authorized Access Only

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

{errors.email.message}

)}
RECOVERY?
{errors.password && (

{errors.password.message}

)}

© 2026 Tech4Biz Solutions.

); }; export default LoginPage;