Update quantity of voucher after given

This commit is contained in:
ZacTohZY
2024-08-12 22:59:14 +08:00
parent 878e854be8
commit be61213aaf
8 changed files with 94 additions and 47 deletions

View File

@@ -111,13 +111,13 @@ router.patch("/:id/status", async (req, res) => {
const schedule = await Schedule.findByPk(id);
if (!schedule) {
return res.status(404).json({ message: 'Schedule not found' });
return res.status(404).json({ message: "Schedule not found" });
}
const now = dayjs();
const scheduleDateTime = dayjs(schedule.dateTime);
const newStatus = scheduleDateTime.isAfter(now) ? "Up coming" : "Ended";
const newStatus = scheduleDateTime.isAfter(now) ? "Upcoming" : "Ended";
schedule.status = newStatus;
await schedule.save();