Greatly reduce repeated code

This commit is contained in:
2023-10-19 16:50:48 -04:00
parent 47e639be43
commit dd2d9f2672
34 changed files with 196 additions and 481 deletions

View File

@ -1,3 +1,5 @@
import { jsonError } from "../../../common.js";
export async function onRequestPost(context: RequestContext) {
const { appeal } = context.data;
const body = new FormData();
@ -20,12 +22,7 @@ export async function onRequestPost(context: RequestContext) {
if (!emailReq.ok) {
console.log(await emailReq.json());
return new Response('{"error":"Failed to accept appeal"}', {
headers: {
"content-type": "application/json",
},
status: 500,
});
return jsonError("Failed to accept appeal", 500);
}
const { current_user: currentUser } = context.data;