import { requireSession } from "@/lib/session"; import { apiFetch } from "@/lib/api"; import type { Tenant } from "@/lib/platform-types"; import type { PlanVersion, TenantSubscription } from "@/lib/billing-types"; import { AssinaturasView } from "./assinaturas-view"; export default async function AssinaturasPage({ searchParams }: { searchParams: Promise<{ tenantId?: string }> }) { const { tenantId } = await searchParams; const session = await requireSession(); const tenants = await apiFetch("/tenants", session.accessToken); const selectedTenant = tenantId ? (tenants.find((t) => t.id === tenantId) ?? null) : null; const [subscriptions, planVersions] = tenantId ? await Promise.all([ apiFetch(`/billing/subscriptions/by-tenant/${tenantId}`, session.accessToken), selectedTenant ? apiFetch(`/billing/plan-versions/by-plan/${selectedTenant.planId}`, session.accessToken) : Promise.resolve([]), ]) : [[], []]; return ( ); }