mirror of
https://github.com/Since-3/since3-portal.git
synced 2026-10-12 20:51:17 +00:00
25 lines
838 B
TypeScript
25 lines
838 B
TypeScript
import "server-only"
|
|
import { createAdminClient } from "@/lib/supabase/admin"
|
|
|
|
export async function getStammdaten(profileId: string) {
|
|
const supabase = createAdminClient()
|
|
|
|
const { data: profile, error: profileError } = await supabase
|
|
.from("profiles")
|
|
.select("client_id")
|
|
.eq("id", profileId)
|
|
.single()
|
|
|
|
if (profileError || !profile) return null
|
|
|
|
if (!profile.client_id) {
|
|
return { client: null, paymentDetails: null }
|
|
}
|
|
|
|
const [{ data: client }, { data: paymentDetails }] = await Promise.all([
|
|
supabase.from("clients").select("*").eq("id", profile.client_id).single(),
|
|
supabase.from("client_payment_details").select("*").eq("client_id", profile.client_id).single(),
|
|
])
|
|
|
|
return { client: client ?? null, paymentDetails: paymentDetails ?? null }
|
|
}
|