diff --git a/app/routes/report.tsx b/app/routes/report.tsx index c5ffb9a..873eaec 100644 --- a/app/routes/report.tsx +++ b/app/routes/report.tsx @@ -66,6 +66,8 @@ export default function () { ); }, []); + const { logged_in, site_key } = useLoaderData(); + async function submit() { const usernames = ( document.getElementById("usernames") as HTMLInputElement @@ -112,13 +114,21 @@ export default function () { method: "POST", }); - if (!submitReq.ok) + if (!submitReq.ok) { + if (!logged_in) { + try { + // @ts-expect-error + turnstile.reset(); + } catch {} + } + return toast({ description: ((await submitReq.json()) as { error: string }).error, isClosable: true, status: "error", title: "Error", }); + } const { id, upload_url }: { id: string; upload_url: string } = await submitReq.json(); @@ -181,8 +191,6 @@ export default function () { sessionStorage.setItem("REPORT_SUCCESS", "1"); } - const { logged_in, site_key } = useLoaderData(); - useEffect(() => { if (logged_in) return;