fix: overseer status coercion

This commit is contained in:
2026-04-22 14:11:02 -04:00
parent a5dd85f5c1
commit 5a8eb90c38
+7 -9
View File
@@ -139,14 +139,12 @@ router.post(
req.body.id ?? req.body.id ??
req.body.overseer_request_id; req.body.overseer_request_id;
const statusRaw = String(req.body.status || "").toUpperCase(); const statusRaw = String(req.body.status || "").toUpperCase();
const status = let status = "PENDING";
statusRaw === "APPROVED" || statusRaw === "COMPLETED" if (statusRaw === "APPROVED" || statusRaw === "COMPLETED")
? "APPROVED" status = "APPROVED";
: statusRaw === "DECLINED" || statusRaw === "FAILED" else if (statusRaw === "DECLINED" || statusRaw === "FAILED")
? "DECLINED" status = "DECLINED";
: statusRaw; if (!rawId) return res.status(400).json({ error: "Missing fields" });
if (!rawId || !status)
return res.status(400).json({ error: "Missing fields" });
const request = await prisma.contentRequest.findFirst({ const request = await prisma.contentRequest.findFirst({
where: { overseerRequestId: Number(rawId) }, where: { overseerRequestId: Number(rawId) },
include: { user: true }, include: { user: true },
@@ -154,7 +152,7 @@ router.post(
if (!request) return res.status(404).json({ error: "Request not found" }); if (!request) return res.status(404).json({ error: "Request not found" });
const updatedRequest = await prisma.contentRequest.update({ const updatedRequest = await prisma.contentRequest.update({
where: { id: request.id }, where: { id: request.id },
data: { status }, data: { status: status as any },
}); });
if (status === "DECLINED") { if (status === "DECLINED") {
await prisma.transaction.create({ await prisma.transaction.create({