2026-06-05 17:45:17 +00:00
|
|
|
import { Switch, Route, Router as WouterRouter, Redirect } from "wouter";
|
2026-06-05 17:05:27 +00:00
|
|
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
|
|
|
import { Toaster } from "@/components/ui/toaster";
|
|
|
|
|
import { TooltipProvider } from "@/components/ui/tooltip";
|
|
|
|
|
import { LanguageProvider } from "./contexts/LanguageContext";
|
2026-06-05 19:54:45 +00:00
|
|
|
import { CartProvider } from "./contexts/CartContext";
|
2026-06-05 17:45:17 +00:00
|
|
|
import { AuthProvider, useAuth } from "./contexts/AuthContext";
|
2026-06-05 17:05:27 +00:00
|
|
|
import { AppLayout } from "./components/layout/AppLayout";
|
|
|
|
|
import NotFound from "@/pages/not-found";
|
2026-06-05 17:45:17 +00:00
|
|
|
import { ComponentType } from "react";
|
2026-06-05 17:05:27 +00:00
|
|
|
|
|
|
|
|
// Page imports
|
|
|
|
|
import Home from "./pages/home";
|
2026-06-05 19:30:47 +00:00
|
|
|
import About from "./pages/about";
|
2026-06-05 19:57:31 +00:00
|
|
|
import Waqf from "./pages/waqf";
|
|
|
|
|
import Baraem from "./pages/baraem";
|
2026-06-05 17:05:27 +00:00
|
|
|
import RequestSupport from "./pages/request";
|
|
|
|
|
import Opportunities from "./pages/opportunities";
|
|
|
|
|
import Donate from "./pages/donate";
|
|
|
|
|
import Admin from "./pages/admin";
|
|
|
|
|
import Track from "./pages/track";
|
|
|
|
|
import ThankYou from "./pages/thank-you";
|
|
|
|
|
import WhatsappLog from "./pages/whatsapp-log";
|
2026-06-05 17:45:17 +00:00
|
|
|
import Login from "./pages/login";
|
2026-06-05 19:54:45 +00:00
|
|
|
import Cart from "./pages/cart";
|
2026-06-05 17:05:27 +00:00
|
|
|
|
|
|
|
|
const queryClient = new QueryClient();
|
|
|
|
|
|
2026-06-05 17:45:17 +00:00
|
|
|
function Protected({ component: Component }: { component: ComponentType<any> }) {
|
|
|
|
|
const { isAuthenticated } = useAuth();
|
|
|
|
|
if (!isAuthenticated) {
|
|
|
|
|
return <Redirect to="/login" />;
|
|
|
|
|
}
|
|
|
|
|
return <Component />;
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-05 17:05:27 +00:00
|
|
|
function Router() {
|
|
|
|
|
return (
|
|
|
|
|
<AppLayout>
|
|
|
|
|
<Switch>
|
|
|
|
|
<Route path="/" component={Home} />
|
2026-06-05 19:30:47 +00:00
|
|
|
<Route path="/about/:section?" component={About} />
|
2026-06-05 19:57:31 +00:00
|
|
|
<Route path="/waqf" component={Waqf} />
|
|
|
|
|
<Route path="/baraem" component={Baraem} />
|
2026-06-05 17:05:27 +00:00
|
|
|
<Route path="/request" component={RequestSupport} />
|
|
|
|
|
<Route path="/opportunities" component={Opportunities} />
|
|
|
|
|
<Route path="/donate/:id" component={Donate} />
|
2026-06-05 19:54:45 +00:00
|
|
|
<Route path="/cart" component={Cart} />
|
2026-06-05 17:45:17 +00:00
|
|
|
<Route path="/login" component={Login} />
|
|
|
|
|
<Route path="/admin">
|
|
|
|
|
<Protected component={Admin} />
|
|
|
|
|
</Route>
|
2026-06-05 17:05:27 +00:00
|
|
|
<Route path="/track/:id" component={Track} />
|
|
|
|
|
<Route path="/thank-you/:id" component={ThankYou} />
|
2026-06-05 17:45:17 +00:00
|
|
|
<Route path="/whatsapp-log">
|
|
|
|
|
<Protected component={WhatsappLog} />
|
|
|
|
|
</Route>
|
2026-06-05 17:05:27 +00:00
|
|
|
<Route component={NotFound} />
|
|
|
|
|
</Switch>
|
|
|
|
|
</AppLayout>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function App() {
|
|
|
|
|
return (
|
|
|
|
|
<QueryClientProvider client={queryClient}>
|
|
|
|
|
<LanguageProvider>
|
2026-06-05 17:45:17 +00:00
|
|
|
<AuthProvider>
|
2026-06-05 19:54:45 +00:00
|
|
|
<CartProvider>
|
|
|
|
|
<TooltipProvider>
|
|
|
|
|
<WouterRouter base={import.meta.env.BASE_URL.replace(/\/$/, "")}>
|
|
|
|
|
<Router />
|
|
|
|
|
</WouterRouter>
|
|
|
|
|
<Toaster />
|
|
|
|
|
</TooltipProvider>
|
|
|
|
|
</CartProvider>
|
2026-06-05 17:45:17 +00:00
|
|
|
</AuthProvider>
|
2026-06-05 17:05:27 +00:00
|
|
|
</LanguageProvider>
|
|
|
|
|
</QueryClientProvider>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default App;
|