import { me } from '@/lib/api';
import { Flash, PageHeader, type SP } from '@/components/ui';
import { KeyIcon } from '@/components/Icons';
import { SecurityPanels } from '@/components/SecurityPanels';

export default async function Settings({ searchParams }: { searchParams: SP }) {
  const sp = await searchParams;
  const user = await me();
  return (
    <>
      <PageHeader
        title="Account security"
        icon={<KeyIcon className="h-5 w-5" />}
        description="Your password, two-factor authentication, recovery codes and signed-in devices. Set ADMIN_MFA_REQUIRED=true in production to make two-factor mandatory for every staff role."
      />
      <Flash ok={sp.ok} err={sp.err} />
      <SecurityPanels user={user} basePath="/settings" setup={!!sp.setup} />
    </>
  );
}
