feat: initial implementation of modern modular webshop (shop core)

This commit is contained in:
DanielS
2026-04-30 23:41:56 +02:00
commit 5538d87283
72 changed files with 12853 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
'use server'
import { createClient } from '@/lib/supabase/server'
import { revalidatePath } from 'next/cache'
import { Order } from '../types'
export async function submitOrder(orderData: {
product_id: string;
selected_modules: string[];
total_amount: number;
customer_details: any;
}) {
const supabase = await createClient()
const { data: { user } } = await supabase.auth.getUser()
if (!user) throw new Error('Not authenticated')
const { data, error } = await supabase
.from('orders')
.insert([{
user_id: user.id,
total_amount: orderData.total_amount,
items: {
product_id: orderData.product_id,
modules: orderData.selected_modules
},
billing_details: orderData.customer_details,
status: 'pending'
}])
.select()
.single()
if (error) throw error
revalidatePath('/admin/orders') // If there was an admin orders page
return data
}