import { lazy, Suspense, useEffect } from 'react';
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
import { AuthProvider } from './contexts/AuthContext';
import Header from './components/common/Header';
import Footer from './components/common/Footer';
import Loader from './components/common/Loader';
import ProtectedRoute from './components/common/ProtectedRoute';
// Lazy-loaded pages
const Home = lazy(() => import('./pages/Home'));
const About = lazy(() => import('./pages/About'));
const OurWork = lazy(() => import('./pages/OurWork'));
const GetInvolved = lazy(() => import('./pages/GetInvolved'));
const Contact = lazy(() => import('./pages/Contact'));
// const MediaCentre = lazy(() => import('./pages/MediaCentre'));
const Login = lazy(() => import('./pages/Login'));
const Register = lazy(() => import('./pages/Register'));
const VerifyEmail = lazy(() => import('./pages/VerifyEmail'));
const Dashboard = lazy(() => import('./pages/Dashboard'));
const Donate = lazy(() => import('./pages/Donate'));
const Campaigns = lazy(() => import('./pages/Campaigns'));
const CampaignDetail = lazy(() => import('./pages/CampaignDetail'));
const VolunteerRegister = lazy(() => import('./pages/VolunteerRegister'));
const HelpRequest = lazy(() => import('./pages/HelpRequest'));
const DonationHistory = lazy(() => import('./pages/DonationHistory'));
const PrivacyPolicy = lazy(() => import('./pages/PrivacyPolicy'));
const TermsConditions = lazy(() => import('./pages/TermsConditions'));
const RefundPolicy = lazy(() => import('./pages/RefundPolicy'));
const NotFound = lazy(() => import('./pages/NotFound'));
import { useLocation } from 'react-router-dom';
function ScrollToTop() {
const { pathname } = useLocation();
useEffect(() => {
document.documentElement.style.scrollBehavior = 'auto';
window.scrollTo(0, 0);
requestAnimationFrame(() => {
document.documentElement.style.scrollBehavior = '';
});
}, [pathname]);
return null;
}
function AppLayout({ children }) {
return (
<>
}>
{children}
>
);
}
function AuthLayout({ children }) {
return (
}>
{children}
);
}
export default function App() {
return (
{/* Auth pages — no header/footer */}
} />
} />
} />
{/* Public pages */}
} />
} />
} />
} />
} />
{/* } /> */}
} />
} />
} />
} />
} />
} />
} />
} />
{/* Protected pages */}
}
/>
}
/>
{/* 404 */}
} />
);
}