import { getClientId } from "@/modules/shared/queries/profile"
import { getInvoices, getProductTemplates, peekNextInvoiceNumber } from "@/modules/shared/queries/invoices"
import { getStammdaten } from "@/modules/shared/queries/stammdaten"
import { BillingDialog, type BillingPrefill } from "@/modules/shared/ui/components/billing-dialog"
import { InvoicesTable } from "@/modules/shared/ui/components/invoices-table"
async function AdminBillingDialog({ profileId }: { profileId: string }) {
const [stammdaten, templates, nextInvoiceNumber] = await Promise.all([
getStammdaten(profileId),
getProductTemplates(),
peekNextInvoiceNumber(),
])
const client = stammdaten?.client
const prefill: BillingPrefill | null = client
? {
companyName: client.company_name,
billingStreet: client.billing_street ?? client.street,
billingPostalCode: client.billing_postal_code ?? client.postal_code,
billingCity: client.billing_city ?? client.city,
billingCountry: client.billing_country ?? client.country,
}
: null
return (