Files
webshop/shop/lib/actions/queries.ts
DanielS 86b63ce77e
All checks were successful
Staging Build / build (push) Successful in 3m11s
feat(checkout): implement wizard and admin actions
2026-07-20 23:18:40 +02:00

37 lines
941 B
TypeScript

'use server'
import { createClient } from '@/lib/supabase/server'
import type { Order, EndCustomer } from '@/lib/types'
/**
* Holt alle Bestellanfragen.
* RLS filtert automatisch auf die eigene Firma (bzw. lässt Admins alle sehen).
*/
export async function getCompanyOrders(): Promise<Order[]> {
const supabase = await createClient()
const { data, error } = await supabase
.from('orders')
.select('*')
.order('created_at', { ascending: false })
if (error) throw error
return data as Order[]
}
/**
* Holt alle Endkunden.
* RLS filtert automatisch auf die eigene Firma (bzw. lässt Admins alle sehen).
*/
export async function getCompanyEndCustomers(): Promise<EndCustomer[]> {
const supabase = await createClient()
const { data, error } = await supabase
.from('end_customers')
.select('*')
.order('company_name', { ascending: true })
if (error) throw error
return data as EndCustomer[]
}