Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix potential hook issue
  • Loading branch information
regalijan committed Oct 19, 2023
1 parent cb5aea2 commit d8bf398
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions components/AppealCard.tsx
Expand Up @@ -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());
Expand All @@ -49,22 +50,24 @@ export default function (props: AppealCardProps) {
});

if (actionReq.ok) {
useToast()({
toast({
description: `Appeal ${action === "accept" ? "accepted" : "denied"}`,
duration: 5000,
status: "success",
title: "Success",
});

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 (
Expand Down

0 comments on commit d8bf398

Please sign in to comment.