More events team nonsense
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user