"use client"; import { useState } from "react"; import { HugeiconsIcon } from "@hugeicons/react"; import { Clock01Icon, SentIcon } from "@hugeicons/core-free-icons"; export function SubmitTextForm() { const [targetUserId, setTargetUserId] = useState(""); const [text, setText] = useState(""); const [trackingId, setTrackingId] = useState(null); const [error, setError] = useState(null); const [isSubmitting, setSubmitting] = useState(false); const [isFallback, setIsFallback] = useState(false); async function onSubmit(event: React.FormEvent) { event.preventDefault(); setSubmitting(true); setError(null); setTrackingId(null); setIsFallback(false); try { const response = await fetch("/api/analyze/text", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ target_user_id: targetUserId, text }) }); const raw = await response.text(); let body: Record = {}; if (raw) { try { body = JSON.parse(raw) as Record; } catch { body = { error: raw }; } } if (!response.ok) { throw new Error(typeof body.error === "string" ? body.error : "Submission failed"); } setTrackingId(typeof body.tracking_id === "string" ? body.tracking_id : null); setIsFallback(body.fallback === true); setText(""); } catch (err) { setError(err instanceof Error ? err.message : "Submission failed"); } finally { setSubmitting(false); } } return (

Message Risk Scanner

Provide the sender and recipient identifier, along with the message contents to begin risk profiling.

setTargetUserId(event.target.value)} placeholder="recipient@example.com" className="ui-input" required />
{text.length}/5000