Compare commits
10 Commits
bbc3adf99c
...
51d1121b23
Author | SHA1 | Date | |
---|---|---|---|
51d1121b23 | |||
31d48ee326 | |||
03d6a47cb7 | |||
0b2dd8fb6c | |||
e7015e8549 | |||
08b36c04b8 | |||
6730b876bf | |||
c48ca6fc24 | |||
2245b040c6 | |||
cb6c835575 |
@ -37,7 +37,6 @@ 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");
|
||||||
@ -47,13 +46,10 @@ export default function () {
|
|||||||
const [submitSuccess, setSubmitSuccess] = useState(false);
|
const [submitSuccess, setSubmitSuccess] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setDatePickerMin(
|
setDatePickerMin(`${new Date().toISOString().split("T").at(0)}`);
|
||||||
`${currentYear}-${currentMonth.toString().padStart(2, "0")}-${currentDate.getUTCDate().toString().padStart(2, "0")}`,
|
currentDate.setUTCMonth(currentMonth);
|
||||||
);
|
|
||||||
currentDate.setUTCDate(0);
|
currentDate.setUTCDate(0);
|
||||||
setDatePickerMax(
|
setDatePickerMax(`${currentDate.toISOString().split("T").at(0)}`);
|
||||||
`${currentYear}-${currentMonth.toString().padStart(2, "0")}-${new Date(currentYear, currentMonth, 0).getUTCDate()}`,
|
|
||||||
);
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
async function submit() {
|
async function submit() {
|
||||||
|
@ -7,6 +7,7 @@ import {
|
|||||||
ModalBody,
|
ModalBody,
|
||||||
ModalCloseButton,
|
ModalCloseButton,
|
||||||
ModalContent,
|
ModalContent,
|
||||||
|
ModalFooter,
|
||||||
ModalHeader,
|
ModalHeader,
|
||||||
ModalOverlay,
|
ModalOverlay,
|
||||||
Table,
|
Table,
|
||||||
@ -69,7 +70,9 @@ 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 results.filter((row) => {
|
return {
|
||||||
|
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 },
|
||||||
);
|
);
|
||||||
@ -81,7 +84,8 @@ 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 () {
|
||||||
@ -115,6 +119,35 @@ 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}>
|
||||||
@ -153,6 +186,11 @@ 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>
|
||||||
@ -171,7 +209,7 @@ export default function () {
|
|||||||
</Tr>
|
</Tr>
|
||||||
</Thead>
|
</Thead>
|
||||||
<Tbody>
|
<Tbody>
|
||||||
{data.map((row) => (
|
{data.results.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>
|
||||||
|
@ -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; created_by: string; user: string }[],
|
[] as { created_at: number | string; created_by: string; user: string }[],
|
||||||
);
|
);
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
const { isOpen, onClose, onOpen } = useDisclosure();
|
const { isOpen, onClose, onOpen } = useDisclosure();
|
||||||
@ -61,7 +61,15 @@ 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 (
|
||||||
<>
|
<>
|
||||||
|
@ -76,6 +76,8 @@ 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}`);
|
||||||
}
|
}
|
||||||
|
@ -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;",
|
"SELECT * FROM appeal_bans ORDER BY created_by DESC;",
|
||||||
).all();
|
).all();
|
||||||
|
|
||||||
return jsonResponse(JSON.stringify(results));
|
return jsonResponse(JSON.stringify(results));
|
||||||
|
@ -14,22 +14,25 @@ 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 email = await context.env.DATA.get(
|
const emailData: { email: string; type: string } | null =
|
||||||
`eventemail_${context.data.event.id}`,
|
await context.env.DATA.get(`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 (email && usernameData) {
|
if (emailData && usernameData) {
|
||||||
await sendEmail(
|
await sendEmail(
|
||||||
email,
|
emailData.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,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -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}`,
|
||||||
context.data.current_user.email,
|
JSON.stringify({ email: context.data.current_user.email, type }),
|
||||||
{ expirationTtl: 2678400 },
|
{ expirationTtl: 2678400 },
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -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 << 1],
|
permissions: [1 << 0, 1 << 11],
|
||||||
table: "appeals",
|
table: "appeals",
|
||||||
},
|
},
|
||||||
gma: {
|
gma: {
|
||||||
|
@ -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 << 1],
|
appeal: [1 << 0, 1 << 11],
|
||||||
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],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user