mirror of
https://github.com/Since-3/since3-portal.git
synced 2026-10-12 20:51:17 +00:00
31 lines
912 B
TypeScript
31 lines
912 B
TypeScript
import "server-only"
|
|
import { createClient } from "@/lib/supabase/server"
|
|
|
|
export type AdminProductTemplate = {
|
|
id: string
|
|
name: string
|
|
description: string | null
|
|
unitPrice: number
|
|
taxRate: number
|
|
isActive: boolean
|
|
}
|
|
|
|
export async function getAllProductTemplates(): Promise<AdminProductTemplate[]> {
|
|
const supabase = await createClient()
|
|
const { data, error } = await supabase
|
|
.from("product_templates")
|
|
.select("id, name, description, unit_price, tax_rate, is_active")
|
|
.order("is_active", { ascending: false })
|
|
.order("name")
|
|
|
|
if (error) throw new Error("Produktvorlagen konnten nicht geladen werden.")
|
|
|
|
return data.map((row) => ({
|
|
id: row.id,
|
|
name: row.name,
|
|
description: row.description,
|
|
unitPrice: Number(row.unit_price),
|
|
taxRate: Number(row.tax_rate),
|
|
isActive: row.is_active,
|
|
}))
|
|
}
|