Compare commits

..

No commits in common. "51d1121b23369dd4cf8833eed2cc53d2be7596b1" and "bbc3adf99c3067dcde02dc724d06d44482371a5a" have entirely different histories.

9 changed files with 31 additions and 78 deletions

View File

@ -37,6 +37,7 @@ export default function () {
const toast = useToast(); const toast = useToast();
const currentDate = new Date(); const currentDate = new Date();
const currentMonth = currentDate.getUTCMonth() + 1; const currentMonth = currentDate.getUTCMonth() + 1;
const currentYear = currentDate.getUTCFullYear();
const [datePickerMax, setDatePickerMax] = useState(""); const [datePickerMax, setDatePickerMax] = useState("");
const [datePickerMin, setDatePickerMin] = useState(""); const [datePickerMin, setDatePickerMin] = useState("");
const [eventDay, setEventDay] = useState("0"); const [eventDay, setEventDay] = useState("0");
@ -46,10 +47,13 @@ export default function () {
const [submitSuccess, setSubmitSuccess] = useState(false); const [submitSuccess, setSubmitSuccess] = useState(false);
useEffect(() => { useEffect(() => {
setDatePickerMin(`${new Date().toISOString().split("T").at(0)}`); setDatePickerMin(
currentDate.setUTCMonth(currentMonth); `${currentYear}-${currentMonth.toString().padStart(2, "0")}-${currentDate.getUTCDate().toString().padStart(2, "0")}`,
);
currentDate.setUTCDate(0); currentDate.setUTCDate(0);
setDatePickerMax(`${currentDate.toISOString().split("T").at(0)}`); setDatePickerMax(
`${currentYear}-${currentMonth.toString().padStart(2, "0")}-${new Date(currentYear, currentMonth, 0).getUTCDate()}`,
);
}, []); }, []);
async function submit() { async function submit() {

View File

@ -7,7 +7,6 @@ import {
ModalBody, ModalBody,
ModalCloseButton, ModalCloseButton,
ModalContent, ModalContent,
ModalFooter,
ModalHeader, ModalHeader,
ModalOverlay, ModalOverlay,
Table, Table,
@ -70,9 +69,7 @@ export async function loader({ context }: { context: RequestContext }) {
results[i].user = JSON.parse(results[i].user as string); results[i].user = JSON.parse(results[i].user as string);
} }
return { return results.filter((row) => {
can_delete: currentUser.permissions & (1 << 0),
results: results.filter((row) => {
const decisionValues = Object.values( const decisionValues = Object.values(
row.decisions as { [k: string]: boolean }, row.decisions as { [k: string]: boolean },
); );
@ -84,8 +81,7 @@ export async function loader({ context }: { context: RequestContext }) {
id: string; id: string;
start: string; start: string;
user: { email?: string; id: string; username: string }; user: { email?: string; id: string; username: string };
}[], }[];
};
} }
export default function () { export default function () {
@ -119,35 +115,6 @@ export default function () {
onOpen(); onOpen();
} }
async function deleteInactivity(id: string) {
const response = await fetch(`/api/inactivity/${id}`, {
method: "DELETE",
});
if (response.ok) {
onClose();
setInactivity({});
toast({
status: "success",
title: "Notice Deleted",
});
return;
}
let msg = "Unknown error";
try {
msg = ((await response.json()) as { error: string }).error;
} catch {}
toast({
description: msg,
status: "error",
title: "Failed to Delete",
});
}
return ( return (
<Container maxW="container.lg"> <Container maxW="container.lg">
<Modal isOpen={isOpen} onClose={onClose}> <Modal isOpen={isOpen} onClose={onClose}>
@ -186,11 +153,6 @@ export default function () {
</ListItem> </ListItem>
</UnorderedList> </UnorderedList>
</ModalBody> </ModalBody>
{data.can_delete ? (
<ModalFooter>
<Button colorScheme="red">Delete</Button>
</ModalFooter>
) : null}
</ModalContent> </ModalContent>
</Modal> </Modal>
<Heading pb="32px">Current Inactivity Notices</Heading> <Heading pb="32px">Current Inactivity Notices</Heading>
@ -209,7 +171,7 @@ export default function () {
</Tr> </Tr>
</Thead> </Thead>
<Tbody> <Tbody>
{data.results.map((row) => ( {data.map((row) => (
<Tr key={row.id}> <Tr key={row.id}>
<Td>{row.user.username}</Td> <Td>{row.user.username}</Td>
<Td>{row.user.id}</Td> <Td>{row.user.id}</Td>

View File

@ -22,7 +22,7 @@ import NewAppealBan from "./NewAppealBan.js";
export default function (props: { isOpen: boolean; onClose: () => void }) { export default function (props: { isOpen: boolean; onClose: () => void }) {
const [entries, setEntries] = useState( const [entries, setEntries] = useState(
[] as { created_at: number | string; created_by: string; user: string }[], [] as { created_at: number; created_by: string; user: string }[],
); );
const toast = useToast(); const toast = useToast();
const { isOpen, onClose, onOpen } = useDisclosure(); const { isOpen, onClose, onOpen } = useDisclosure();
@ -61,15 +61,7 @@ export default function (props: { isOpen: boolean; onClose: () => void }) {
setEntries([...entries].filter((entry) => entry.user !== user)); setEntries([...entries].filter((entry) => entry.user !== user));
} }
useEffect(() => { useEffect(() => {}, []);
(async function () {
const banData = await fetch("/api/appeals/bans");
if (!banData.ok) return;
setEntries(await banData.json());
})();
}, []);
return ( return (
<> <>

View File

@ -76,8 +76,6 @@ export default function (props: AppealCardProps & { port?: MessagePort }) {
} }
onClose(); onClose();
setFeedback("");
setAction("");
setLoading(false); setLoading(false);
props.port?.postMessage(`appeal_${props.id}`); props.port?.postMessage(`appeal_${props.id}`);
} }

View File

@ -2,7 +2,7 @@ import { jsonResponse } from "../../common.js";
export async function onRequestGet(context: RequestContext) { export async function onRequestGet(context: RequestContext) {
const { results } = await context.env.D1.prepare( const { results } = await context.env.D1.prepare(
"SELECT * FROM appeal_bans ORDER BY created_by DESC;", "SELECT * FROM appeal_bans;",
).all(); ).all();
return jsonResponse(JSON.stringify(results)); return jsonResponse(JSON.stringify(results));

View File

@ -14,25 +14,22 @@ export async function onRequestPost(context: RequestContext) {
if (!updatedEvent) return jsonError("This event does not exist", 404); if (!updatedEvent) return jsonError("This event does not exist", 404);
const emailData: { email: string; type: string } | null = const email = await context.env.DATA.get(
await context.env.DATA.get(`eventemail_${context.data.event.id}`, { `eventemail_${context.data.event.id}`,
type: "json", );
});
const usernameData: Record<string, string> | null = const usernameData: Record<string, string> | null =
await context.env.D1.prepare("SELECT name FROM et_members WHERE id = ?;") await context.env.D1.prepare("SELECT name FROM et_members WHERE id = ?;")
.bind(updatedEvent.created_by) .bind(updatedEvent.created_by)
.first(); .first();
if (emailData && usernameData) { if (email && usernameData) {
await sendEmail( await sendEmail(
emailData.email, email,
context.env.MAILGUN_API_KEY, context.env.MAILGUN_API_KEY,
`Event ${context.data.body.approved ? "Approved" : "Rejected"}`, `Event ${context.data.body.approved ? "Approved" : "Rejected"}`,
`event_${context.data.body.approved ? "approved" : "rejected"}`, `event_${context.data.body.approved ? "approved" : "rejected"}`,
{ {
date: `${updatedEvent.year}-${updatedEvent.month.toString().padStart(2, "0")}-${updatedEvent.day.toString().padStart(2, "0")}`, date: `${updatedEvent.year}-${updatedEvent.month.toString().padStart(2, "0")}-${updatedEvent.day.toString().padStart(2, "0")}`,
event: emailData.type,
username: usernameData.name, username: usernameData.name,
}, },
); );

View File

@ -98,7 +98,7 @@ export async function onRequestPost(context: RequestContext) {
if (type !== "gamenight") if (type !== "gamenight")
await context.env.DATA.put( await context.env.DATA.put(
`eventemail_${id}`, `eventemail_${id}`,
JSON.stringify({ email: context.data.current_user.email, type }), context.data.current_user.email,
{ expirationTtl: 2678400 }, { expirationTtl: 2678400 },
); );

View File

@ -5,7 +5,7 @@ export async function onRequestGet(context: RequestContext) {
[k: string]: { permissions: number[]; table: string }; [k: string]: { permissions: number[]; table: string };
} = { } = {
appeal: { appeal: {
permissions: [1 << 0, 1 << 11], permissions: [1 << 0, 1 << 1],
table: "appeals", table: "appeals",
}, },
gma: { gma: {

View File

@ -12,7 +12,7 @@ export async function onRequestGet(context: RequestContext): Promise<any> {
report: "reports", report: "reports",
}; };
const permissions: { [k: string]: number[] } = { const permissions: { [k: string]: number[] } = {
appeal: [1 << 0, 1 << 11], appeal: [1 << 0, 1 << 1],
gma: [1 << 5], gma: [1 << 5],
inactivity: [1 << 4, 1 << 6, 1 << 7, 1 << 11, 1 << 12], inactivity: [1 << 4, 1 << 6, 1 << 7, 1 << 11, 1 << 12],
report: [1 << 5], report: [1 << 5],