"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 (

Tinovisas

Visa Operations Platform

{!isLogin && ( <>
setForm({ ...form, first_name: e.target.value })} className="input w-full" placeholder="John" />
setForm({ ...form, last_name: e.target.value })} className="input w-full" placeholder="Doe" />
)}
setForm({ ...form, email: e.target.value })} className="input w-full" placeholder="admin@tinovisas.com" required />
setForm({ ...form, password: e.target.value })} className="input w-full" placeholder="••••••••" required minLength={6} />

Default admin: admin@tinovisas.com / Admin123!

); }