added resource auth status cards and moved login to reusable login form

This commit is contained in:
Milo Schwartz
2024-11-23 17:56:21 -05:00
parent 795c144e1e
commit 78b23a8956
14 changed files with 507 additions and 454 deletions

View File

@@ -0,0 +1,33 @@
import { internal } from "@app/api";
import { authCookieHeader } from "@app/api/cookies";
import { GetOrgResponse } from "@server/routers/org";
import { AxiosResponse } from "axios";
import { redirect } from "next/navigation";
import { cache } from "react";
export default async function OrgLayout(props: {
children: React.ReactNode;
params: Promise<{ orgId: string }>;
}) {
const cookie = await authCookieHeader();
const params = await props.params;
const orgId = params.orgId;
if (!orgId) {
redirect(`/`);
}
try {
const getOrg = cache(() =>
internal.get<AxiosResponse<GetOrgResponse>>(
`/org/${orgId}`,
cookie,
),
);
await getOrg();
} catch {
redirect(`/`);
}
return <>{props.children}</>;
}