diff --git a/backend/controllers/DLDeliveryController.js b/backend/controllers/DLDeliveryController.js index dd18e26e..c83cd95c 100644 --- a/backend/controllers/DLDeliveryController.js +++ b/backend/controllers/DLDeliveryController.js @@ -20,6 +20,18 @@ export const assignDriverToOrder = async () => { return } + const existingDelivery = await DLDelivery.findOne({ + orderID: order.oID, + }) + if (existingDelivery) { + // If the order is already assigned, delete the order from dOrder table + await dOrder.deleteOne({ _id: order._id }) + console.log( + `Order ${order.oID} is already assigned, deleted from dOrder table.` + ) + return + } + // Find an available driver const driver = await DLDriver.findOne({ isAvailable: true }).sort({ createdAt: 1, diff --git a/backend/controllers/DLOcontroller.js b/backend/controllers/DLOcontroller.js index 08ef1f5f..3806f4ce 100644 --- a/backend/controllers/DLOcontroller.js +++ b/backend/controllers/DLOcontroller.js @@ -113,10 +113,8 @@ const assignReadyOrders = async () => { const existingOrder = await dOrder.findOne({ oID: order._id.toString(), }) - if (existingOrder) { - // console.log(`Order with ID ${order._id} already exists in dOrder.`) - continue // Skip this order if it already exists + continue // Skip this order if it already exists in dOrder } // Find the shop associated with this order (via shopId) @@ -172,11 +170,6 @@ const assignReadyOrders = async () => { // Save the new dOrder await newDOrder.save() /*console.log(`Order with ID ${order._id} has been successfully assigned to dOrder with new orderID ${newDOrder.orderID}.`)*/ - - // After saving the new dOrder, update the order status to "Assigning" in the Order model - order.orderStatus = 'Assigning' - await order.save() // Save the updated order - // console.log(`Order with ID ${order._id} has been marked as "Assigning" in the Order model.`) } } catch (error) { console.error('Error assigning ready orders to dOrder:', error) diff --git a/backend/uploads/1727053967402-id1.jpeg b/backend/uploads/1727053967402-id1.jpeg new file mode 100644 index 00000000..ed7e2639 Binary files /dev/null and b/backend/uploads/1727053967402-id1.jpeg differ diff --git a/backend/uploads/1727053967402-images (1).jpeg b/backend/uploads/1727053967402-images (1).jpeg new file mode 100644 index 00000000..138ad08f Binary files /dev/null and b/backend/uploads/1727053967402-images (1).jpeg differ diff --git a/backend/uploads/1727053967402-li1 - Copy (2).jpeg b/backend/uploads/1727053967402-li1 - Copy (2).jpeg new file mode 100644 index 00000000..3d522178 Binary files /dev/null and b/backend/uploads/1727053967402-li1 - Copy (2).jpeg differ diff --git a/backend/uploads/1727054250696-id2.jpeg b/backend/uploads/1727054250696-id2.jpeg new file mode 100644 index 00000000..2efa566d Binary files /dev/null and b/backend/uploads/1727054250696-id2.jpeg differ diff --git a/backend/uploads/1727054250696-images (2).jpeg b/backend/uploads/1727054250696-images (2).jpeg new file mode 100644 index 00000000..2f6c6a87 Binary files /dev/null and b/backend/uploads/1727054250696-images (2).jpeg differ diff --git a/backend/uploads/1727054250696-li1 - Copy (3).jpeg b/backend/uploads/1727054250696-li1 - Copy (3).jpeg new file mode 100644 index 00000000..3d522178 Binary files /dev/null and b/backend/uploads/1727054250696-li1 - Copy (3).jpeg differ diff --git a/backend/uploads/1727055520267-li1.jpeg b/backend/uploads/1727055520267-li1.jpeg new file mode 100644 index 00000000..3d522178 Binary files /dev/null and b/backend/uploads/1727055520267-li1.jpeg differ diff --git a/backend/uploads/1727060006946-id1 - Copy.jpeg b/backend/uploads/1727060006946-id1 - Copy.jpeg new file mode 100644 index 00000000..ed7e2639 Binary files /dev/null and b/backend/uploads/1727060006946-id1 - Copy.jpeg differ diff --git a/backend/uploads/1727060006947-id1.jpeg b/backend/uploads/1727060006947-id1.jpeg new file mode 100644 index 00000000..ed7e2639 Binary files /dev/null and b/backend/uploads/1727060006947-id1.jpeg differ diff --git a/backend/uploads/1727060006947-images.jpeg b/backend/uploads/1727060006947-images.jpeg new file mode 100644 index 00000000..08d36031 Binary files /dev/null and b/backend/uploads/1727060006947-images.jpeg differ diff --git a/backend/uploads/1727060871491-download.jpeg b/backend/uploads/1727060871491-download.jpeg new file mode 100644 index 00000000..81166fc4 Binary files /dev/null and b/backend/uploads/1727060871491-download.jpeg differ diff --git a/backend/uploads/1727060871491-id1 - Copy.jpeg b/backend/uploads/1727060871491-id1 - Copy.jpeg new file mode 100644 index 00000000..ed7e2639 Binary files /dev/null and b/backend/uploads/1727060871491-id1 - Copy.jpeg differ diff --git a/backend/uploads/1727060871491-li1 - Copy (3).jpeg b/backend/uploads/1727060871491-li1 - Copy (3).jpeg new file mode 100644 index 00000000..3d522178 Binary files /dev/null and b/backend/uploads/1727060871491-li1 - Copy (3).jpeg differ diff --git a/backend/uploads/1727061115161-id1 - Copy.jpeg b/backend/uploads/1727061115161-id1 - Copy.jpeg new file mode 100644 index 00000000..ed7e2639 Binary files /dev/null and b/backend/uploads/1727061115161-id1 - Copy.jpeg differ diff --git a/backend/uploads/1727061115162-images (2).jpeg b/backend/uploads/1727061115162-images (2).jpeg new file mode 100644 index 00000000..2f6c6a87 Binary files /dev/null and b/backend/uploads/1727061115162-images (2).jpeg differ diff --git a/backend/uploads/1727061115162-li1 - Copy (3).jpeg b/backend/uploads/1727061115162-li1 - Copy (3).jpeg new file mode 100644 index 00000000..3d522178 Binary files /dev/null and b/backend/uploads/1727061115162-li1 - Copy (3).jpeg differ diff --git a/backend/uploads/1727062096026-id1 - Copy.jpeg b/backend/uploads/1727062096026-id1 - Copy.jpeg new file mode 100644 index 00000000..ed7e2639 Binary files /dev/null and b/backend/uploads/1727062096026-id1 - Copy.jpeg differ diff --git a/backend/uploads/1727062096026-images (2).jpeg b/backend/uploads/1727062096026-images (2).jpeg new file mode 100644 index 00000000..2f6c6a87 Binary files /dev/null and b/backend/uploads/1727062096026-images (2).jpeg differ diff --git a/backend/uploads/1727062096026-li1 - Copy (2).jpeg b/backend/uploads/1727062096026-li1 - Copy (2).jpeg new file mode 100644 index 00000000..3d522178 Binary files /dev/null and b/backend/uploads/1727062096026-li1 - Copy (2).jpeg differ diff --git a/backend/uploads/1727519172982-images (1).jpeg b/backend/uploads/1727519172982-images (1).jpeg new file mode 100644 index 00000000..138ad08f Binary files /dev/null and b/backend/uploads/1727519172982-images (1).jpeg differ diff --git a/backend/uploads/1727519172982-li1 - Copy.jpeg b/backend/uploads/1727519172982-li1 - Copy.jpeg new file mode 100644 index 00000000..3d522178 Binary files /dev/null and b/backend/uploads/1727519172982-li1 - Copy.jpeg differ diff --git a/backend/uploads/1727519172984-id2.jpeg b/backend/uploads/1727519172984-id2.jpeg new file mode 100644 index 00000000..2efa566d Binary files /dev/null and b/backend/uploads/1727519172984-id2.jpeg differ diff --git a/backend/uploads/1727535697391-We4ponx-Crysis-3-Crysis-3-1.256.png b/backend/uploads/1727535697391-We4ponx-Crysis-3-Crysis-3-1.256.png new file mode 100644 index 00000000..72ec9c25 Binary files /dev/null and b/backend/uploads/1727535697391-We4ponx-Crysis-3-Crysis-3-1.256.png differ diff --git a/backend/uploads/1727535697393-We4ponx-Crysis-3-Crysis-3-1.256.png b/backend/uploads/1727535697393-We4ponx-Crysis-3-Crysis-3-1.256.png new file mode 100644 index 00000000..72ec9c25 Binary files /dev/null and b/backend/uploads/1727535697393-We4ponx-Crysis-3-Crysis-3-1.256.png differ diff --git a/backend/uploads/1727535697394-We4ponx-Crysis-3-Crysis-3-1.256.png b/backend/uploads/1727535697394-We4ponx-Crysis-3-Crysis-3-1.256.png new file mode 100644 index 00000000..72ec9c25 Binary files /dev/null and b/backend/uploads/1727535697394-We4ponx-Crysis-3-Crysis-3-1.256.png differ diff --git a/backend/uploads/1727544159173-We4ponx-Crysis-3-Crysis-3-1.256.png b/backend/uploads/1727544159173-We4ponx-Crysis-3-Crysis-3-1.256.png new file mode 100644 index 00000000..72ec9c25 Binary files /dev/null and b/backend/uploads/1727544159173-We4ponx-Crysis-3-Crysis-3-1.256.png differ diff --git a/backend/uploads/1727544171542-We4ponx-Crysis-3-Crysis-3-1.256.png b/backend/uploads/1727544171542-We4ponx-Crysis-3-Crysis-3-1.256.png new file mode 100644 index 00000000..72ec9c25 Binary files /dev/null and b/backend/uploads/1727544171542-We4ponx-Crysis-3-Crysis-3-1.256.png differ diff --git a/backend/uploads/1727544307081-images (1).jpeg b/backend/uploads/1727544307081-images (1).jpeg new file mode 100644 index 00000000..138ad08f Binary files /dev/null and b/backend/uploads/1727544307081-images (1).jpeg differ diff --git a/backend/uploads/1727544307081-images (2).jpeg b/backend/uploads/1727544307081-images (2).jpeg new file mode 100644 index 00000000..2f6c6a87 Binary files /dev/null and b/backend/uploads/1727544307081-images (2).jpeg differ diff --git a/backend/uploads/1727544350765-images (1).jpeg b/backend/uploads/1727544350765-images (1).jpeg new file mode 100644 index 00000000..138ad08f Binary files /dev/null and b/backend/uploads/1727544350765-images (1).jpeg differ diff --git a/backend/uploads/1727544350765-images (2).jpeg b/backend/uploads/1727544350765-images (2).jpeg new file mode 100644 index 00000000..2f6c6a87 Binary files /dev/null and b/backend/uploads/1727544350765-images (2).jpeg differ diff --git a/backend/uploads/1727544653930-images (1).jpeg b/backend/uploads/1727544653930-images (1).jpeg new file mode 100644 index 00000000..138ad08f Binary files /dev/null and b/backend/uploads/1727544653930-images (1).jpeg differ diff --git a/backend/uploads/1727544780630-images (1).jpeg b/backend/uploads/1727544780630-images (1).jpeg new file mode 100644 index 00000000..138ad08f Binary files /dev/null and b/backend/uploads/1727544780630-images (1).jpeg differ diff --git a/frontend/src/Components/Admin/admnlogins.jsx b/frontend/src/Components/Admin/admnlogins.jsx index 03d36b02..8f87af25 100644 --- a/frontend/src/Components/Admin/admnlogins.jsx +++ b/frontend/src/Components/Admin/admnlogins.jsx @@ -15,17 +15,17 @@ const AdminLogin = () => { { email: 'sanjeewa@gmail.com', password: 'sanjeewa', - navigateTo: '/manager/dashboard', // Admin 1's dashboard + navigateTo: '/manager/dashboard' // Admin 1's dashboard }, { email: 'admin2@example.com', password: 'password123', - navigateTo: '/manager/dashboard', // Admin 2's dashboard + navigateTo: '/manager/dashboard' // Admin 2's dashboard }, { email: 'admin3@example.com', password: 'securePass', - navigateTo: '/superuser/dashboard', // Admin 3's dashboard + navigateTo: '/superuser/dashboard' // Admin 3's dashboard }, ] diff --git a/frontend/src/Pages/delivery/DLDriverDashboard.jsx b/frontend/src/Pages/delivery/DLDriverDashboard.jsx index 3083eb52..1231055f 100644 --- a/frontend/src/Pages/delivery/DLDriverDashboard.jsx +++ b/frontend/src/Pages/delivery/DLDriverDashboard.jsx @@ -37,14 +37,11 @@ const DLDriverDashboard = () => { setIsAvailable(data.isAvailable) // Set initial availability // Check if NIC and password are the same - const nicCheckRes = await axios.get( - '/api/drivers/nic-password-check', - { - headers: { - Authorization: `Bearer ${driverToken}`, // Pass token in headers - }, - } - ) + const nicCheckRes = await axios.get('/api/drivers/nic-password-check', { + headers: { + Authorization: `Bearer ${driverToken}`, // Pass token in headers + }, + }) setNicMatchesPassword(nicCheckRes.data.nicMatchesPassword) // Set NIC and password equality check result // Fetch ongoing deliveries assigned to this driver @@ -156,10 +153,10 @@ const DLDriverDashboard = () => { status === 'Ready' ? 25 : status === 'Picked Up' - ? 50 - : status === 'On The Way' - ? 75 - : 100 + ? 50 + : status === 'On The Way' + ? 75 + : 100 const bgColor = progress === 100 ? 'bg-gray-400' : 'bg-green-500' return ( @@ -186,8 +183,7 @@ const DLDriverDashboard = () => {
Warning: Your NIC number and password are the same. Please update your password for better - security. When you change the password, you can assign - orders. + security. When you change the password, you can assign orders.
)} @@ -220,9 +216,7 @@ const DLDriverDashboard = () => { : 'bg-red-500 hover:bg-red-600' }`} > - {isAvailable - ? 'Available' - : 'Unavailable'} + {isAvailable ? 'Available' : 'Unavailable'} )}