since3-portal/modules/admin/queries/internal-credentials.ts
2026-10-11 18:22:32 +02:00

30 lines
No EOL
958 B
TypeScript

import "server-only";
import { BillingCycle, Plan } from "../lib/internal-costs";
import { createClient } from "@/lib/supabase/server";
export type InternalCredential = {
id: string;
service: string;
title: string;
username: string;
url: string;
plan: Plan;
price: number | null;
billing_cycle: BillingCycle | null;
updated_at: string;
}
export async function getInternalCredentials() {
const supabase = await createClient()
const { data, error } = await supabase
.from("internal_credentials")
.select("id, service, title, username, url, plan, price, billing_cycle, updated_at")
.order("service")
.order("title")
if (error) throw new Error("Interne Zugänge konnten nicht geladen werden.")
// Numeric kann je nach Größe als String ankommen
return (data as InternalCredential[]).map((row) => ({ ...row, price: row.price === null ? null : Number(row.price)}))
}