Create event decision endpoint
This commit is contained in:
parent
6c378080cc
commit
51b8822d0a
16
functions/api/events-team/events/[id]/decision.ts
Normal file
16
functions/api/events-team/events/[id]/decision.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { jsonError } from "../../../../common.js";
|
||||
|
||||
export async function onRequestPost(context: RequestContext) {
|
||||
if (typeof context.data.body.approved !== "boolean")
|
||||
return jsonError("Decision type must be a boolean", 400);
|
||||
|
||||
await context.env.D1.prepare(
|
||||
"UPDATE events SET approved = ?, pending = 0 WHERE id = ?;",
|
||||
)
|
||||
.bind(Number(context.data.body.approved), context.data.event.id)
|
||||
.run();
|
||||
|
||||
return new Response(null, {
|
||||
status: 204,
|
||||
});
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user