diff --git a/.DS_Store b/.DS_Store index 5f5ce44..a91148e 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/Screenshot 2025-10-26 at 00.51.22.png b/Screenshot 2025-10-26 at 00.51.22.png new file mode 100644 index 0000000..0e4b30c Binary files /dev/null and b/Screenshot 2025-10-26 at 00.51.22.png differ diff --git a/Screenshot 2025-10-31 at 21.00.15.png b/Screenshot 2025-10-31 at 21.00.15.png new file mode 100644 index 0000000..ad707a3 Binary files /dev/null and b/Screenshot 2025-10-31 at 21.00.15.png differ diff --git a/backend/app.js b/backend/app.js index afed315..1b0c6e4 100644 --- a/backend/app.js +++ b/backend/app.js @@ -15,7 +15,10 @@ const helmet = require("helmet"); app.use(helmet()); app.use(express.json()); app.use(express.urlencoded({ extended: true })); -app.use(cookieParser()); +app.use((req, res, next) => { + console.log(`${req.method} ${req.url}`); + next(); +}); app.use(cors({ origin: process.env.FRONTEND_URL ? process.env.FRONTEND_URL.split(',') : ['http://localhost:3000', 'http://localhost:3001', 'http://localhost:3002', 'https://ambulance-booking-phi.vercel.app'], diff --git a/backend/controllers/booking.controller.js b/backend/controllers/booking.controller.js index f5456c9..a796392 100644 --- a/backend/controllers/booking.controller.js +++ b/backend/controllers/booking.controller.js @@ -27,16 +27,25 @@ module.exports.createBooking = async (req, res, next) => { } module.exports.updateBookingStatus = async (req, res, next) => { + const errors = validationResult(req); + if (!errors.isEmpty()) { + return res.status(400).json({ errors: errors.array() }); + } + console.log('Update Status Request:', { params: req.params, body: req.body }); try { const { status } = req.body; const { id } = req.params; const driverId = req.driver ? req.driver._id : null; + console.log('Searching for booking with:', { id, status, driverId }); const booking = await bookingService.updateBookingStatus(id, status, driverId); if (!booking) { + console.log('Booking NOT found for ID:', id); return res.status(404).json({ message: 'Booking not found' }); } + console.log('Booking found and updated:', booking._id); res.status(200).json(booking); } catch (err) { + console.error('Update Status Error:', err); res.status(500).json({ message: err.message }); } } diff --git a/backend/routes/booking.route.js b/backend/routes/booking.route.js index 5abbb6e..2353226 100644 --- a/backend/routes/booking.route.js +++ b/backend/routes/booking.route.js @@ -21,6 +21,12 @@ router.put('/:id/status', bookingController.updateBookingStatus ); +router.patch('/:id/status', + authMiddleware.authDriver, + body('status').isIn(['accepted', 'arrived', 'completed', 'cancelled']).withMessage('Invalid status'), + bookingController.updateBookingStatus +); + router.get('/pending', authMiddleware.authDriver, query('lat').optional().isNumeric().withMessage('Latitude must be a number'), diff --git a/frontend/app/driver/request/[id]/page.jsx b/frontend/app/driver/request/[id]/page.jsx index 8980a76..ffa7128 100644 --- a/frontend/app/driver/request/[id]/page.jsx +++ b/frontend/app/driver/request/[id]/page.jsx @@ -13,10 +13,7 @@ const MapComponent = dynamic(() => import('@/common/components/MapComponent'), { export default function RequestDetails({ params }) { const router = useRouter(); - // In Next.js App Router (prior to 15), params is a prop. In 15, it's a promise. - // Assuming 14 or lower based on previous code usually accessing params directly. - // If it breaks, I'll fix it to await params. - const id = params.id; + const { id } = React.use(params); const [booking, setBooking] = useState(null); const driverTabs = [ @@ -38,7 +35,7 @@ export default function RequestDetails({ params }) { const handleAccept = async () => { try { - await api.patch(`/bookings/${id}/status`, { status: "accepted" }); + await api.put(`/bookings/${id}/status`, { status: "accepted" }); router.push(`/driver/trip/${id}`); } catch (error) { console.error("Failed to accept booking:", error); @@ -47,7 +44,7 @@ export default function RequestDetails({ params }) { const handleDecline = async () => { try { - await api.patch(`/bookings/${id}/status`, { status: "declined" }); + await api.put(`/bookings/${id}/status`, { status: "declined" }); router.push('/driver/dashboard'); } catch (error) { console.error("Failed to decline booking:", error); diff --git a/frontend/app/driver/trip/[id]/page.jsx b/frontend/app/driver/trip/[id]/page.jsx index 45f4a74..935d5cc 100644 --- a/frontend/app/driver/trip/[id]/page.jsx +++ b/frontend/app/driver/trip/[id]/page.jsx @@ -14,7 +14,7 @@ const MapComponent = dynamic(() => import('@/common/components/MapComponent'), { export default function TripDetailsAccepted({ params }) { const router = useRouter(); - const id = params.id; + const { id } = React.use(params); const [booking, setBooking] = useState(null); const [vehicleLocation, setVehicleLocation] = useState(null); const [socket, setSocket] = useState(null); @@ -65,7 +65,7 @@ export default function TripDetailsAccepted({ params }) { const handleCompleteTrip = async () => { try { - await api.patch(`/bookings/${id}/status`, { status: "completed" }); + await api.put(`/bookings/${id}/status`, { status: "completed" }); router.push('/driver/dashboard'); } catch (error) { console.error("Failed to complete trip:", error); diff --git a/frontend/common/pages/HomePage.jsx b/frontend/common/pages/HomePage.jsx index e57771a..ee3b164 100644 --- a/frontend/common/pages/HomePage.jsx +++ b/frontend/common/pages/HomePage.jsx @@ -1,71 +1,16 @@ 'use client'; import React from 'react'; -import { Activity, Users, MapPin, Clock, Shield, Phone, ArrowRight, CheckCircle2, Mail, Facebook, Twitter, Instagram, Linkedin } from 'lucide-react'; +import { + Activity, Users, MapPin, Clock, Shield, ArrowRight, Phone, + CheckCircle2, Mail, Facebook, Twitter, Instagram, Linkedin, + Navigation, User, Bell, BellRing, Compass, Navigation2, Ambulance +} from 'lucide-react'; import { useRouter } from 'next/navigation'; -const featureCards = [ - { - title: 'Instant Response', - description: 'Get ambulances to your location within 5 minutes of booking.', - icon: Clock, - }, - { - title: 'Real-Time Tracking', - description: 'Track your ambulance location live on the map until arrival.', - icon: MapPin, - }, - { - title: 'Verified Drivers', - description: 'All drivers are verified medical professionals with proper licenses.', - icon: Shield, - }, - { - title: '24/7 Support', - description: 'Emergency assistance available round the clock, every day.', - icon: Phone, - }, - { - title: 'Advanced Care', - description: 'Choose from Basic, ICU, Neonatal, or Air Ambulance services.', - icon: Activity, - }, - { - title: 'Smart Routes', - description: 'Optimized routes to reach hospitals faster during emergencies.', - icon: MapPin, - }, -]; - -const steps = [ - { - number: '01', - title: 'Book Ambulance', - description: 'Enter your pickup and destination locations to book an ambulance.', - icon: MapPin, - }, - { - number: '02', - title: 'Choose Ambulance', - description: 'Select ambulance type based on your specific medical emergency needs.', - icon: Phone, - }, - { - number: '03', - title: 'Track Live', - description: 'Watch ambulance arrival in real-time with our live GPS map tracking.', - icon: Activity, - }, - { - number: '04', - title: 'Get Help', - description: 'Reach the hospital safely with professional medical care on the way.', - icon: Shield, - }, -]; - const HomePage = () => { const router = useRouter(); + const [activeTab, setActiveTab] = React.useState('user'); const handleBookAsClient = () => { router.push('/signup?role=user'); @@ -75,312 +20,277 @@ const HomePage = () => { router.push('/signup?role=driver'); }; - return ( -
- - {/* Hero Section with Wave Background */} -
- {/* Hero Background Elements */} -
- {/* Top Right Blue Wave */} -
- - - -
- - {/* Bottom Left Blue Wave (Rotated) */} -
- - - -
+ const steps = { + user: [ + { + title: 'Share Location', + description: 'Tell us where you are. We find the nearest ambulance for you.', + icon: MapPin, + }, + { + title: 'See the Map', + description: 'Watch the driver coming to you on your phone screen.', + icon: Navigation2, + }, + { + title: 'Get Help', + description: 'Our team takes care of you. We drive you to the hospital fast.', + icon: Activity, + } + ], + driver: [ + { + title: 'See New Bookings', + description: 'Get a message on your phone when someone needs help nearby.', + icon: BellRing, + }, + { + title: 'Drive Fast', + description: 'Use our easy map to find the best road to reach the patient.', + icon: Compass, + }, + { + title: 'Finish Trip', + description: 'Drop the person at the hospital and get ready for the next one.', + icon: CheckCircle2, + } + ] + }; - {/* Soft Blue Gradients focused on Hero */} -
+ return ( +
+ + {/* Hero Section */} +
+ {/* Background Image Layer */} +
+ Medical Facility + {/* Blue Overlay */} +
+
-
-
- {/* Left Content */} -
-
- - AmbuConnect Services -
- -

- AmbuConnect, We’re On the Way -

- -

- Get immediate medical assistance with fast and reliable ambulance services. We ensure safe transport and rapid response when every moment matters. -

- -
- - + {/* Navigation */} + + +
+
+ +

+ + Book Ambulance + + + Save Lives + +

+ +

+ Book a reliable ambulance in seconds. We provide quick transport with professional medical staff to keep you safe. +

- {/* Right Images - Floating Cards with Hover Animation */} -
- {/* Card 1 - Top Left */} -
-
-
- Emergency Ambulance -
-
-
-
- - {/* Card 2 - Top Right */} -
-
-
- Ambulance Fleet -
-
-
-
- - {/* Card 3 - Bottom Center */} -
-
-
- Emergency Response Team -
-
-
-
+
+ - {/* Decorative Element within Hero Scope */} -
-
+
- {/* Features Grid - Plain White Background */} -
-
-
-

Our Services

-

Why Choose AmbuConnect

-

- Advanced technology meets compassionate care to provide the best emergency response. -

+ {/* How It Works Section */} +
+
+
+

+ + Platform Guide +

+

+ How it Works. +

+ +
+ + +
-
- {featureCards.map(({ title, description, icon: Icon }) => ( -
- {/* Background Large Icon - Always Visible */} -
- -
+
+ {/* Timeline Line (Desktop) */} +
-
-
- + {steps[activeTab].map((step, idx) => ( +
+
+ +
+ 0{idx + 1}
-

{title}

-

{description}

+
{step.title}
+

+ {step.description} +

+
))}
- {/* How It Works Steps - Plain White Background */} -
-
-
-

Simple Process

-

How to Book Help

-
+ {/* Professional Partnership Call-to-action */} +
+
+
+
+ Medical Workstation +
+
-
- {/* Connector Line (Desktop) */} -
+
+

+ Partner with the
+ Future of Care. +

+

+ Join a verified network of hospitals, clinics, and professional drivers. Connect your infrastructure to our rapid response ecosystem. +

- {steps.map(({ number, title, description, icon: Icon }) => ( -
-
-
-
- -
-
- {number} -
-
-

{title}

-

- {description} -

+
+ +
+ Hospitals + Drivers
- ))} +
- {/* Expanded Footer - Dark Theme */} -