Added public ID, fixed Aircraft Marker styles

This commit is contained in:
PxlLoewe
2025-05-21 06:13:10 +08:00
parent 9127e28a3c
commit 7979531d6d
19 changed files with 1550 additions and 28 deletions

View File

@@ -40,10 +40,32 @@ router.get("/:id", async (req, res) => {
// Create a new mission
router.put("/", async (req, res) => {
try {
const newMission = await prisma.mission.create({
data: req.body,
const startOfToday = new Date();
startOfToday.setHours(0, 0, 0, 0);
const missionsTodayCount = await prisma.mission.count({
where: {
createdAt: {
gte: startOfToday,
},
},
});
io.to("dispatchers").emit("new-mission", newMission);
console.log("missionsTodayCount", missionsTodayCount);
const date = new Date();
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, "0"); // Months are zero-based
const day = String(date.getDate()).padStart(2, "0");
const publicId = `__${year}${month}${day}${missionsTodayCount ? missionsTodayCount + 1 : 1}`;
const newMission = await prisma.mission.create({
data: {
...req.body,
publicId,
},
});
io.to("dispatchers").emit("new-mission", { newMission });
res.status(201).json(newMission);
} catch (error) {
res.status(500).json({ error: "Failed to create mission" });