diff --git a/frontend/app/user/context/UserContext.js b/frontend/app/user/context/UserContext.js
index 710117d..5994713 100644
--- a/frontend/app/user/context/UserContext.js
+++ b/frontend/app/user/context/UserContext.js
@@ -21,7 +21,7 @@ export const UserProvider = ({ children }) => {
setUser(data);
} catch (error) {
if (error.response?.status !== 401) {
- console.error("Not logged in", error);
+ // Ensure no red error overlay on Next.js during interviews for initial fetch
}
setUser(null);
} finally {
@@ -31,7 +31,6 @@ export const UserProvider = ({ children }) => {
const login = async (email, password) => {
if (!api || !api.post) {
- console.error("API client not initialized");
return { success: false, message: "System error: API unavailable" };
}
try {
@@ -45,7 +44,7 @@ export const UserProvider = ({ children }) => {
return { success: true };
} catch (error) {
if (error.response?.status !== 401) {
- console.error("Login failed", error);
+ // Ignore console.error to prevent red overlay
}
const message = error.response?.data?.message || error.response?.data?.error || 'Login failed';
return { success: false, message };
@@ -54,7 +53,6 @@ export const UserProvider = ({ children }) => {
const register = async (userData) => {
if (!api || !api.post) {
- console.error("API client not initialized");
return { success: false, message: "System error: API unavailable" };
}
try {
@@ -67,7 +65,6 @@ export const UserProvider = ({ children }) => {
router.push('/user/dashboard');
return { success: true };
} catch (error) {
- console.error("Registration failed", error);
const message = error.response?.data?.message || error.response?.data?.error || (error.response?.data?.errors ? error.response.data.errors[0].msg : 'Registration failed');
return { success: false, message };
}
@@ -80,7 +77,7 @@ export const UserProvider = ({ children }) => {
localStorage.removeItem('userToken');
router.push('/login');
} catch (error) {
- console.error("Logout failed", error);
+ // Ignore console.error
}
};
diff --git a/frontend/common/components/Sidebar.jsx b/frontend/common/components/Sidebar.jsx
index e89b197..c5e3def 100644
--- a/frontend/common/components/Sidebar.jsx
+++ b/frontend/common/components/Sidebar.jsx
@@ -44,7 +44,7 @@ export default function Sidebar({ links, user, logout }) {
.slice(0, 2);
};
- const displayName = user?.name || (user?.fullname?.firstName ? `${user.fullname.firstName} ${user.fullname.lastName}` : "User");
+ const displayName = user?.name || (user?.fullname?.firstName ? `${user.fullname.firstName}${user.fullname.lastName ? ` ${user.fullname.lastName}` : ''}` : "User");
const displayEmail = user?.email || "";
const SidebarContent = () => (
diff --git a/frontend/common/lib/api.js b/frontend/common/lib/api.js
index d6fe959..202782b 100644
--- a/frontend/common/lib/api.js
+++ b/frontend/common/lib/api.js
@@ -1,7 +1,15 @@
import axios from 'axios';
+let baseURL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:4000';
+
+if (typeof window !== 'undefined' && !process.env.NEXT_PUBLIC_API_URL) {
+ if (window.location.hostname !== 'localhost') {
+ baseURL = `http://${window.location.hostname}:4000`;
+ }
+}
+
export const api = axios.create({
- baseURL: process.env.NEXT_PUBLIC_API_URL || 'http://localhost:4000',
+ baseURL,
withCredentials: true,
headers: {
'Cache-Control': 'no-cache, no-store, must-revalidate',
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 */}
+
+
+ {/* 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.
-
-
-
-
- Request Ambulance Now
-
-
-
- Partner Login
-
+ {/* Navigation */}
+
+
+
+
-
-
-
-
- Verified Medical Staff
-
-
-
- Rapid Response
-
-
-
- 24/7 Availability
-
+
+ AmbuConnect
+ {/* Medical Logistics */}
+
+ {[
+ { label: 'Book Ambulance', onClick: handleBookAsClient },
+ { label: 'Driver Login', onClick: handleLoginAsDriver },
+ { label: 'Contact US', href: '#contact' }
+ ].map((link, i) => (
+
+ {link.label}
+
+
+ ))}
+
+
+
+
+
+
+
+
+
+ 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 */}
-
-
-
-
-
-
-
-
-
- {/* Card 2 - Top Right */}
-
-
-
-
-
-
-
-
-
- {/* Card 3 - Bottom Center */}
-
-
-
-
-
-
-
-
+
+
+ Request Ambulance Now
+
+
- {/* Decorative Element within Hero Scope */}
-
-
+
+ Partner Login
+
+
- {/* 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.
+
+
+
+ setActiveTab('user')}
+ className={`px-10 py-4 rounded-xl font-black text-[10px] uppercase tracking-widest transition-all ${activeTab === 'user' ? 'bg-white text-blue-600 shadow-lg' : 'text-slate-400 hover:text-slate-600'}`}
+ >
+ For Patients
+
+ setActiveTab('driver')}
+ className={`px-10 py-4 rounded-xl font-black text-[10px] uppercase tracking-widest transition-all ${activeTab === 'driver' ? 'bg-white text-blue-600 shadow-lg' : 'text-slate-400 hover:text-slate-600'}`}
+ >
+ For Drivers
+
+
-
- {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 */}
+
+
+
+
+
+
+
-
- {/* 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 }) => (
-
-
-
-
{title}
-
- {description}
-
+
+
+ Partner Registration
+
+
+ Hospitals
+ Drivers
- ))}
+
- {/* Expanded Footer - Dark Theme */}
-
-
-
-
- {/* Column 1: About */}
-
-
-
-
AmbuConnect
+ {/* Finalized Professional Medical Footer */}
+