Fix potential hook issue
This commit is contained in:
parent
cb5aea2832
commit
d8bf398ed4
@ -27,6 +27,7 @@ export default function (props: AppealCardProps) {
|
|||||||
);
|
);
|
||||||
const [action, setAction] = useState("");
|
const [action, setAction] = useState("");
|
||||||
const [feedback, setFeedback] = useState("");
|
const [feedback, setFeedback] = useState("");
|
||||||
|
const toast = useToast();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setDateString(new Date(props.created_at).toLocaleString());
|
setDateString(new Date(props.created_at).toLocaleString());
|
||||||
@ -49,7 +50,7 @@ export default function (props: AppealCardProps) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (actionReq.ok) {
|
if (actionReq.ok) {
|
||||||
useToast()({
|
toast({
|
||||||
description: `Appeal ${action === "accept" ? "accepted" : "denied"}`,
|
description: `Appeal ${action === "accept" ? "accepted" : "denied"}`,
|
||||||
duration: 5000,
|
duration: 5000,
|
||||||
status: "success",
|
status: "success",
|
||||||
@ -57,14 +58,16 @@ export default function (props: AppealCardProps) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById(`appeal_${props.id}`)?.remove();
|
document.getElementById(`appeal_${props.id}`)?.remove();
|
||||||
|
} else {
|
||||||
|
toast({
|
||||||
|
description: ((await actionReq.json()) as { error: string }).error,
|
||||||
|
duration: 10000,
|
||||||
|
status: "error",
|
||||||
|
title: "Oops!",
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
useToast()({
|
onClose();
|
||||||
description: ((await actionReq.json()) as { error: string }).error,
|
|
||||||
duration: 10000,
|
|
||||||
status: "error",
|
|
||||||
title: "Oops!",
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user