import { Metadata } from "next"; import { TopbarNav } from "./components/TopbarNav"; import { Cog, Combine, Users, Waypoints } from "lucide-react"; import Header from "./components/Header"; import { verifySession } from "@app/lib/auth/verifySession"; import { redirect } from "next/navigation"; import { internal } from "@app/api"; import { AxiosResponse } from "axios"; import { GetOrgResponse, ListOrgsResponse } from "@server/routers/org"; import { authCookieHeader } from "@app/api/cookies"; import { cache } from "react"; export const dynamic = "force-dynamic"; export const metadata: Metadata = { title: `Settings - Pangolin`, description: "", }; const topNavItems = [ { title: "Sites", href: "/{orgId}/settings/sites", icon: , }, { title: "Resources", href: "/{orgId}/settings/resources", icon: , }, { title: "Users", href: "/{orgId}/settings/users", icon: , }, { title: "General", href: "/{orgId}/settings/general", icon: , }, ]; interface SettingsLayoutProps { children: React.ReactNode; params: Promise<{ orgId: string }>; } export default async function SettingsLayout(props: SettingsLayoutProps) { const params = await props.params; const { children } = props; const getUser = cache(verifySession); const user = await getUser(); if (!user) { redirect("/auth/login"); } const cookie = await authCookieHeader(); try { const getOrg = cache(() => internal.get>( `/org/${params.orgId}`, cookie ) ); const org = await getOrg(); } catch { redirect(`/`); } let orgs: ListOrgsResponse["orgs"] = []; try { const getOrgs = cache(() => internal.get>(`/orgs`, cookie) ); const res = await getOrgs(); if (res && res.data.data.orgs) { orgs = res.data.data.orgs; } } catch (e) { console.error("Error fetching orgs", e); } return ( <>
{children}
); }