import { Suspense } from "react"; import { StaffReportView } from "@/components/StaffReportView"; import { SiteHeader, SiteFooter } from "@/components/SiteChrome"; import { isStaffKeyValid } from "@/lib/staff-auth"; interface PageProps { searchParams: Promise<{ org?: string; key?: string; frame?: string }>; } export const metadata = { title: "Staff report — Food Co-op Initiative", robots: { index: false, follow: false }, }; export default async function StaffReportPage({ searchParams }: PageProps) { const { org, key, frame } = await searchParams; const isFramed = frame === "1"; // Generic "not found" if the key is missing or wrong — don't confirm // route existence. if (!isStaffKeyValid(key)) { return ; } const orgId = Number(org); const orgValid = !!org && Number.isFinite(orgId) && orgId > 0; // CIVI_BASE_URL flows from server config to client only as a base for // outbound file links. No secret material is exposed. const civiBaseUrl = process.env.CIVI_BASE_URL ?? ""; // When embedded in CiviCRM (?frame=1), drop the site header/footer so the // report fills the iframe cleanly. Standalone visits keep full chrome. const body = (
{orgValid ? ( ) : ( )}
); if (isFramed) return body; return ( <> Skip to content {body} ); } function NotFound({ framed }: { framed: boolean }) { const inner = (

Not found

The page you requested doesn't exist.

); if (framed) return
{inner}
; return ( <>
{inner}
); } function MissingOrg() { return (

Missing or invalid org id.

Add ?org=<civi-org-id> to the URL. The org id is the Civi Contact id of the organization (visible in the URL when viewing the org in CiviCRM).

); }