feat(my-customers): flatten orders into per-device cards

- split orders by device_name into FlattenedDevice entries
- strip device prefixes from product and module names
- render one DeviceCard per Kasse in the customer accordion
- add targeted upgrade URL with orderId, customer_id, device_id
- wizard starts at step 3 in upgrade mode with locked customer
- mark existing licensed modules as read-only with badge
This commit is contained in:
DanielS
2026-07-23 09:45:14 +02:00
parent 086a893e19
commit 0e4495292d
7 changed files with 369 additions and 156 deletions

View File

@@ -1,8 +1,8 @@
export const dynamic = 'force-dynamic';
import { redirect } from 'next/navigation'
import Link from 'next/link'
import { getPartnerCustomersWithOrders } from '@/lib/actions/queries'
import type { EndCustomerWithOrders } from '@/lib/types'
import { getPartnerCustomersWithDevices } from '@/lib/actions/queries'
import type { EndCustomerWithDevices } from '@/lib/types'
import { ArrowLeft, Building2, Plus, AlertTriangle } from 'lucide-react'
import { Button } from '@/components/ui/button'
import { createClient } from '@/lib/supabase/server'
@@ -13,10 +13,10 @@ export default async function MyCustomersPage() {
const { data: { user } } = await supabase.auth.getUser()
if (!user) redirect('/auth/login')
let customers: EndCustomerWithOrders[] = []
let customers: EndCustomerWithDevices[] = []
let fetchError: string | null = null
try {
customers = await getPartnerCustomersWithOrders()
customers = await getPartnerCustomersWithDevices()
} catch (err: any) {
console.error("Error loading partner customers with orders:", err)
fetchError = err.message || "Es gab ein Problem beim Laden Ihrer Kunden und Kassen."