// verify.jsx — Certificate Verification page (wired to the WordPress REST API) (function () { const { useState, useEffect, useRef } = React; const Icon = window.Icon; const { PageHero } = window; const STATUS_META = { valid: { cls: "status-valid", label: "Valid", icon: "shield", color: "var(--ok)", bg: "var(--ok-bg)", msg: "This is a genuine, active INFOTECH certificate." }, expired: { cls: "status-expired", label: "Expired", icon: "clock", color: "var(--warn)", bg: "var(--warn-bg)", msg: "This certificate is genuine but has passed its validity period." }, cancelled: { cls: "status-cancelled", label: "Cancelled", icon: "close", color: "var(--bad)", bg: "var(--bad-bg)", msg: "This certificate has been revoked and is no longer valid." }, }; function ResultRow({ label, value, strong }) { return (
{label} {value}
); } function Verify({ navigate, prefill }) { const [query, setQuery] = useState(prefill || ""); const [state, setState] = useState("idle"); // idle | loading | found | notfound | error const [record, setRecord] = useState(null); const [touched, setTouched] = useState(false); const resultRef = useRef(null); const run = (value) => { const v = (value ?? query).trim(); setTouched(true); if (!v) { setState("idle"); return; } setState("loading"); setRecord(null); window.api("verify?q=" + encodeURIComponent(v)).then((res) => { if (res.ok && res.data && res.data.found) { setRecord(res.data.record); setState("found"); } else if (res.ok) { setState("notfound"); } else { setState("error"); } }); }; useEffect(() => { if (prefill && prefill.trim()) run(prefill); /* eslint-disable-next-line */ }, []); useEffect(() => { if ((state === "found" || state === "notfound") && resultRef.current) { resultRef.current.scrollTop; // reflow } }, [state]); const onSubmit = (e) => { e.preventDefault(); run(); }; const meta = record ? (STATUS_META[record.status] || STATUS_META.valid) : null; const download = () => { if (record.certFileUrl) { window.open(record.certFileUrl, "_blank"); return; } window.makeCertPDF(record); }; return (
{/* search card */}

Enter certificate details

Use the Certificate ID or Registration Number printed on the document.

setQuery(e.target.value)} style={{ paddingLeft: 46 }} />
{touched && !query.trim() && state !== "loading" && Please enter a Certificate ID or Registration Number.}
{/* sample hint */}
Try a sample:{" "} {["INFO-2025-GD-0142", "INF-24-2098", "INFO-2023-AV-0307", "INFO-2024-PS-0233"].map((s, i) => ( {i < 3 ? " · " : ""} ))}
{/* results */}
{state === "loading" && (

Searching the certificate registry…

)} {state === "error" && (

Something went wrong

We couldn't reach the verification service. Please check your connection and try again.

)} {state === "notfound" && (

Certificate not found

Please check your Certificate ID or Registration Number and try again. If the problem continues, contact the institute.

)} {state === "found" && record && (
{/* result header */}
Verification Result

{record.name}

{meta.label}

{meta.msg}

{record.status !== "cancelled" ? ( ) : ( Certificate download is disabled for cancelled records )}
)}
{/* trust note */}
Secure, read-only verification — your search is not stored.
); } window.Verify = Verify; })();