"use client"; import { useState, useEffect } from "react"; import { useRouter } from "next/navigation"; import { useAuth } from "../../hooks/useAuth"; import { useClients } from "../../hooks/useClients"; import { useCountries } from "../../hooks/useCountries"; import Sidebar from "../../components/Sidebar"; import Header from "../../components/Header"; import { checkupAPI, clientAPI } from "../../lib/api"; import { toast } from "react-toastify"; import { Activity, Play, Loader2, Monitor, AlertCircle } from "lucide-react"; export default function CheckupPage() { const router = useRouter(); const { user, loading } = useAuth(); const { clients } = useClients({ status: "active", limit: 100 }); const { countries } = useCountries(true); const [running, setRunning] = useState(false); const [selectedClient, setSelectedClient] = useState(""); const [selectedCountry, setSelectedCountry] = useState(""); const [logs, setLogs] = useState([]); useEffect(() => { if (!loading && !user) router.push("/login"); }, [user, loading, router]); const handleRunCheckup = async () => { if (!selectedClient || !selectedCountry) { toast.error("Select a client and country"); return; } setRunning(true); setLogs([]); try { setLogs((prev) => [...prev, "Starting checkup session..."]); const { data } = await checkupAPI.run({ client_id: selectedClient, country_id: selectedCountry }); setLogs((prev) => [...prev, "Checkup completed!", `Available dates: ${data.data?.available_dates?.length || 0} found`]); toast.success("Checkup completed successfully"); } catch (error: any) { const msg = error.response?.data?.message || "Checkup failed"; setLogs((prev) => [...prev, `Error: ${msg}`]); toast.error(msg); } finally { setRunning(false); } }; if (loading || !user) return null; return (

Checkup Mode

Check visa appointment availability

{/* Control Panel */}

Run Checkup

{countries.map((c: any) => ( ))}
{/* Logs Panel */}

Session Logs

{logs.length === 0 ? (

No logs yet. Start a checkup to see logs here.

) : ( logs.map((log, i) => (
[{new Date().toLocaleTimeString()}] {log}
)) )}
{/* Info Cards */}

Automated Checkup

Uses Playwright to navigate VFS websites and check for available appointment slots.

Real-time Monitoring

Screenshots are captured during the checkup process for verification.

Session Logging

All actions are logged and stored for audit and debugging purposes.

); }