import { prisma } from "@/server/db"

export async function getTenantSmtp2goSubaccountId(tenantId: string) {
  const row = await prisma.smtp2goSubaccount.findUnique({
    where: { tenantId },
    select: { subaccountId: true },
  })

  const subaccountId = row?.subaccountId?.trim()
  if (!subaccountId) throw new Error("TENANT_MISSING_SUBACCOUNT_ID")

  return subaccountId
}
