Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register change #2

Merged
merged 3 commits into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions backend/controllers/DLDriverFormController.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import asyncHandler from 'express-async-handler'
import DLDeliveryForm from '../models/DLDeliveryFormModel.js'

// Function to submit a delivery form
// Function to submit a delivery form
const submitDLDeliveryForm = asyncHandler(async (req, res) => {
const {
Expand All @@ -15,6 +16,9 @@ const submitDLDeliveryForm = asyncHandler(async (req, res) => {
address,
vehicleNumber,
vehicleType,
idCardImageUrl, // Image URLs passed from front-end
licenseImageUrl, // Image URLs passed from front-end
personalImageUrl, // Image URLs passed from front-end
} = req.body

// Check if a form with the same email already exists
Expand All @@ -27,11 +31,6 @@ const submitDLDeliveryForm = asyncHandler(async (req, res) => {
return
}

// Save the images
const idCardImageUrl = req.files['idCardImage'][0].path
const licenseImageUrl = req.files['licenseImage'][0].path
const personalImageUrl = req.files['personalImage'][0].path

// Create and save the delivery form
const deliveryForm = await DLDeliveryForm.create({
firstName,
Expand All @@ -45,17 +44,20 @@ const submitDLDeliveryForm = asyncHandler(async (req, res) => {
address,
vehicleNumber,
vehicleType,
idCardImageUrl,
licenseImageUrl,
personalImageUrl,
idCardImageUrl, // Directly saving the image URL passed from front-end
licenseImageUrl, // Directly saving the image URL passed from front-end
personalImageUrl, // Directly saving the image URL passed from front-end
})

// Respond with success message and saved form
res.status(201).json({
message: 'Form submitted successfully',
deliveryForm,
})
})



// Function to get all pending forms
const getPendingForms = asyncHandler(async (req, res) => {
const pendingForms = await DLDeliveryForm.find({ status: 'Pending' })
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added backend/uploads/1727544307081-images (1).jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added backend/uploads/1727544307081-images (2).jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added backend/uploads/1727544350765-images (1).jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added backend/uploads/1727544350765-images (2).jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added backend/uploads/1727544653930-images (1).jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added backend/uploads/1727544780630-images (1).jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
70 changes: 45 additions & 25 deletions frontend/src/Components/delivery/DLmanageSidebar.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { Link } from 'react-router-dom';
import { Link, NavLink } from 'react-router-dom';
import {
FaTachometerAlt,
FaTruck,
Expand All @@ -13,60 +13,80 @@ const DLmanageSidebar = () => {
return (
<aside className="absolute top-6 left-6 w-60 bg-white rounded-lg shadow-lg p-4 mt-8">
<nav>
<ul>
<li className="mb-2">
<Link
<ul className="space-y-4">
<li>
<NavLink
to="/manager/dashboard"
className="flex items-center p-2 rounded-lg bg-gray-100 text-gray-700 hover:bg-green-500 hover:text-white"
className={({ isActive }) =>
`flex items-center p-2 text-gray-700 rounded-md hover:bg-gray-100 ${
isActive ? 'bg-gray-100 border-l-4 border-green-700' : ''
}`
}
>
<FaTachometerAlt className="w-5 h-5 mr-3" />
Dashboard
</Link>
</NavLink>
</li>
<li className="mb-2">
<Link
<li>
<NavLink
to="/DLAllDeliveries"
className="flex items-center p-2 text-gray-500 hover:bg-gray-100 hover:text-gray-700 rounded-lg hover:bg-green-500 hover:text-white"
className={({ isActive }) =>
`flex items-center p-2 text-gray-700 rounded-md hover:bg-gray-100 ${
isActive ? 'bg-gray-100 border-l-4 border-green-700' : ''
}`
}
>
<FaTruck className="w-5 h-5 mr-3" />
Deliveries
</Link>
</NavLink>
</li>
<li className="mb-2">
<Link
<li>
<NavLink
to="/alldrivers"
className="flex items-center p-2 text-gray-500 hover:bg-gray-100 hover:text-gray-700 rounded-lg hover:bg-green-500 hover:text-white"
className={({ isActive }) =>
`flex items-center p-2 text-gray-700 rounded-md hover:bg-gray-100 ${
isActive ? 'bg-gray-100 border-l-4 border-green-700' : ''
}`
}
>
<FaUsers className="w-5 h-5 mr-3" />
Drivers
</Link>
</NavLink>
</li>
<li className="mb-2">
<Link
<li>
<NavLink
to="/manager/approve-driver"
className="flex items-center p-2 text-gray-500 hover:bg-gray-100 hover:text-gray-700 rounded-lg hover:bg-green-500 hover:text-white"
className={({ isActive }) =>
`flex items-center p-2 text-gray-700 rounded-md hover:bg-gray-100 ${
isActive ? 'bg-gray-100 border-l-4 border-green-700' : ''
}`
}
>
<FaUserCheck className="w-5 h-5 mr-3" />
Pending Drivers
</Link>
</NavLink>
</li>
<li className="mb-2">
<Link
<li>
<NavLink
to="/notifications"
className="flex items-center p-2 text-gray-500 hover:bg-gray-100 hover:text-gray-700 rounded-lg hover:bg-green-500 hover:text-white"
className={({ isActive }) =>
`flex items-center p-2 text-gray-700 rounded-md hover:bg-gray-100 ${
isActive ? 'bg-gray-100 border-l-4 border-green-700' : ''
}`
}
>
<FaBell className="w-5 h-5 mr-3" />
Notifications
</Link>
</NavLink>
</li>
<li>
<Link
<NavLink
to="/logout"
className="flex items-center p-2 text-gray-500 hover:bg-gray-100 hover:text-gray-700 rounded-lg hover:bg-green-500 hover:text-white"
className="flex items-center p-2 text-gray-700 rounded-md hover:bg-gray-100"
>
<FaSignOutAlt className="w-5 h-5 mr-3" />
Logout
</Link>
</NavLink>
</li>
</ul>
</nav>
Expand Down
72 changes: 44 additions & 28 deletions frontend/src/Components/delivery/DeliverySidebar.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

import React from 'react';
import { Link, useNavigate } from 'react-router-dom'; // Added useNavigate for navigation
import { NavLink, useNavigate } from 'react-router-dom'; // Using NavLink for active link detection
import Swal from 'sweetalert2';
import {
FaTachometerAlt,
Expand Down Expand Up @@ -48,7 +47,6 @@ const DeliverySidebar = ({ driver }) => {
const baseUrl = 'http://localhost:3000/';
const personalImageUrl = `${baseUrl}${driver?.personalImageUrl}`;


return (
<aside className="absolute top-6 left-6 w-60 bg-white rounded-lg shadow-lg p-4 mt-8">
{/* Driver Avatar and Welcome Message */}
Expand All @@ -63,57 +61,76 @@ const DeliverySidebar = ({ driver }) => {

{/* Navigation Links */}
<nav>
<ul>
<li className="mb-2">
<Link
<ul className="space-y-4">
<li>
<NavLink
to="/driver/dashboard"
className="flex items-center p-2 rounded-lg bg-gray-100 text-gray-700 hover:bg-green-500 hover:text-white"
className={({ isActive }) =>
`flex items-center p-2 text-gray-700 rounded-md hover:bg-gray-100 ${
isActive ? 'bg-gray-100 border-l-4 border-green-700' : ''
}`
}
>
<FaTachometerAlt className="w-5 h-5 mr-3" />
Dashboard
</Link>
</NavLink>
</li>
<li className="mb-2">
<Link
<li>
<NavLink
to="/driver/ongoing-deliveries"
className="flex items-center p-2 text-gray-500 hover:bg-gray-100 hover:text-gray-700 rounded-lg hover:bg-green-500 hover:text-white"
className={({ isActive }) =>
`flex items-center p-2 text-gray-700 rounded-md hover:bg-gray-100 ${
isActive ? 'bg-gray-100 border-l-4 border-green-700' : ''
}`
}
>
<FaTruck className="w-5 h-5 mr-3" />
Ongoing Deliveries
</Link>
</NavLink>
</li>
<li className="mb-2">
<Link
<li>
<NavLink
to="/driver/deliveries"
className="flex items-center p-2 text-gray-500 hover:bg-gray-100 hover:text-gray-700 rounded-lg hover:bg-green-500 hover:text-white"
className={({ isActive }) =>
`flex items-center p-2 text-gray-700 rounded-md hover:bg-gray-100 ${
isActive ? 'bg-gray-100 border-l-4 border-green-700' : ''
}`
}
>
<FaClipboardList className="w-5 h-5 mr-3" />
Deliveries
</Link>
</NavLink>
</li>
<li className="mb-2">
<Link
<li>
<NavLink
to="/driver/profile"
className="flex items-center p-2 text-gray-500 hover:bg-gray-100 hover:text-gray-700 rounded-lg hover:bg-green-500 hover:text-white"
className={({ isActive }) =>
`flex items-center p-2 text-gray-700 rounded-md hover:bg-gray-100 ${
isActive ? 'bg-gray-100 border-l-4 border-green-700' : ''
}`
}
>
<FaUser className="w-5 h-5 mr-3" />
Profile
</Link>
</NavLink>
</li>
<li className="mb-2">
<Link
<li>
<NavLink
to="/driver/settings"
className="flex items-center p-2 text-gray-500 hover:bg-gray-100 hover:text-gray-700 rounded-lg hover:bg-green-500 hover:text-white"
className={({ isActive }) =>
`flex items-center p-2 text-gray-700 rounded-md hover:bg-gray-100 ${
isActive ? 'bg-gray-100 border-l-4 border-green-700' : ''
}`
}
>
<FaCog className="w-5 h-5 mr-3" />

Settings
</Link>
</NavLink>
</li>
<li>
<button
onClick={handleLogout}
className="flex items-center p-2 text-gray-500 hover:bg-gray-100 hover:text-gray-700 rounded-lg hover:bg-red-500 hover:text-white"
className="flex items-center p-2 text-gray-700 rounded-md hover:bg-red-500 hover:text-white"
>
<FaSignOutAlt className="w-5 h-5 mr-3" />
Log-out
Expand All @@ -125,5 +142,4 @@ const DeliverySidebar = ({ driver }) => {
);
};


export default DeliverySidebar
export default DeliverySidebar;
4 changes: 2 additions & 2 deletions frontend/src/Pages/delivery/DLApproveDriver.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const DLApproveDriver = () => {
useEffect(() => {
const fetchPendingForms = async () => {
try {
const { data } = await axios.get('/api/d_forms/pending-forms')
const { data } = await axios.get('/d_forms/pending-forms')
setPendingForms(data)
} catch (error) {
console.error('Error fetching pending forms:', error)
Expand All @@ -26,7 +26,7 @@ const DLApproveDriver = () => {
// Handle reviewing a driver by navigating to the review page
const handleReview = (id) => {

navigate(`/api/manager/approve-driver/${id}`);
navigate(`/manager/approve-driver/${id}`);
};


Expand Down
8 changes: 4 additions & 4 deletions frontend/src/Pages/delivery/DLDriverAccept.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ const DLDriverAccept = () => {


// Construct the full URL for each image
const baseUrl = 'http://localhost:3000/'
const idCardImageUrl = `${baseUrl}${driverDetails.idCardImageUrl}`
const licenseImageUrl = `${baseUrl}${driverDetails.licenseImageUrl}`
const personalImageUrl = `${baseUrl}${driverDetails.personalImageUrl}`
// const baseUrl = 'http://localhost:3000/'
const idCardImageUrl = `${driverDetails.idCardImageUrl}`
const licenseImageUrl = `${driverDetails.licenseImageUrl}`
const personalImageUrl = `${driverDetails.personalImageUrl}`

return (

Expand Down
Loading