feat(checkout): implement wizard and admin actions
All checks were successful
Staging Build / build (push) Successful in 3m11s

This commit is contained in:
DanielS
2026-07-20 23:18:40 +02:00
parent 2b372be228
commit 86b63ce77e
5 changed files with 190 additions and 11 deletions

View File

@@ -182,8 +182,9 @@ export async function checkoutAction(params: {
items: any[];
endCustomerId: string;
customerProfile?: any;
lastLicenseDate?: string | null;
}) {
const { items, endCustomerId, customerProfile } = params;
const { items, endCustomerId, customerProfile, lastLicenseDate } = params;
const supabase = await createClient();
// 1. Session & Auth Check
@@ -256,7 +257,8 @@ export async function checkoutAction(params: {
products,
categories,
type === 'purchase' ? 'one_time' : 'monthly',
item.moduleQuantities
item.moduleQuantities,
type === 'purchase' ? lastLicenseDate : null
);
const itemsWithDevice = itemSnapshot.items.map(i => ({
...i,
@@ -273,7 +275,8 @@ export async function checkoutAction(params: {
total: total,
tax_rate: 19,
tax_amount: Math.round(total * 0.19 * 100) / 100,
subtotal: Math.round((total / 1.19) * 100) / 100
subtotal: Math.round((total / 1.19) * 100) / 100,
last_license_date: type === 'purchase' ? lastLicenseDate : null
};
const orderNumber = generateOrderNumber(type === 'purchase' ? 'AE' : 'BE');

View File

@@ -42,7 +42,7 @@ export async function POST(request: Request) {
}
const body = await request.json();
const { items, customerProfile, endCustomerId, endCustomer } = body;
const { items, customerProfile, endCustomerId, endCustomer, lastLicenseDate } = body;
if (!items || !Array.isArray(items) || items.length === 0) {
return NextResponse.json({ error: 'Warenkorb leer' }, { status: 400 });
@@ -84,7 +84,8 @@ export async function POST(request: Request) {
products,
categories,
type === 'purchase' ? 'one_time' : 'monthly',
item.moduleQuantities
item.moduleQuantities,
type === 'purchase' ? lastLicenseDate : null
);
const itemsWithDevice = itemSnapshot.items.map(i => ({
...i,
@@ -101,7 +102,8 @@ export async function POST(request: Request) {
total: total,
tax_rate: 19, // default
tax_amount: Math.round(total * 0.19 * 100) / 100,
subtotal: Math.round((total / 1.19) * 100) / 100
subtotal: Math.round((total / 1.19) * 100) / 100,
last_license_date: type === 'purchase' ? lastLicenseDate : null
};
const orderHash = hashOrderSnapshot(orderSnapshot);