More events team nonsense
All checks were successful
Test, Build, Deploy / Test, Build, and Deploy (push) Successful in 55s
Test, Build, Deploy / Create Sentry Release (push) Successful in 6s

This commit is contained in:
2026-04-11 03:30:46 -04:00
parent 465bb30966
commit cfc57c838e
17 changed files with 355 additions and 259 deletions

View File

@@ -5,12 +5,15 @@ export async function onRequestPost(context: RequestContext) {
if (typeof context.data.body.approved !== "boolean")
return jsonError("Decision type must be a boolean", 400);
const updatedEvent: Record<string, number | string> | null =
await context.env.D1.prepare(
"UPDATE events SET approved = ?, pending = 0 WHERE id = ? RETURNING created_by, day, month, year;",
)
.bind(Number(context.data.body.approved), context.data.event.id)
.first();
const updatedEvent = await context.data.prisma.event.update({
data: {
approved: context.data.body.approved,
pending: false,
},
where: {
id: context.data.event.id,
},
});
if (!updatedEvent) return jsonError("This event does not exist", 404);
@@ -19,10 +22,14 @@ export async function onRequestPost(context: RequestContext) {
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();
const usernameData = await context.data.prisma.etMember.findUnique({
where: {
id: updatedEvent.created_by,
},
select: {
name: true,
},
});
if (emailData && usernameData) {
await sendEmail(