NOW they should work
This commit is contained in:
parent
8d041df174
commit
de6688891d
@ -12,7 +12,7 @@ import {
|
|||||||
Spacer,
|
Spacer,
|
||||||
Stack,
|
Stack,
|
||||||
Text,
|
Text,
|
||||||
useToast
|
useToast,
|
||||||
} from "@chakra-ui/react";
|
} from "@chakra-ui/react";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
||||||
@ -21,22 +21,22 @@ export default function(props: ReportCardProps) {
|
|||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
const targetMap: { [k: number]: string } = {};
|
const targetMap: { [k: number]: string } = {};
|
||||||
const [attachmentsReady, setAttachmentReady] = useState(
|
const [attachmentsReady, setAttachmentReady] = useState(
|
||||||
!props.attachments_loading
|
!props.attachments_loading,
|
||||||
);
|
);
|
||||||
const actionMap: { [k: number]: number } = {};
|
const actionMap: { [k: number]: number } = {};
|
||||||
|
|
||||||
for (let i = 0; i < props.target_ids.length; i++)
|
for (let i = 0; i < props.target_ids.length; i++)
|
||||||
Object.defineProperty(targetMap, props.target_ids[i], {
|
Object.defineProperty(targetMap, props.target_ids[i], {
|
||||||
value: props.target_usernames[i]
|
value: props.target_usernames[i],
|
||||||
});
|
});
|
||||||
|
|
||||||
async function recheckAttachment() {
|
async function recheckAttachment() {
|
||||||
const attachmentCheck = await fetch("/api/uploads/status", {
|
const attachmentCheck = await fetch("/api/uploads/status", {
|
||||||
body: JSON.stringify(props.attachments),
|
body: JSON.stringify(props.attachments),
|
||||||
headers: {
|
headers: {
|
||||||
"content-type": "application/json"
|
"content-type": "application/json",
|
||||||
},
|
},
|
||||||
method: "POST"
|
method: "POST",
|
||||||
});
|
});
|
||||||
|
|
||||||
setAttachmentReady(attachmentCheck.ok);
|
setAttachmentReady(attachmentCheck.ok);
|
||||||
@ -46,16 +46,16 @@ export default function(props: ReportCardProps) {
|
|||||||
const submitReq = await fetch(`/api/reports/${props.id}/action`, {
|
const submitReq = await fetch(`/api/reports/${props.id}/action`, {
|
||||||
body: JSON.stringify(actionMap),
|
body: JSON.stringify(actionMap),
|
||||||
headers: {
|
headers: {
|
||||||
"content-type": "application/json"
|
"content-type": "application/json",
|
||||||
},
|
},
|
||||||
method: "POST"
|
method: "POST",
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!submitReq.ok) {
|
if (!submitReq.ok) {
|
||||||
toast({
|
toast({
|
||||||
description: (await submitReq.json() as { error: string }).error,
|
description: ((await submitReq.json()) as { error: string }).error,
|
||||||
status: "error",
|
status: "error",
|
||||||
title: "S̸̯̜̈́o̴̳̅̾̏̽m̴͔͕̈́̋ē̴̙͓̯̍̃ț̸͖̘̀h̶̛̳̝̐i̵̋͘͜ņ̷̙̤͌g̴̭̻̓̈́ ̴̘͍̦̪̆w̸̡̏̑̊é̸̠̖̹̂͜n̴̖̳̤̕t̴͚̊̊̕ ̸̛͙̺̬̎́w̴͈͑̋͊r̷̢̛o̵̱̩̍͋ͅṇ̸̝̰̮́g̵̡̢̦͕͂"
|
title: "S̸̯̜̈́o̴̳̅̾̏̽m̴͔͕̈́̋ē̴̙͓̯̍̃ț̸͖̘̀h̶̛̳̝̐i̵̋͘͜ņ̷̙̤͌g̴̭̻̓̈́ ̴̘͍̦̪̆w̸̡̏̑̊é̸̠̖̹̂͜n̴̖̳̤̕t̴͚̊̊̕ ̸̛͙̺̬̎́w̴͈͑̋͊r̷̢̛o̵̱̩̍͋ͅṇ̸̝̰̮́g̵̡̢̦͕͂",
|
||||||
});
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -64,7 +64,7 @@ export default function(props: ReportCardProps) {
|
|||||||
toast({
|
toast({
|
||||||
description: "Actions were successfully applied",
|
description: "Actions were successfully applied",
|
||||||
status: "success",
|
status: "success",
|
||||||
title: "Success"
|
title: "Success",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,7 +163,7 @@ export default function(props: ReportCardProps) {
|
|||||||
name={props.target_ids[i].toString()}
|
name={props.target_ids[i].toString()}
|
||||||
onChange={(val) => {
|
onChange={(val) => {
|
||||||
Object.defineProperty(actionMap, props.target_ids[i], {
|
Object.defineProperty(actionMap, props.target_ids[i], {
|
||||||
value: parseInt(val)
|
value: parseInt(val),
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@ -179,14 +179,19 @@ export default function(props: ReportCardProps) {
|
|||||||
Ban
|
Ban
|
||||||
</Radio>
|
</Radio>
|
||||||
</Stack>
|
</Stack>
|
||||||
</RadioGroup>
|
</RadioGroup>,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return radioGroups;
|
return radioGroups;
|
||||||
})()}
|
})()}
|
||||||
<Box pt="16px">
|
<Box pt="16px">
|
||||||
<Button colorScheme="blue">Submit</Button>
|
<Button
|
||||||
|
colorScheme="blue"
|
||||||
|
onClick={async () => await submitActions()}
|
||||||
|
>
|
||||||
|
Submit
|
||||||
|
</Button>
|
||||||
</Box>
|
</Box>
|
||||||
</Stack>
|
</Stack>
|
||||||
)}
|
)}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user