NGU-Web/src/App.tsx
Zaldimmar 499662b59a Leadership becomes the Organization page, at /organization
Three sections: Mission, Vision & Values from the national
organization record's own description and content blocks;
Leadership as that record's teams with their people; Details &
Contact with NGU's address, nonprofit status, email and the
record's contact links. /leadership answers with a 301 to
/organization (MOVED in routes/pages.js), and a page title or intro
saved for it in Site settings moves with it (migration 054).

OrganizationDetail's team list and contact buttons are now shared
components (OrgTeams, OrgContact), and NGU's address and email live
once in src/data/organizationDetails.ts for the footer, the page and
ComingSoon.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 20:30:18 -05:00

147 lines
6.2 KiB
TypeScript

import {
BrowserRouter,
Routes,
Route,
Outlet,
Navigate,
} from "react-router-dom"
import { lazy, Suspense } from "react"
/*Components*/
import Layout from "./components/Layout.tsx"
/*Libraries*/
import { AuthProvider, RequireAuth } from "./lib/auth.tsx"
import RequireRole from "./pages/admin/RequireRole.tsx"
/*Pages*/
// Home is the landing page, so it ships in the main bundle. Every
// other page, and all of the admin, is fetched when first visited:
// a visitor to the front page never downloads the admin, the QR
// encoder, the calendar or the group map. Layout and AdminLayout
// wrap their <Outlet /> in <Suspense>, so the header stays put while
// a page loads.
import Home from "./pages/Home.tsx"
/* A page's chunk can be missing when a deploy replaced the build while
this tab still ran the old one. Reload once to pick up the new
build; if that doesn't help, let the error surface. */
const CHUNK_RELOAD = "site-chunk-reload"
const lazyPage = (load) =>
lazy(() =>
load()
.then((page) => {
try {
sessionStorage.removeItem(CHUNK_RELOAD)
} catch {}
return page
})
.catch((err) => {
const key = CHUNK_RELOAD
let reloaded = false
try {
reloaded = sessionStorage.getItem(key) === "1"
sessionStorage.setItem(key, "1")
} catch {}
if (!reloaded) {
window.location.reload()
return new Promise(() => {})
}
throw err
}),
)
const Retreats = lazyPage(() => import("./pages/Retreats.tsx"))
const Community = lazyPage(() => import("./pages/Community.tsx"))
const Organization = lazyPage(() => import("./pages/Organization.tsx"))
const Resources = lazyPage(() => import("./pages/Resources.tsx"))
const History = lazyPage(() => import("./pages/History.tsx"))
const Feedback = lazyPage(() => import("./pages/Feedback.tsx"))
const Request = lazyPage(() => import("./pages/Request.tsx"))
const Giving = lazyPage(() => import("./pages/Giving.tsx"))
const QrCodes = lazyPage(() => import("./pages/QrCodes.tsx"))
const Privacy = lazyPage(() => import("./pages/Privacy.tsx"))
const Terms = lazyPage(() => import("./pages/Terms.tsx"))
const NotFound = lazyPage(() => import("./pages/NotFound.tsx"))
/*Entity Pages*/
const EventDetail = lazyPage(() => import("./pages/EventDetail.tsx"))
const OrganizationDetail = lazyPage(
() => import("./pages/OrganizationDetail.tsx"),
)
const TeamDetail = lazyPage(() => import("./pages/TeamDetail.tsx"))
const AwardDetail = lazyPage(() => import("./pages/AwardDetail.tsx"))
const PersonDetail = lazyPage(() => import("./pages/PersonDetail.tsx"))
const BlogPost = lazyPage(() => import("./pages/BlogPost.tsx"))
/*Admin Pages*/
const AdminLayout = lazyPage(() => import("./pages/admin/AdminLayout.tsx"))
const AdminLogin = lazyPage(() => import("./pages/admin/AdminLogin.tsx"))
const AdminPanel = lazyPage(() => import("./pages/admin/AdminPanel.tsx"))
const AdminHome = lazyPage(() => import("./pages/admin/AdminHome.tsx"))
const AdminFeedback = lazyPage(() => import("./pages/admin/AdminFeedback.tsx"))
const AdminMedia = lazyPage(() => import("./pages/admin/AdminMedia.tsx"))
const AdminClips = lazyPage(() => import("./pages/admin/AdminClips.tsx"))
const EntityList = lazyPage(() => import("./pages/admin/EntityList.tsx"))
const EntityEdit = lazyPage(() => import("./pages/admin/EntityEdit.tsx"))
export default function App() {
return (
<BrowserRouter>
<Routes>
{/* Layout renders the nav once and swaps page content into <Outlet /> */}
<Route element={<Layout />}>
<Route index element={<Home />} />
<Route path="retreats" element={<Retreats />} />
<Route path="/events/:id" element={<EventDetail />} />
<Route path="community" element={<Community />} />
<Route path="/regions/:id" element={<OrganizationDetail />} />
<Route path="/groups/:id" element={<OrganizationDetail />} />
<Route path="/partners/:id" element={<OrganizationDetail />} />
<Route path="/organizations/:id" element={<OrganizationDetail />} />
<Route path="/teams/:id" element={<TeamDetail />} />
<Route path="/awards/:id" element={<AwardDetail />} />
<Route path="/people/:id" element={<PersonDetail />} />
<Route path="/blog/:id" element={<BlogPost />} />
<Route path="organization" element={<Organization />} />
<Route path="resources" element={<Resources />} />
<Route path="history" element={<History />} />
<Route path="feedback" element={<Feedback />} />
<Route path="request" element={<Request />} />
<Route path="qr" element={<QrCodes />} />
<Route path="give" element={<Giving />} />
<Route path="privacy" element={<Privacy />} />
<Route path="terms" element={<Terms />} />
<Route path="*" element={<NotFound />} />
</Route>
<Route
element={
<AuthProvider>
<Suspense fallback={null}>
<Outlet />
</Suspense>
</AuthProvider>
}
>
<Route path="/admin/login" element={<AdminLogin />} />
<Route element={<RequireAuth />}>
<Route path="/admin" element={<AdminLayout />}>
<Route index element={<Navigate to="/admin/home" replace />} />
<Route path="home" element={<AdminHome />} />
<Route element={<RequireRole role="superadmin" />}>
<Route path="panel" element={<AdminPanel />} />
</Route>
<Route path="feedback" element={<AdminFeedback />} />
<Route path="data-requests" element={<AdminFeedback kind="privacy" />} />
<Route path="requests" element={<AdminFeedback kind="content" />} />
<Route path="media" element={<AdminMedia />} />
<Route element={<RequireRole role="admin" />}>
<Route path="clips" element={<AdminClips />} />
</Route>
<Route path=":entity" element={<EntityList />} />
<Route path=":entity/:id" element={<EntityEdit />} />
</Route>
</Route>
</Route>
</Routes>
</BrowserRouter>
)
}