Added public ID, fixed Aircraft Marker styles
This commit is contained in:
@@ -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" });
|
||||
|
||||
Reference in New Issue
Block a user