import { notFound } from 'next/navigation';

import { RoleGate } from '@/components/auth/RoleGate';
import { FeaturePreviewPage } from '@/components/preview/FeaturePreviewPage';

const sections = {
  organizations: {
    eyebrow: 'Client Admin',
    title: 'Organization Management',
    description:
      'Manage client-level organization settings, tenant boundaries, and workspace ownership from one place.',
    bullets: [
      'Client records are the commercial boundary for contracts, billing, and entitlements.',
      'Tenant records remain the identity and security boundary for domains, RBAC, and residency controls.',
      'Use this area to review organization structure before deeper billing and compliance workflows.',
    ],
  },
  users: {
    eyebrow: 'Client Admin',
    title: 'User Management',
    description:
      'Invite users, manage role assignments, and align access with tenant-aware workspace boundaries.',
    bullets: [
      'Client admins manage who can access which tenant and which workspace areas.',
      'Role assignment should stay aligned with Keycloak claims and portal session context.',
      'Auditability and least-privilege access are part of the supported model.',
    ],
  },
  billing: {
    eyebrow: 'Client Admin',
    title: 'Billing & Subscriptions',
    description:
      'Review subscriptions, invoices, and the commercial state attached to the client boundary.',
    bullets: [
      'Billing is moving from tenant-scoped ownership to client and subscription-scoped ownership.',
      'Request-only and operator-provisioned offers should never appear as instant self-service purchases.',
      'Invoice and payment views will align with the canonical subscription model.',
    ],
  },
  compliance: {
    eyebrow: 'Client Admin',
    title: 'Compliance & Reporting',
    description:
      'Track audit posture, policy acknowledgements, and exportable reporting for regulated workloads.',
    bullets: [
      'Compliance state should align with tenant security controls and subscription obligations.',
      'Exports and evidence should be client-aware and tenant-aware.',
      'Residency and sovereignty decisions belong here, not in ad hoc support flows.',
    ],
  },
} as const;

export default function AdminSectionPage({
  params,
}: {
  params: { section: keyof typeof sections };
}) {
  const section = sections[params.section];
  if (!section) notFound();

  return (
    <RoleGate
      allowedRoles={['admin', 'tenant-admin', 'ADMIN', 'TENANT_ADMIN']}
      callbackUrl={`/admin/${params.section}`}
      badge="Admin"
      title="Admin access required"
      subtitle="Sign in with a client-admin or internal-admin account to open this workspace."
    >
      <FeaturePreviewPage
        eyebrow={section.eyebrow}
        title={section.title}
        description={section.description}
        bullets={section.bullets}
        primaryAction={{ href: '/admin', label: 'Back to Admin Overview' }}
        secondaryAction={{ href: '/help/support', label: 'Contact Platform Support' }}
      />
    </RoleGate>
  );
}
