mirror of
https://github.com/Since-3/since3-portal.git
synced 2026-10-12 20:51:17 +00:00
23 lines
812 B
TypeScript
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 }
|
|
}
|