feat: make MH Paid column inline-editable

Add PATCH /api/payments/:id/mh-paid-amount for direct value updates.
Clicking the MH Paid cell opens an input; Enter/blur saves and refreshes,
Escape cancels. Dash placeholder is also clickable to enter a value.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Gitead
2026-05-06 17:50:52 -04:00
parent 1196e2afee
commit 6f33e416c1
2 changed files with 83 additions and 5 deletions

View File

@@ -427,6 +427,34 @@ router.patch(
}
);
// PATCH /api/payments/:id/mh-paid-amount
router.patch(
"/:id/mh-paid-amount",
async (req: Request, res: Response): Promise<any> => {
try {
const userId = req.user?.id;
if (!userId) return res.status(401).json({ message: "Unauthorized" });
const paymentId = parseIntOrError(req.params.id, "Payment ID");
const raw = req.body.mhPaidAmount;
const mhPaidAmount = parseFloat(raw);
if (isNaN(mhPaidAmount) || mhPaidAmount < 0) {
return res.status(400).json({ message: "Invalid mhPaidAmount value" });
}
const updated = await prisma.payment.update({
where: { id: paymentId },
data: { mhPaidAmount, updatedById: userId },
});
return res.json({ ...updated, mhPaidAmount: Number(updated.mhPaidAmount) });
} catch (err: unknown) {
const message = err instanceof Error ? err.message : "Failed to update MH paid amount";
return res.status(500).json({ message });
}
}
);
// PATCH /api/payments/:id/mh-payment-check
router.patch(
"/:id/mh-payment-check",