Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Properly add appeal ban data to popup
  • Loading branch information
regalijan committed Mar 12, 2025
1 parent bbc3adf commit cb6c835
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion components/AppealBans.tsx
Expand Up @@ -19,13 +19,32 @@ import {
} from "@chakra-ui/react";
import { useEffect, useState } from "react";
import NewAppealBan from "./NewAppealBan.js";
import { useLoaderData } from "@remix-run/react";

export async function loader({ context }: { context: RequestContext }) {
const list = (
await context.env.D1.prepare(
"SELECT * FROM appeal_bans ORDER BY created_at DESC;",
).all()
).results as {
created_at: number | string;
created_by: string;
user: string;
}[];

for (const row of list)
row.created_at = new Date(row.created_at).toUTCString();

return list;
}

export default function (props: { isOpen: boolean; onClose: () => void }) {
const [entries, setEntries] = useState(
[] as { created_at: number; created_by: string; user: string }[],
[] as { created_at: number | string; created_by: string; user: string }[],
);
const toast = useToast();
const { isOpen, onClose, onOpen } = useDisclosure();
setEntries(useLoaderData<typeof loader>());

async function removeBan(user: string) {
const removeResp = await fetch(`/api/appeals/${user}/ban`, {
Expand Down

0 comments on commit cb6c835

Please sign in to comment.