since3-portal/modules/shared/queries/stammdaten.ts
2026-09-29 13:05:38 +02:00

23 lines
812 B
TypeScript

import "server-only"
import { createAdminClient } from "@/lib/supabase/admin"
import { getClientId } from "@/modules/shared/queries/profile"
export async function getStammdaten(profileId: string) {
const clientId = await getClientId(profileId)
if (!clientId) {
return { client: null, paymentDetails: null }
}
const supabase = createAdminClient()
const [clientRes, paymentRes] = await Promise.all([
supabase.from("clients").select("*").eq("id", clientId).maybeSingle(),
supabase.from("client_payment_details").select("*").eq("client_id", clientId).maybeSingle(),
])
if (clientRes.error || paymentRes.error) {
throw new Error("Stammdaten konnten nicht geladen werden.")
}
return { client: clientRes.data, paymentDetails: paymentRes.data }
}