import { AppShell } from "@/components/app-shell"
import { SiteHeader } from "@/components/site-header"
import { AdminDevicesOverview } from "@/components/admin/devices/admin-devices-overview"
import { DEFAULT_TENANT_ID } from "@/lib/constants"

export const runtime = "nodejs"
export const dynamic = "force-dynamic"

export default async function AdminDevicesPage({
  searchParams,
}: { searchParams: Promise<Record<string, string | string[] | undefined>> }) {
  const params = await searchParams
  const companyParam = params.company
  const company = typeof companyParam === "string" ? companyParam : undefined
  const autoOpenCreateDevice = params.quick === "new-device"
  return (
    <AppShell
      header={
        <SiteHeader
          title="Parque de dispositivos"
          lead="Acompanhe computadores e celulares monitorados, métricas recentes e a sincronização do agente."
        />
      }
    >
      <div className="mx-auto w-full max-w-6xl px-4 pb-12 lg:px-6">
        <AdminDevicesOverview
          tenantId={DEFAULT_TENANT_ID}
          initialCompanyFilterSlug={company ?? "all"}
          autoOpenCreateDevice={autoOpenCreateDevice}
        />
      </div>
    </AppShell>
  )
}
