Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
"Finish" this atrocity
  • Loading branch information
Regalijan authored and Regalijan committed Oct 23, 2023
1 parent 6ca0e70 commit 58f83d2
Showing 1 changed file with 95 additions and 16 deletions.
111 changes: 95 additions & 16 deletions app/routes/me.tsx
Expand Up @@ -45,22 +45,29 @@ export async function loader({ context }: { context: RequestContext }) {

const settledPromises = await Promise.allSettled(d1Promises);

return settledPromises.filter((p) => {
if (p.status === "fulfilled") return p.value.results;
const data = {
items: settledPromises.filter((p) => {
if (p.status === "fulfilled") return p.value.results;

return null;
}) as any as ({ [k: string]: any }[] | null)[];
return null;
}) as any as ({ [k: string]: any }[] | null)[],
permissions: currentUser.permissions as number,
};

return data;
}

export default function () {
const data: ({ [k: string]: any }[] | null)[] =
useLoaderData<typeof loader>();
const data: {
items: ({ [k: string]: any }[] | null)[];
permissions: number;
} = useLoaderData<typeof loader>();
const timeStates: {
[k: number]: { data: string; set: Dispatch<SetStateAction<string>> };
} = {};
const toast = useToast();

for (const result of data) {
for (const result of data.items) {
if (!result) continue;

for (const row of result) {
Expand Down Expand Up @@ -231,7 +238,7 @@ export default function () {
<br />
<br />
<Heading size="lg">Discord Appeals</Heading>
<TableContainer>
<TableContainer mb="16px">
<Table variant="simple">
<Thead>
<Tr>
Expand All @@ -242,32 +249,104 @@ export default function () {
</Tr>
</Thead>
<Tbody>
{data[0]
? data[0].map((result) => {
{data.items[0]?.map((result) => {
return (
<Tr>
<Td>{timeStates[result.created_at].data}</Td>
<Td>{result.id}</Td>
<Td>
{result.open
? "Pending"
: typeof result.approved === "boolean"
? `${result.approved ? "Accepted" : "Denied"}`
: "Unknown"}
</Td>
<Td>
<Button
onClick={async () => await fetchItem(result.id, "appeal")}
>
View
</Button>
</Td>
</Tr>
);
})}
</Tbody>
</Table>
</TableContainer>
<br />
{[1 << 2, 1 << 3, 1 << 9, 1 << 10].find((p) => data.permissions & p) ? (
<>
<Heading size="lg">Inactivity Notices</Heading>
<TableContainer mb="16px">
<Table variant="simple">
<Thead>
<Tr>
<Th>Date</Th>
<Th>ID</Th>
<Th>Status</Th>
<Th>View</Th>
</Tr>
</Thead>
<Tbody>
{data.items[1]?.map((result) => {
return (
<Tr>
<Td>{timeStates[result.created_at].data}</Td>
<Td>{result.id}</Td>
<Td>
{result.open
? "Pending"
: typeof result.approved === "boolean"
? `${result.approved ? "Accepted" : "Denied"}`
: "Unknown"}
: Object.values(result.decisions).find((d) => !d)
? "Denied"
: "Approved"}
</Td>
<Td>
<Button
onClick={async () =>
await fetchItem(result.id, "appeal")
await fetchItem(result.id, "inactivity")
}
>
View
</Button>
</Td>
</Tr>
);
})
: undefined}
})}
</Tbody>
</Table>
</TableContainer>
<br />
</>
) : null}
<Heading size="lg">Reports</Heading>
<TableContainer>
<Table variant="simple">
<Thead>
<Tr>
<Th>Date</Th>
<Th>ID</Th>
<Th>Status</Th>
<Th>View</Th>
</Tr>
</Thead>
<Tbody>
{data.items[2]?.map((result) => {
return (
<Tr>
<Td>{timeStates[result.created_at].data}</Td>
<Td>{result.id}</Td>
<Td>{result.open ? "Pending" : "Reviewed"}</Td>
<Td>
<Button
onClick={async () => await fetchItem(result.id, "report")}
>
View
</Button>
</Td>
</Tr>
);
})}
</Tbody>
</Table>
</TableContainer>
Expand Down

0 comments on commit 58f83d2

Please sign in to comment.