From d8bf398ed409468e461c62ffd373212f57470d89 Mon Sep 17 00:00:00 2001 From: regalijan Date: Thu, 19 Oct 2023 16:50:41 -0400 Subject: [PATCH] Fix potential hook issue --- components/AppealCard.tsx | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/components/AppealCard.tsx b/components/AppealCard.tsx index d7f8d48..e1f6816 100644 --- a/components/AppealCard.tsx +++ b/components/AppealCard.tsx @@ -27,6 +27,7 @@ export default function (props: AppealCardProps) { ); const [action, setAction] = useState(""); const [feedback, setFeedback] = useState(""); + const toast = useToast(); useEffect(() => { setDateString(new Date(props.created_at).toLocaleString()); @@ -49,7 +50,7 @@ export default function (props: AppealCardProps) { }); if (actionReq.ok) { - useToast()({ + toast({ description: `Appeal ${action === "accept" ? "accepted" : "denied"}`, duration: 5000, status: "success", @@ -57,14 +58,16 @@ export default function (props: AppealCardProps) { }); document.getElementById(`appeal_${props.id}`)?.remove(); + } else { + toast({ + description: ((await actionReq.json()) as { error: string }).error, + duration: 10000, + status: "error", + title: "Oops!", + }); } - useToast()({ - description: ((await actionReq.json()) as { error: string }).error, - duration: 10000, - status: "error", - title: "Oops!", - }); + onClose(); } return (