"use client"; import { FormEvent, useEffect, useState } from "react"; export default function LinkDevicePage() { const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [code, setCode] = useState(""); const [busy, setBusy] = useState(false); const [err, setErr] = useState(null); const [ok, setOk] = useState(null); useEffect(() => { const q = new URLSearchParams(window.location.search); const c = q.get("code"); if (c) setCode(c.toUpperCase()); }, []); async function onSubmit(e: FormEvent) { e.preventDefault(); setBusy(true); setErr(null); setOk(null); try { const res = await fetch("/api/v1/link/claim", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ email, password, code }), }); const data = await res.json().catch(() => ({})); if (!res.ok) { setErr(data.error?.message ?? "Koppelen mislukt"); return; } setOk(`Apparaat “${data.deviceName ?? "TV"}” is gekoppeld. Je kunt dit venster sluiten.`); setPassword(""); } finally { setBusy(false); } } return (

VMC

Apparaat koppelen

Log in met je kijker-account en voer de code van je TV of telefoon in.

{err &&

{err}

} {ok &&

{ok}

}
); }