Added the backend code for completed task and also frontend is completed

This commit is contained in:
Md. Mosiur Rahman
2025-03-24 00:09:15 +06:00
parent 55f7f9eaa2
commit 053cdf0a6f
6 changed files with 75 additions and 39 deletions

View File

@@ -270,8 +270,22 @@ app.post("/api/delivery/create", async(req,res)=>{
await newDelivery.save().then(()=>res.status(201).json({ message: "Delivery saved successfully", success: true })).catch((err)=>res.status(500).json({ error: err.message }));
})
//TODO: Check create and read from frontend
//TODO: Add another Field to DeliverySchema called "isCompleted: boolean" - remove the table from DB FIRST
app.put("/api/delivery/update/:id", async(req, res)=> {
const filter = { _id : req.params.id }
const update = { delivery_status : req.body.delivery_status }
console.log(update)
if (!req.body.delivery_status) {
res.status(404).send("Delivery status is required")
}
const updateClient = await DeliveryModel.findOneAndUpdate(filter,update)
if (!updateClient) {
res.send(404).send("Client not Found")
}
res.status(200).send("Delivery Type Updated")
})
//TODO: FIx the file structure
//TODO: delivery Update
//TODO: delivery Delete