"use client"; import { useState } from "react"; import { useRouter } from "next/navigation"; import { authAPI } from "../../lib/api"; import { setAuth } from "../../lib/auth"; import { toast } from "react-toastify"; import { Globe, Loader2 } from "lucide-react"; export default function LoginPage() { const router = useRouter(); const [isLogin, setIsLogin] = useState(true); const [loading, setLoading] = useState(false); const [form, setForm] = useState({ email: "", password: "", first_name: "", last_name: "" }); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setLoading(true); try { const res = isLogin ? await authAPI.login(form.email, form.password) : await authAPI.register(form); const { token, user } = res.data.data; setAuth(token, user); toast.success(isLogin ? "Welcome back!" : "Account created!"); router.push("/dashboard"); } catch (error: any) { toast.error(error.response?.data?.message || "Authentication failed"); } finally { setLoading(false); } }; return (
Visa Operations Platform
Default admin: admin@tinovisas.com / Admin123!