Files
EpicNext-Cms/src/app/admin-next/layout.tsx
T
Simo 9af1e62655
CI / check (push) Successful in 29s
CI / deploy (push) Successful in 56s
CI / release (push) Skipped
feat: allow rank-gated housekeeping preview in production
2026-08-31 20:29:38 +02:00

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;
}