32 lines
862 B
TypeScript
32 lines
862 B
TypeScript
import { notFound } from "next/navigation";
|
|
import type { ReactNode } from "react";
|
|
import { env } from "@/env";
|
|
import { isHousekeepingPreviewEnabled } from "@/features/housekeeping/foundation/preview-gate";
|
|
import { getHousekeepingCapabilityContext } from "@/features/housekeeping/foundation/server-capability-context";
|
|
import { PERMS } from "@/lib/permission-slugs";
|
|
|
|
export default async function AdminNextLayout({
|
|
children,
|
|
}: {
|
|
children: ReactNode;
|
|
}) {
|
|
const hasProductionAccess =
|
|
env.NODE_ENV === "production" && env.HOUSEKEEPING_NEXT_PREVIEW_ENABLED
|
|
? (await getHousekeepingCapabilityContext()).has(
|
|
PERMS.HOUSEKEEPING_PREVIEW_ACCESS,
|
|
)
|
|
: false;
|
|
|
|
if (
|
|
!isHousekeepingPreviewEnabled({
|
|
nodeEnv: env.NODE_ENV,
|
|
flag: env.HOUSEKEEPING_NEXT_PREVIEW_ENABLED,
|
|
hasProductionAccess,
|
|
})
|
|
) {
|
|
notFound();
|
|
}
|
|
|
|
return children;
|
|
}
|