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:
@@ -8,7 +8,7 @@ import { redirect } from 'next/navigation'
|
||||
import { Suspense } from 'react'
|
||||
|
||||
interface PageProps {
|
||||
searchParams: Promise<{ id?: string; orderId?: string; mode?: string }>
|
||||
searchParams: Promise<{ id?: string; orderId?: string; mode?: string; customer_id?: string; device_id?: string }>
|
||||
}
|
||||
|
||||
export default async function OrderPage({ searchParams }: PageProps) {
|
||||
@@ -27,14 +27,29 @@ export default async function OrderPage({ searchParams }: PageProps) {
|
||||
</div>
|
||||
|
||||
<Suspense fallback={<div className="h-96 w-full animate-pulse bg-white/5 rounded-2xl" />}>
|
||||
<OrderDataWrapper orderId={orderId} mode={params.mode} />
|
||||
<OrderDataWrapper
|
||||
orderId={orderId}
|
||||
mode={params.mode}
|
||||
customerId={params.customer_id}
|
||||
deviceId={params.device_id}
|
||||
/>
|
||||
</Suspense>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
async function OrderDataWrapper({ orderId, mode }: { orderId?: string; mode?: string }) {
|
||||
async function OrderDataWrapper({
|
||||
orderId,
|
||||
mode,
|
||||
customerId,
|
||||
deviceId,
|
||||
}: {
|
||||
orderId?: string
|
||||
mode?: string
|
||||
customerId?: string
|
||||
deviceId?: string
|
||||
}) {
|
||||
const supabase = await createClient()
|
||||
const { data: { user } } = await supabase.auth.getUser()
|
||||
|
||||
@@ -84,7 +99,7 @@ async function OrderDataWrapper({ orderId, mode }: { orderId?: string; mode?: st
|
||||
redirect('/order')
|
||||
}
|
||||
|
||||
if (orderData.status === 'completed' && !isAdmin && mode !== 'extension') {
|
||||
if (orderData.status === 'completed' && !isAdmin && mode !== 'extension' && mode !== 'upgrade') {
|
||||
redirect('/order')
|
||||
}
|
||||
|
||||
@@ -139,6 +154,9 @@ async function OrderDataWrapper({ orderId, mode }: { orderId?: string; mode?: st
|
||||
initialOrder={initialOrder}
|
||||
isAdmin={userData?.role === 'admin'}
|
||||
companies={companies}
|
||||
upgradeMode={mode === 'upgrade'}
|
||||
initialEndCustomerId={customerId || null}
|
||||
lockedDeviceId={deviceId ? decodeURIComponent(deviceId) : null}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user