fix: overseer status coercion
This commit is contained in:
@@ -139,14 +139,12 @@ router.post(
|
||||
req.body.id ??
|
||||
req.body.overseer_request_id;
|
||||
const statusRaw = String(req.body.status || "").toUpperCase();
|
||||
const status =
|
||||
statusRaw === "APPROVED" || statusRaw === "COMPLETED"
|
||||
? "APPROVED"
|
||||
: statusRaw === "DECLINED" || statusRaw === "FAILED"
|
||||
? "DECLINED"
|
||||
: statusRaw;
|
||||
if (!rawId || !status)
|
||||
return res.status(400).json({ error: "Missing fields" });
|
||||
let status = "PENDING";
|
||||
if (statusRaw === "APPROVED" || statusRaw === "COMPLETED")
|
||||
status = "APPROVED";
|
||||
else if (statusRaw === "DECLINED" || statusRaw === "FAILED")
|
||||
status = "DECLINED";
|
||||
if (!rawId) return res.status(400).json({ error: "Missing fields" });
|
||||
const request = await prisma.contentRequest.findFirst({
|
||||
where: { overseerRequestId: Number(rawId) },
|
||||
include: { user: true },
|
||||
@@ -154,7 +152,7 @@ router.post(
|
||||
if (!request) return res.status(404).json({ error: "Request not found" });
|
||||
const updatedRequest = await prisma.contentRequest.update({
|
||||
where: { id: request.id },
|
||||
data: { status },
|
||||
data: { status: status as any },
|
||||
});
|
||||
if (status === "DECLINED") {
|
||||
await prisma.transaction.create({
|
||||
|
||||
Reference in New Issue
Block a user