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 currentDate = new Date();
|
||||
const currentMonth = currentDate.getUTCMonth() + 1;
|
||||
const currentYear = currentDate.getUTCFullYear();
|
||||
const [datePickerMax, setDatePickerMax] = useState("");
|
||||
const [datePickerMin, setDatePickerMin] = useState("");
|
||||
const [eventDay, setEventDay] = useState("0");
|
||||
@ -47,13 +46,10 @@ export default function () {
|
||||
const [submitSuccess, setSubmitSuccess] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
setDatePickerMin(
|
||||
`${currentYear}-${currentMonth.toString().padStart(2, "0")}-${currentDate.getUTCDate().toString().padStart(2, "0")}`,
|
||||
);
|
||||
setDatePickerMin(`${new Date().toISOString().split("T").at(0)}`);
|
||||
currentDate.setUTCMonth(currentMonth);
|
||||
currentDate.setUTCDate(0);
|
||||
setDatePickerMax(
|
||||
`${currentYear}-${currentMonth.toString().padStart(2, "0")}-${new Date(currentYear, currentMonth, 0).getUTCDate()}`,
|
||||
);
|
||||
setDatePickerMax(`${currentDate.toISOString().split("T").at(0)}`);
|
||||
}, []);
|
||||
|
||||
async function submit() {
|
||||
|
@ -7,6 +7,7 @@ import {
|
||||
ModalBody,
|
||||
ModalCloseButton,
|
||||
ModalContent,
|
||||
ModalFooter,
|
||||
ModalHeader,
|
||||
ModalOverlay,
|
||||
Table,
|
||||
@ -69,7 +70,9 @@ export async function loader({ context }: { context: RequestContext }) {
|
||||
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(
|
||||
row.decisions as { [k: string]: boolean },
|
||||
);
|
||||
@ -81,7 +84,8 @@ export async function loader({ context }: { context: RequestContext }) {
|
||||
id: string;
|
||||
start: string;
|
||||
user: { email?: string; id: string; username: string };
|
||||
}[];
|
||||
}[],
|
||||
};
|
||||
}
|
||||
|
||||
export default function () {
|
||||
@ -115,6 +119,35 @@ export default function () {
|
||||
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 (
|
||||
<Container maxW="container.lg">
|
||||
<Modal isOpen={isOpen} onClose={onClose}>
|
||||
@ -153,6 +186,11 @@ export default function () {
|
||||
</ListItem>
|
||||
</UnorderedList>
|
||||
</ModalBody>
|
||||
{data.can_delete ? (
|
||||
<ModalFooter>
|
||||
<Button colorScheme="red">Delete</Button>
|
||||
</ModalFooter>
|
||||
) : null}
|
||||
</ModalContent>
|
||||
</Modal>
|
||||
<Heading pb="32px">Current Inactivity Notices</Heading>
|
||||
@ -171,7 +209,7 @@ export default function () {
|
||||
</Tr>
|
||||
</Thead>
|
||||
<Tbody>
|
||||
{data.map((row) => (
|
||||
{data.results.map((row) => (
|
||||
<Tr key={row.id}>
|
||||
<Td>{row.user.username}</Td>
|
||||
<Td>{row.user.id}</Td>
|
||||
|
@ -22,7 +22,7 @@ import NewAppealBan from "./NewAppealBan.js";
|
||||
|
||||
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();
|
||||
@ -61,7 +61,15 @@ export default function (props: { isOpen: boolean; onClose: () => void }) {
|
||||
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 (
|
||||
<>
|
||||
|
@ -76,6 +76,8 @@ export default function (props: AppealCardProps & { port?: MessagePort }) {
|
||||
}
|
||||
|
||||
onClose();
|
||||
setFeedback("");
|
||||
setAction("");
|
||||
setLoading(false);
|
||||
props.port?.postMessage(`appeal_${props.id}`);
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ import { jsonResponse } from "../../common.js";
|
||||
|
||||
export async function onRequestGet(context: RequestContext) {
|
||||
const { results } = await context.env.D1.prepare(
|
||||
"SELECT * FROM appeal_bans;",
|
||||
"SELECT * FROM appeal_bans ORDER BY created_by DESC;",
|
||||
).all();
|
||||
|
||||
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);
|
||||
|
||||
const email = await context.env.DATA.get(
|
||||
`eventemail_${context.data.event.id}`,
|
||||
);
|
||||
const emailData: { email: string; type: string } | null =
|
||||
await context.env.DATA.get(`eventemail_${context.data.event.id}`, {
|
||||
type: "json",
|
||||
});
|
||||
|
||||
const usernameData: Record<string, string> | null =
|
||||
await context.env.D1.prepare("SELECT name FROM et_members WHERE id = ?;")
|
||||
.bind(updatedEvent.created_by)
|
||||
.first();
|
||||
|
||||
if (email && usernameData) {
|
||||
if (emailData && usernameData) {
|
||||
await sendEmail(
|
||||
email,
|
||||
emailData.email,
|
||||
context.env.MAILGUN_API_KEY,
|
||||
`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")}`,
|
||||
event: emailData.type,
|
||||
username: usernameData.name,
|
||||
},
|
||||
);
|
||||
|
@ -98,7 +98,7 @@ export async function onRequestPost(context: RequestContext) {
|
||||
if (type !== "gamenight")
|
||||
await context.env.DATA.put(
|
||||
`eventemail_${id}`,
|
||||
context.data.current_user.email,
|
||||
JSON.stringify({ email: context.data.current_user.email, type }),
|
||||
{ expirationTtl: 2678400 },
|
||||
);
|
||||
|
||||
|
@ -5,7 +5,7 @@ export async function onRequestGet(context: RequestContext) {
|
||||
[k: string]: { permissions: number[]; table: string };
|
||||
} = {
|
||||
appeal: {
|
||||
permissions: [1 << 0, 1 << 1],
|
||||
permissions: [1 << 0, 1 << 11],
|
||||
table: "appeals",
|
||||
},
|
||||
gma: {
|
||||
|
@ -12,7 +12,7 @@ export async function onRequestGet(context: RequestContext): Promise<any> {
|
||||
report: "reports",
|
||||
};
|
||||
const permissions: { [k: string]: number[] } = {
|
||||
appeal: [1 << 0, 1 << 1],
|
||||
appeal: [1 << 0, 1 << 11],
|
||||
gma: [1 << 5],
|
||||
inactivity: [1 << 4, 1 << 6, 1 << 7, 1 << 11, 1 << 12],
|
||||
report: [1 << 5],
|
||||
|
Loading…
x
Reference in New Issue
Block a user