add server side fetching

This commit is contained in:
miloschwartz
2026-06-30 21:15:03 -04:00
parent f0efa4203b
commit fed4ec42c4
8 changed files with 411 additions and 313 deletions

View File

@@ -0,0 +1,9 @@
import { Loader2 } from "lucide-react";
export default function OrgPageLoading() {
return (
<div className="flex items-center justify-center py-16">
<Loader2 className="size-6 animate-spin text-muted-foreground" />
</div>
);
}

View File

@@ -2,8 +2,8 @@ import { Layout } from "@app/components/Layout";
import ResourceLauncher from "@app/components/resource-launcher/ResourceLauncher";
import { internal } from "@app/lib/api";
import { authCookieHeader } from "@app/lib/api/cookies";
import { fetchLauncherPageData } from "@app/lib/launcherServerData";
import { verifySession } from "@app/lib/auth/verifySession";
import { pullEnv } from "@app/lib/pullEnv";
import UserProvider from "@app/providers/UserProvider";
import { ListUserOrgsResponse } from "@server/routers/org";
import { GetOrgOverviewResponse } from "@server/routers/org/getOrgOverview";
@@ -13,8 +13,11 @@ import { cache } from "react";
type OrgPageProps = {
params: Promise<{ orgId: string }>;
searchParams: Promise<Record<string, string>>;
};
export const dynamic = "force-dynamic";
export default async function OrgPage(props: OrgPageProps) {
const params = await props.params;
const orgId = params.orgId;
@@ -55,6 +58,15 @@ export default async function OrgPage(props: OrgPageProps) {
const isAdminOrOwner = Boolean(overview?.isAdmin || overview?.isOwner);
const searchParams = new URLSearchParams(await props.searchParams);
const launcherData = overview
? await fetchLauncherPageData(
orgId,
searchParams,
await authCookieHeader()
)
: null;
return (
<UserProvider user={user}>
<Layout
@@ -65,8 +77,18 @@ export default async function OrgPage(props: OrgPageProps) {
launcherMode
showViewAsAdmin={isAdminOrOwner}
>
{overview ? (
<ResourceLauncher orgId={orgId} isAdmin={isAdminOrOwner} />
{overview && launcherData ? (
<ResourceLauncher
orgId={orgId}
isAdmin={isAdminOrOwner}
views={launcherData.views}
activeViewId={launcherData.activeViewId}
config={launcherData.config}
savedConfig={launcherData.savedConfig}
groups={launcherData.groups}
groupsPagination={launcherData.groupsPagination}
resourcesByGroupKey={launcherData.resourcesByGroupKey}
/>
) : null}
</Layout>
</UserProvider>