feat: implement product categories with tabbed filtering and admin configuration
This commit is contained in:
@@ -8,13 +8,24 @@ export async function getProducts() {
|
||||
const supabase = await createClient()
|
||||
const { data, error } = await supabase
|
||||
.from('products')
|
||||
.select('*, modules:product_modules(*)')
|
||||
.select('*, category:categories(*), modules:product_modules(*)')
|
||||
.order('created_at', { ascending: false })
|
||||
|
||||
if (error) throw error
|
||||
return data as Product[]
|
||||
}
|
||||
|
||||
export async function getCategories() {
|
||||
const supabase = await createClient()
|
||||
const { data, error } = await supabase
|
||||
.from('categories')
|
||||
.select('*')
|
||||
.order('name', { ascending: true })
|
||||
|
||||
if (error) throw error
|
||||
return data
|
||||
}
|
||||
|
||||
export async function createProduct(product: Omit<Product, 'id' | 'created_at' | 'updated_at'>, modules: Omit<ProductModule, 'id' | 'product_id' | 'created_at'>[]) {
|
||||
const supabase = await createClient()
|
||||
|
||||
@@ -59,8 +70,10 @@ export async function updateProduct(id: string, product: Partial<Product>, modul
|
||||
const modulesWithId = modules.map(m => ({
|
||||
name: m.name,
|
||||
description: m.description,
|
||||
additional_price: m.additional_price,
|
||||
price: m.additional_price, // Match schema column name 'price'
|
||||
is_required: m.is_required,
|
||||
requirements: m.requirements || [],
|
||||
exclusions: m.exclusions || [],
|
||||
product_id: id
|
||||
}))
|
||||
const { error: modulesError } = await supabase
|
||||
|
||||
Reference in New Issue
Block a user