From 5f9dfb76e70818b908bff060ba0c7575a0cb6db4 Mon Sep 17 00:00:00 2001 From: regalijan Date: Thu, 19 Oct 2023 16:49:44 -0400 Subject: [PATCH] Handle upload failures --- components/NewGameBan.tsx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/components/NewGameBan.tsx b/components/NewGameBan.tsx index 34e3128..c17aad0 100644 --- a/components/NewGameBan.tsx +++ b/components/NewGameBan.tsx @@ -152,6 +152,24 @@ export default function (props: { isOpen: boolean; onClose: () => void }) { }, method: "PUT", }); + + if (!fileUpload.ok) { + await fetch("/api/reports/recall", { + body: JSON.stringify({ id }), + headers: { + "content-type": "application/json", + }, + method: "POST", + }); + + useToast()({ + description: "Failed to upload file", + status: "error", + title: "Error", + }); + + return; + } } return (