feat(checkout): implement wizard and admin actions
All checks were successful
Staging Build / build (push) Successful in 3m11s
All checks were successful
Staging Build / build (push) Successful in 3m11s
This commit is contained in:
36
shop/lib/actions/queries.ts
Normal file
36
shop/lib/actions/queries.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
'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[]
|
||||
}
|
||||
Reference in New Issue
Block a user