Fix invalid hook call

This commit is contained in:
regalijan 2023-10-19 16:50:18 -04:00
parent dc8aae170b
commit afa5a4b764
Signed by: regalijan
GPG Key ID: 5D4196DA269EF520

View File

@ -27,6 +27,7 @@ import { useState } from "react";
export default function (props: { isOpen: boolean; onClose: () => void }) { export default function (props: { isOpen: boolean; onClose: () => void }) {
const actionMap: { [k: string]: number } = {}; const actionMap: { [k: string]: number } = {};
const [rows, setRows] = useState([] as JSX.Element[]); const [rows, setRows] = useState([] as JSX.Element[]);
const toast = useToast();
const fileTypes: { [k: string]: string } = { const fileTypes: { [k: string]: string } = {
gif: "image/gif", gif: "image/gif",
heic: "image/heic", heic: "image/heic",
@ -67,7 +68,7 @@ export default function (props: { isOpen: boolean; onClose: () => void }) {
<Td> <Td>
<Link onClick={() => removeUser(user)}>Remove</Link> <Link onClick={() => removeUser(user)}>Remove</Link>
</Td> </Td>
</Tr> </Tr>,
); );
} }
@ -130,7 +131,7 @@ export default function (props: { isOpen: boolean; onClose: () => void }) {
}); });
if (!submitReq.ok) { if (!submitReq.ok) {
useToast()({ toast({
description: ((await submitReq.json()) as { error: string }).error, description: ((await submitReq.json()) as { error: string }).error,
status: "error", status: "error",
title: "Failed to submit report", title: "Failed to submit report",
@ -162,7 +163,7 @@ export default function (props: { isOpen: boolean; onClose: () => void }) {
method: "POST", method: "POST",
}); });
useToast()({ toast({
description: "Failed to upload file", description: "Failed to upload file",
status: "error", status: "error",
title: "Error", title: "Error",
@ -179,7 +180,7 @@ export default function (props: { isOpen: boolean; onClose: () => void }) {
method: "POST", method: "POST",
}); });
useToast()({ toast({
description: "User moderated", description: "User moderated",
status: "success", status: "success",
title: "Success", title: "Success",
@ -209,7 +210,7 @@ export default function (props: { isOpen: boolean; onClose: () => void }) {
0 > 1 || 0 > 1 ||
user.match(/\W/) user.match(/\W/)
) { ) {
useToast()({ toast({
description: "Check the username and try again", description: "Check the username and try again",
duration: 5000, duration: 5000,
isClosable: true, isClosable: true,