refactor(wizard): optimize ui ux with no-page-scroll and hub flow
All checks were successful
Staging Build / build (push) Successful in 3m16s
All checks were successful
Staging Build / build (push) Successful in 3m16s
This commit is contained in:
@@ -1,11 +1,32 @@
|
||||
'use client'
|
||||
|
||||
import React from 'react'
|
||||
import React, { useState } from 'react'
|
||||
import { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter } from '@/components/ui/card'
|
||||
import { Separator } from '@/components/ui/separator'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Badge } from '@/components/ui/badge'
|
||||
import { ShieldCheck, Building2, Calendar, Loader2, CheckCircle2 } from 'lucide-react'
|
||||
import { Checkbox } from '@/components/ui/checkbox'
|
||||
import { Label } from '@/components/ui/label'
|
||||
import {
|
||||
ShieldCheck,
|
||||
Building2,
|
||||
Calendar,
|
||||
Loader2,
|
||||
CheckCircle2,
|
||||
Pencil,
|
||||
Trash2,
|
||||
Plus,
|
||||
ChevronLeft,
|
||||
MessageSquare,
|
||||
FileText,
|
||||
Lock,
|
||||
Check,
|
||||
X,
|
||||
CreditCard,
|
||||
User,
|
||||
MapPin,
|
||||
Send,
|
||||
} from 'lucide-react'
|
||||
import * as Icons from 'lucide-react'
|
||||
import { Category, Product, EndCustomer, Profile } from '@/lib/types'
|
||||
|
||||
@@ -70,300 +91,424 @@ export function StepSummary({
|
||||
onAddNewBasketItem,
|
||||
onDeleteBasketItem,
|
||||
}: StepSummaryProps) {
|
||||
const [confirmDeleteIdx, setConfirmDeleteIdx] = React.useState<number | null>(null)
|
||||
const [confirmDeleteIdx, setConfirmDeleteIdx] = useState<number | null>(null)
|
||||
const [acceptedTerms, setAcceptedTerms] = useState(false)
|
||||
|
||||
const fmt = (val: number) => new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(val)
|
||||
|
||||
const totalPositionsCount = finalItemsToShow.length
|
||||
const primaryInterval = finalItemsToShow[0]?.billingInterval || 'monthly'
|
||||
|
||||
return (
|
||||
<div className="grid grid-cols-1 lg:grid-cols-12 gap-6 h-full items-stretch text-left">
|
||||
{/* LINKER BEREICH: Scrollbares Bedienfeld */}
|
||||
<div className="lg:col-span-5 flex flex-col h-full overflow-hidden pr-4 space-y-6">
|
||||
<div className="flex-1 overflow-y-auto pr-1 space-y-6 pb-4 subpixel-antialiased scrollbar-thin scrollbar-thumb-white/10 scrollbar-track-transparent">
|
||||
|
||||
{/* Header & Status Stepper */}
|
||||
<div className="space-y-4">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="w-12 h-12 bg-primary/20 rounded-xl flex items-center justify-center border border-primary/50 shrink-0">
|
||||
<ShieldCheck className="w-6 h-6 text-primary" />
|
||||
</div>
|
||||
<div>
|
||||
<h2 className="text-2xl font-extrabold text-white tracking-tight">
|
||||
Anfrage prüfen
|
||||
</h2>
|
||||
<p className="text-slate-400 text-xs mt-0.5">
|
||||
Fast fertig! Bitte überprüfen Sie Ihre ausgewählte Konfiguration.
|
||||
</p>
|
||||
</div>
|
||||
<Card className="glass-dark border-white/10 h-[calc(100vh-8.5rem)] flex flex-col justify-between overflow-hidden relative">
|
||||
{/* ─── 1. FIXED HEADER (shrink-0) ─── */}
|
||||
<CardHeader className="pb-3 pt-4 px-6 shrink-0 border-b border-white/10 bg-slate-950/40 space-y-0">
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="w-10 h-10 bg-primary/20 rounded-xl flex items-center justify-center border border-primary/40 shrink-0 text-primary">
|
||||
<ShieldCheck className="w-5 h-5" />
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
{/* Kunden-Info Card */}
|
||||
{selectedEndCustomer && (
|
||||
<div className="p-4 rounded-xl bg-white/5 border border-white/10 space-y-2">
|
||||
<div className="flex items-center gap-2 text-primary font-bold text-xs uppercase tracking-wider">
|
||||
<Building2 className="w-4 h-4" />
|
||||
<span>Ausgewählter Endkunde</span>
|
||||
</div>
|
||||
<p className="text-white font-bold text-sm">{selectedEndCustomer.company_name}</p>
|
||||
<p className="text-slate-400 text-xs">Ansprechpartner: {[selectedEndCustomer.first_name, selectedEndCustomer.last_name].filter(Boolean).join(' ')}</p>
|
||||
<p className="text-slate-400 text-xs">Adresse: {[selectedEndCustomer.street, [selectedEndCustomer.zip, selectedEndCustomer.city].filter(Boolean).join(' ')].filter(Boolean).join(', ')}</p>
|
||||
<div>
|
||||
<CardTitle className="text-xl font-bold text-white flex items-center gap-2">
|
||||
Anfrage prüfen & absenden
|
||||
</CardTitle>
|
||||
<CardDescription className="text-xs text-slate-300 mt-0.5">
|
||||
Überprüfen Sie alle konfigurierten Kassen, Positionen und Konditionen vor der Freigabe.
|
||||
</CardDescription>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Anmerkungen / Notizfeld */}
|
||||
<div className="space-y-2 pt-2">
|
||||
<label htmlFor="order-notes" className="block text-xs font-bold text-white uppercase tracking-wider">
|
||||
Anmerkungen / Hinweise (optional)
|
||||
</label>
|
||||
<textarea
|
||||
id="order-notes"
|
||||
rows={4}
|
||||
value={orderNotes}
|
||||
onChange={e => setOrderNotes(e.target.value)}
|
||||
placeholder="Besondere Hinweise, Ansprechpartner oder Terminwünsche hier eintragen..."
|
||||
className="w-full p-3 rounded-xl bg-white/5 border border-white/10 text-xs text-white placeholder-slate-500 focus:border-primary focus:outline-none transition-colors duration-200 resize-none shadow-inner"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<p className="text-[10px] text-slate-500 leading-relaxed">
|
||||
Mit dem Klick auf „{initialOrder ? 'Anfrage aktualisieren' : 'Kostenpflichtig bestellen'}“ akzeptieren Sie unsere AGB und die{' '}
|
||||
<a href="/datenschutz" target="_blank" rel="noopener noreferrer" className="underline hover:text-slate-400">
|
||||
Datenschutzerklärung
|
||||
</a>.
|
||||
</p>
|
||||
|
||||
{/* Aktions-Buttons */}
|
||||
<div className="space-y-3 pt-2">
|
||||
<Button
|
||||
className="w-full h-12 text-sm font-bold bg-primary hover:bg-primary/90 shadow-[0_0_15px_rgba(59,130,246,0.2)] rounded-xl"
|
||||
onClick={handleSubmit}
|
||||
disabled={isSubmitting}
|
||||
>
|
||||
{isSubmitting ? (
|
||||
initialOrder ? (
|
||||
<><Loader2 className="mr-2 h-4 w-4 animate-spin" /> Anfrage wird aktualisiert...</>
|
||||
) : (
|
||||
<><Loader2 className="mr-2 h-4 w-4 animate-spin" /> Anfrage wird versendet...</>
|
||||
)
|
||||
) : (
|
||||
initialOrder ? 'Anfrage aktualisieren' : 'Kostenpflichtig bestellen'
|
||||
)}
|
||||
</Button>
|
||||
<Button variant="ghost" className="w-full text-slate-400 hover:text-white text-xs h-10" onClick={prevStep}>
|
||||
Noch etwas ändern
|
||||
</Button>
|
||||
</div>
|
||||
<Badge variant="outline" className="border-primary/30 text-primary bg-primary/10 text-xs px-3 py-1">
|
||||
Schritt 4 von 4
|
||||
</Badge>
|
||||
</div>
|
||||
</div>
|
||||
</CardHeader>
|
||||
|
||||
{/* RECHTER BEREICH: Eigenständig scrollbare Zusammenfassung der Anfrage */}
|
||||
<div className="lg:col-span-7 flex flex-col h-full overflow-hidden pl-4">
|
||||
<Card className="glass-dark border-white/10 shadow-2xl overflow-hidden rounded-2xl flex flex-col h-full">
|
||||
<CardHeader className="shrink-0 border-b border-white/5 pb-4">
|
||||
<CardTitle className="text-lg text-white flex items-center justify-between font-bold flex-wrap gap-2">
|
||||
<div className="flex items-center gap-2">
|
||||
<span>Zusammenfassung der Positionen</span>
|
||||
<Badge className="bg-primary/20 text-primary border border-primary/30 text-xs rounded-full">
|
||||
{finalItemsToShow.length} {finalItemsToShow.length === 1 ? 'Kasse' : 'Kassen'}
|
||||
</Badge>
|
||||
{/* ─── 2. SCROLLABLE MIDDLE (flex-1 min-h-0 overflow-y-auto) ─── */}
|
||||
<div className="flex-1 min-h-0 overflow-y-auto p-6 scrollbar-thin scrollbar-thumb-slate-800 scrollbar-track-transparent">
|
||||
<div className="grid grid-cols-1 lg:grid-cols-12 gap-6 max-w-7xl mx-auto w-full items-start">
|
||||
{/* ─── LINKES RASTER (lg:col-span-7) – Auftragsübersicht & Kassen ─── */}
|
||||
<div className="lg:col-span-7 space-y-5">
|
||||
{/* Kopf-Card: Endkunde & Abrechnungsmodell */}
|
||||
<div className="p-4 rounded-2xl bg-white/5 border border-white/10 space-y-3">
|
||||
<div className="flex items-center justify-between gap-2 border-b border-white/5 pb-2.5 flex-wrap">
|
||||
<div className="flex items-center gap-2 text-primary font-bold text-xs uppercase tracking-wider">
|
||||
<Building2 className="w-4 h-4" />
|
||||
<span>Kunde & Abrechnung</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Badge variant="outline" className="text-[10px] bg-primary/10 border-primary/30 text-primary font-semibold">
|
||||
{primaryInterval === 'one_time' ? 'Einmalkauf' : 'Monatliches Abo'}
|
||||
</Badge>
|
||||
{lastLicenseDate && (
|
||||
<Badge variant="outline" className="text-[10px] bg-emerald-500/10 border-emerald-500/30 text-emerald-400">
|
||||
Stichtag: {new Date(lastLicenseDate).toLocaleDateString('de-DE')}
|
||||
</Badge>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
{onAddNewBasketItem && (
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={onAddNewBasketItem}
|
||||
className="border-dashed border-primary/50 text-primary hover:bg-primary/10 text-xs font-bold gap-1.5 h-8 rounded-lg"
|
||||
>
|
||||
<Icons.UserPlus className="w-3.5 h-3.5" /> + Weitere Kasse anlegen
|
||||
</Button>
|
||||
)}
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
|
||||
{/* Scrollbarer Content der Aufschlüsselung */}
|
||||
<CardContent className="space-y-6 text-left flex-1 overflow-y-auto pt-6 subpixel-antialiased scrollbar-thin scrollbar-thumb-white/10 scrollbar-track-transparent pr-2">
|
||||
<div className="space-y-6">
|
||||
{finalItemsToShow.map((item, itemIdx) => (
|
||||
<div key={itemIdx} className="space-y-3 border-b border-white/5 pb-5 last:border-0 last:pb-0">
|
||||
<div
|
||||
onClick={() => onEditBasketItem && onEditBasketItem(itemIdx)}
|
||||
className={`flex justify-between items-center bg-white/5 p-3 rounded-xl border border-white/10 ${onEditBasketItem ? 'cursor-pointer hover:border-primary/50 hover:bg-white/10 transition-all group' : ''}`}
|
||||
>
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-white font-bold text-sm">Kasse: {item.deviceName}</span>
|
||||
{item.licenseNumber && (
|
||||
<span className="text-[10px] text-slate-400">({item.licenseNumber})</span>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<span className={`text-[10px] px-2 py-0.5 rounded border ${item.billingInterval === 'one_time' ? 'border-amber-500/30 text-amber-400 bg-amber-500/10' : 'border-emerald-500/30 text-emerald-400 bg-emerald-500/10'} font-semibold uppercase`}>
|
||||
{item.billingInterval === 'one_time' ? 'Kauf' : 'Abo'}
|
||||
{selectedEndCustomer ? (
|
||||
<div className="space-y-1">
|
||||
<h4 className="text-sm font-bold text-white">{selectedEndCustomer.company_name}</h4>
|
||||
<div className="flex items-center gap-3 text-xs text-slate-300 flex-wrap">
|
||||
{(selectedEndCustomer.first_name || selectedEndCustomer.last_name) && (
|
||||
<span className="flex items-center gap-1">
|
||||
<User className="w-3 h-3 text-slate-400" />
|
||||
{[selectedEndCustomer.first_name, selectedEndCustomer.last_name].filter(Boolean).join(' ')}
|
||||
</span>
|
||||
{onEditBasketItem && (
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="h-7 px-2 text-xs text-slate-300 group-hover:text-primary group-hover:bg-primary/20 gap-1 rounded-lg"
|
||||
>
|
||||
<Icons.Pencil className="w-3 h-3" /> Bearbeiten
|
||||
</Button>
|
||||
)}
|
||||
{onDeleteBasketItem && (
|
||||
<Button
|
||||
type="button"
|
||||
variant={confirmDeleteIdx === itemIdx ? "destructive" : "ghost"}
|
||||
size="sm"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
if (confirmDeleteIdx === itemIdx) {
|
||||
onDeleteBasketItem(itemIdx)
|
||||
setConfirmDeleteIdx(null)
|
||||
} else {
|
||||
setConfirmDeleteIdx(itemIdx)
|
||||
}
|
||||
}}
|
||||
onMouseLeave={() => setConfirmDeleteIdx(null)}
|
||||
className={`h-7 px-2 text-xs transition-all ${
|
||||
confirmDeleteIdx === itemIdx
|
||||
? 'bg-red-600 text-white hover:bg-red-700 font-bold px-3 shadow-[0_0_10px_rgba(220,38,38,0.5)]'
|
||||
: 'text-slate-400 hover:text-red-400 hover:bg-red-500/20'
|
||||
} gap-1 rounded-lg`}
|
||||
>
|
||||
<Icons.Trash2 className="w-3.5 h-3.5" />
|
||||
{confirmDeleteIdx === itemIdx ? 'Wirklich löschen?' : 'Löschen'}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{(selectedEndCustomer.street || selectedEndCustomer.zip || selectedEndCustomer.city) && (
|
||||
<span className="flex items-center gap-1">
|
||||
<MapPin className="w-3 h-3 text-slate-400" />
|
||||
{[selectedEndCustomer.street, [selectedEndCustomer.zip, selectedEndCustomer.city].filter(Boolean).join(' ')].filter(Boolean).join(', ')}
|
||||
</span>
|
||||
)}
|
||||
{selectedEndCustomer.vat_id && (
|
||||
<span className="text-slate-400">USt-IdNr: {selectedEndCustomer.vat_id}</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<p className="text-xs text-slate-400 italic">Kein Endkunde zugewiesen (Partner-Bestellung).</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{visibleCategories.map(cat => {
|
||||
const sel = item.selections[cat.id]
|
||||
const selectedProds: Product[] = []
|
||||
if (cat.allow_multiselect && sel?.productIds) {
|
||||
sel.productIds.forEach((pId: string) => {
|
||||
const p = products.find(prod => prod.id === pId)
|
||||
if (p) selectedProds.push(p)
|
||||
})
|
||||
} else if (sel?.productId) {
|
||||
const p = products.find(prod => prod.id === sel.productId)
|
||||
if (p) selectedProds.push(p)
|
||||
}
|
||||
{/* Kassenliste */}
|
||||
<div className="space-y-3">
|
||||
<div className="flex items-center justify-between">
|
||||
<h3 className="text-xs font-bold text-slate-300 uppercase tracking-wider flex items-center gap-2">
|
||||
<span>Enthaltene Kassen ({finalItemsToShow.length})</span>
|
||||
</h3>
|
||||
{onAddNewBasketItem && (
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={onAddNewBasketItem}
|
||||
className="border-dashed border-primary/40 text-primary hover:bg-primary/10 text-xs font-semibold gap-1.5 h-7"
|
||||
>
|
||||
<Plus className="w-3 h-3" /> Weitere Kasse hinzufügen
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
if (selectedProds.length === 0) return null
|
||||
{finalItemsToShow.length === 0 ? (
|
||||
<div className="p-6 rounded-2xl bg-white/5 border border-white/10 text-center space-y-2">
|
||||
<p className="text-xs text-slate-400 font-medium">Keine Kassen in der Aufstellung vorhanden.</p>
|
||||
</div>
|
||||
) : (
|
||||
finalItemsToShow.map((item, itemIdx) => (
|
||||
<div
|
||||
key={itemIdx}
|
||||
className="p-4 rounded-2xl bg-white/5 border border-white/10 space-y-3 relative overflow-hidden"
|
||||
>
|
||||
{/* Kassen Header Bar */}
|
||||
<div className="flex justify-between items-center bg-slate-950/40 p-2.5 rounded-xl border border-white/5">
|
||||
<div className="flex items-center gap-2 min-w-0">
|
||||
<span className="text-white font-bold text-xs truncate">
|
||||
{item.deviceName || `Kasse ${itemIdx + 1}`}
|
||||
</span>
|
||||
{itemIdx > 0 && (
|
||||
<Badge variant="outline" className="text-[9px] px-1.5 py-0 border-emerald-500/30 text-emerald-400 bg-emerald-500/10 shrink-0">
|
||||
Kasse 2+
|
||||
</Badge>
|
||||
)}
|
||||
{item.licenseNumber && (
|
||||
<span className="text-[10px] text-slate-400 font-mono truncate">
|
||||
({item.licenseNumber})
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
const sortedProds = [...selectedProds].sort((a, b) => a.base_price - b.base_price)
|
||||
const freeLimit = cat.allow_multiselect ? cat.free_items_limit : 0
|
||||
<div className="flex items-center gap-1.5 shrink-0">
|
||||
<Badge
|
||||
variant="outline"
|
||||
className={`text-[9px] px-2 py-0.5 font-semibold ${
|
||||
item.billingInterval === 'one_time'
|
||||
? 'border-amber-500/30 text-amber-400 bg-amber-500/10'
|
||||
: 'border-blue-500/30 text-blue-400 bg-blue-500/10'
|
||||
}`}
|
||||
>
|
||||
{item.billingInterval === 'one_time' ? 'Kauf' : 'Abo'}
|
||||
</Badge>
|
||||
|
||||
return (
|
||||
<div key={cat.id} className="text-sm space-y-2 pl-2">
|
||||
<span className="text-slate-500 text-[10px] font-bold uppercase tracking-wider block">{cat.name}:</span>
|
||||
{sortedProds.map((prod, idx) => {
|
||||
const isFree = idx < freeLimit
|
||||
const isAbo = item.billingInterval === 'monthly'
|
||||
const displayPrice = isFree ? 0 : (isAbo ? ((prod as any).monthly_price ?? prod.base_price) : prod.base_price)
|
||||
return (
|
||||
<div key={prod.id} className="flex justify-between text-slate-200">
|
||||
<span className="flex items-center gap-1.5">
|
||||
<CategoryIcon icon={cat.icon} className="w-3.5 h-3.5 text-primary shrink-0" />
|
||||
{prod.name}
|
||||
{isFree && <span className="text-[9px] bg-green-500/20 text-green-400 px-1.5 py-0.5 rounded border border-green-500/30 font-bold uppercase">Inklusive</span>}
|
||||
</span>
|
||||
<span className="font-bold text-xs text-white">
|
||||
{isFree ? '0,00 €' : new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(displayPrice)}
|
||||
</span>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
{onEditBasketItem && (
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => onEditBasketItem(itemIdx)}
|
||||
className="h-7 px-2 text-xs text-slate-300 hover:text-primary hover:bg-primary/20 gap-1 rounded-lg"
|
||||
title="Kasse in Schritt 3 bearbeiten"
|
||||
>
|
||||
<Pencil className="w-3 h-3" /> Bearbeiten
|
||||
</Button>
|
||||
)}
|
||||
|
||||
{/* Selected Modules */}
|
||||
{sel?.moduleIds && sel.moduleIds.length > 0 && (
|
||||
<div className="pl-4 space-y-1.5 pt-1">
|
||||
{sel.moduleIds.map((mId: string) => {
|
||||
let modObj: any = null
|
||||
products.forEach(p => {
|
||||
const found = p.modules?.find(m => m.id === mId)
|
||||
if (found) modObj = found
|
||||
})
|
||||
if (!modObj) return null
|
||||
{onDeleteBasketItem && (
|
||||
<Button
|
||||
type="button"
|
||||
variant={confirmDeleteIdx === itemIdx ? 'destructive' : 'ghost'}
|
||||
size="sm"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
if (confirmDeleteIdx === itemIdx) {
|
||||
onDeleteBasketItem(itemIdx)
|
||||
setConfirmDeleteIdx(null)
|
||||
} else {
|
||||
setConfirmDeleteIdx(itemIdx)
|
||||
}
|
||||
}}
|
||||
onMouseLeave={() => setConfirmDeleteIdx(null)}
|
||||
className={`h-7 px-2 text-xs transition-all ${
|
||||
confirmDeleteIdx === itemIdx
|
||||
? 'bg-red-600 text-white hover:bg-red-700 font-bold px-2.5 shadow-md shadow-red-500/30'
|
||||
: 'text-slate-400 hover:text-red-400 hover:bg-red-500/20'
|
||||
} gap-1 rounded-lg`}
|
||||
title="Kasse entfernen"
|
||||
>
|
||||
<Trash2 className="w-3 h-3" />
|
||||
{confirmDeleteIdx === itemIdx ? 'Wirklich löschen?' : ''}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Enthaltene Produkte & Module */}
|
||||
<div className="space-y-2 text-xs">
|
||||
{visibleCategories.map((cat) => {
|
||||
const sel = item.selections[cat.id]
|
||||
const selectedProds: Product[] = []
|
||||
if (cat.allow_multiselect && sel?.productIds) {
|
||||
sel.productIds.forEach((pId: string) => {
|
||||
const p = products.find((prod) => prod.id === pId)
|
||||
if (p) selectedProds.push(p)
|
||||
})
|
||||
} else if (sel?.productId) {
|
||||
const p = products.find((prod) => prod.id === sel.productId)
|
||||
if (p) selectedProds.push(p)
|
||||
}
|
||||
|
||||
if (selectedProds.length === 0) return null
|
||||
|
||||
const sortedProds = [...selectedProds].sort((a, b) => a.base_price - b.base_price)
|
||||
const freeLimit = cat.allow_multiselect ? cat.free_items_limit : 0
|
||||
|
||||
return (
|
||||
<div key={cat.id} className="space-y-1 pl-1">
|
||||
<span className="text-slate-400 text-[10px] font-bold uppercase tracking-wider block">
|
||||
{cat.name}:
|
||||
</span>
|
||||
{sortedProds.map((prod, idx) => {
|
||||
const isFree = idx < freeLimit
|
||||
const isAbo = item.billingInterval === 'monthly'
|
||||
const qty = item.moduleQuantities?.[mId] || 1
|
||||
const unitPrice = isAbo ? (modObj.monthly_price ?? modObj.price) : modObj.price
|
||||
const totalPrice = unitPrice * qty
|
||||
const displayPrice = isFree ? 0 : isAbo ? ((prod as any).monthly_price ?? prod.base_price) : prod.base_price
|
||||
|
||||
return (
|
||||
<div key={mId} className="flex justify-between text-slate-400 text-xs">
|
||||
<span>+ {modObj.name} {qty > 1 ? `(${qty}x)` : ''}</span>
|
||||
<span className="font-semibold text-slate-300">
|
||||
{new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(totalPrice)}
|
||||
<div key={prod.id} className="flex justify-between items-center text-slate-200 pl-2">
|
||||
<span className="flex items-center gap-1.5 truncate pr-2">
|
||||
<CategoryIcon icon={cat.icon} className="w-3.5 h-3.5 text-primary shrink-0" />
|
||||
<span className="truncate">{prod.name}</span>
|
||||
{isFree && (
|
||||
<span className="text-[9px] bg-green-500/20 text-green-400 px-1.5 py-0.2 rounded border border-green-500/30 font-bold uppercase shrink-0">
|
||||
Inklusive
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
<span className="font-bold text-xs text-white tabular-nums shrink-0">
|
||||
{isFree ? '0,00 €' : fmt(displayPrice)}
|
||||
</span>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
))}
|
||||
|
||||
{/* Gebühren & Zusatz-Positionen */}
|
||||
{/* Selected Module Chips */}
|
||||
{sel?.moduleIds && sel.moduleIds.length > 0 && (
|
||||
<div className="pl-6 space-y-1 pt-0.5">
|
||||
{sel.moduleIds.map((mId: string) => {
|
||||
let modObj: any = null
|
||||
products.forEach((p) => {
|
||||
const found = p.modules?.find((m) => m.id === mId)
|
||||
if (found) modObj = found
|
||||
})
|
||||
if (!modObj) return null
|
||||
|
||||
const isAbo = item.billingInterval === 'monthly'
|
||||
const qty = item.moduleQuantities?.[mId] || 1
|
||||
const unitPrice = isAbo ? (modObj.monthly_price ?? modObj.price) : modObj.price
|
||||
const totalPrice = unitPrice * qty
|
||||
|
||||
return (
|
||||
<div key={mId} className="flex justify-between text-slate-400 text-[11px]">
|
||||
<span className="truncate pr-2">
|
||||
+ {modObj.name} {qty > 1 ? `(${qty}x)` : ''}
|
||||
</span>
|
||||
<span className="font-semibold text-slate-300 tabular-nums shrink-0">
|
||||
{fmt(totalPrice)}
|
||||
</span>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
))
|
||||
)}
|
||||
|
||||
{/* Service- & Zusatz-Positionen */}
|
||||
{linkedFeeProducts.length > 0 && (
|
||||
<div className="border-t border-white/5 pt-4 space-y-2">
|
||||
<span className="text-slate-500 text-[10px] font-bold uppercase tracking-wider block">Service & Gebühren:</span>
|
||||
{linkedFeeProducts.map(fp => (
|
||||
<div className="p-3.5 rounded-2xl bg-white/5 border border-white/10 space-y-2">
|
||||
<span className="text-slate-400 text-[10px] font-bold uppercase tracking-wider block">
|
||||
Service & Gebühren:
|
||||
</span>
|
||||
{linkedFeeProducts.map((fp) => (
|
||||
<div key={fp.id} className="flex justify-between text-xs text-slate-300">
|
||||
<span>{fp.name}</span>
|
||||
<span className="font-bold text-white">{new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(fp.base_price)}</span>
|
||||
<span className="font-bold text-white tabular-nums">{fmt(fp.base_price)}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Summen-Berechnung */}
|
||||
{oneTimeTotal > 0 ? (
|
||||
<div className="space-y-2 border-t border-white/10 pt-5">
|
||||
<div className="flex justify-between text-xs text-slate-400">
|
||||
<span>Netto-Gesamtbetrag:</span>
|
||||
<span className="font-semibold text-white">{new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(oneTimeNet)}</span>
|
||||
</div>
|
||||
<div className="flex justify-between text-xs text-slate-400">
|
||||
<span>zzgl. 19% MwSt.:</span>
|
||||
<span className="font-semibold text-white">{new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(oneTimeTax)}</span>
|
||||
</div>
|
||||
{updatePriceModifier.label && (
|
||||
<div className="text-xs text-green-400 font-semibold bg-green-500/10 p-2.5 rounded-xl border border-green-500/20 my-1">
|
||||
{updatePriceModifier.label}
|
||||
{/* ─── RECHTES RASTER (lg:col-span-5) – Notizen, Bedingungen & Summen ─── */}
|
||||
<div className="lg:col-span-5 space-y-5">
|
||||
{/* Glassmorphism Preiskalkulation */}
|
||||
<div className="p-5 rounded-2xl bg-slate-950/80 border border-white/10 space-y-3 shadow-xl">
|
||||
<div className="flex items-center gap-2 pb-2 border-b border-white/10">
|
||||
<CreditCard className="w-4 h-4 text-primary" />
|
||||
<h3 className="text-xs font-bold text-white uppercase tracking-wider">
|
||||
Gesamte Preiskalkulation
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
{oneTimeTotal > 0 && (
|
||||
<div className="space-y-1.5 text-xs">
|
||||
<div className="flex justify-between text-slate-400">
|
||||
<span>Einmalig (netto):</span>
|
||||
<span className="tabular-nums font-mono text-white">{fmt(oneTimeNet)}</span>
|
||||
</div>
|
||||
<div className="flex justify-between text-slate-400">
|
||||
<span>zzgl. 19% MwSt.:</span>
|
||||
<span className="tabular-nums font-mono text-white">{fmt(oneTimeTax)}</span>
|
||||
</div>
|
||||
{updatePriceModifier?.label && (
|
||||
<div className="text-[11px] text-green-400 font-semibold bg-green-500/10 p-2 rounded-lg border border-green-500/20 my-1">
|
||||
{updatePriceModifier.label}
|
||||
</div>
|
||||
)}
|
||||
<div className="flex justify-between text-sm font-bold text-white pt-2 border-t border-white/5">
|
||||
<span>Einmalig gesamt (brutto):</span>
|
||||
<span className="tabular-nums font-mono text-primary font-extrabold text-base">{fmt(oneTimeGross)}</span>
|
||||
</div>
|
||||
)}
|
||||
<div className="flex justify-between text-base font-bold text-primary pt-3 border-t border-white/5">
|
||||
<span>Gesamtbetrag (brutto):</span>
|
||||
<span className="font-bold text-white">{new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(oneTimeGross)}</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{monthlyTotal > 0 && (
|
||||
<div className={`space-y-1.5 text-xs ${oneTimeTotal > 0 ? 'pt-3 border-t border-white/10' : ''}`}>
|
||||
<div className="flex justify-between text-slate-400">
|
||||
<span>Monatlich (netto):</span>
|
||||
<span className="tabular-nums font-mono text-white">{fmt(monthlyNet)} / mtl.</span>
|
||||
</div>
|
||||
<div className="flex justify-between text-slate-400">
|
||||
<span>zzgl. 19% MwSt.:</span>
|
||||
<span className="tabular-nums font-mono text-white">{fmt(monthlyTax)} / mtl.</span>
|
||||
</div>
|
||||
<div className="flex justify-between text-sm font-bold text-white pt-2 border-t border-white/5">
|
||||
<span>Monatlich gesamt (brutto):</span>
|
||||
<span className="tabular-nums font-mono text-primary font-extrabold text-base">{fmt(monthlyGross)} / mtl.</span>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Bestellnotizen */}
|
||||
<div className="p-4 rounded-2xl bg-white/5 border border-white/10 space-y-2">
|
||||
<Label htmlFor="order-notes" className="text-xs font-bold text-white uppercase tracking-wider flex items-center gap-1.5">
|
||||
<MessageSquare className="w-3.5 h-3.5 text-primary" />
|
||||
<span>Bestellnotizen / Bemerkungen (optional)</span>
|
||||
</Label>
|
||||
<textarea
|
||||
id="order-notes"
|
||||
rows={3}
|
||||
value={orderNotes}
|
||||
onChange={(e) => setOrderNotes(e.target.value)}
|
||||
placeholder="Besondere Hinweise, Wunschtermine oder Ansprechpartner..."
|
||||
className="w-full p-3 rounded-xl bg-slate-950/70 border border-white/10 text-xs text-white placeholder:text-slate-500 focus:border-primary focus:outline-none transition-colors resize-none scrollbar-thin scrollbar-thumb-slate-800 scrollbar-track-transparent"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Lizenzbestimmungen & B2B-Workflow Checkbox */}
|
||||
<div className="p-4 rounded-2xl bg-white/5 border border-white/10 space-y-3">
|
||||
<div className="flex items-start gap-3">
|
||||
<Checkbox
|
||||
id="terms-checkbox"
|
||||
checked={acceptedTerms}
|
||||
onCheckedChange={(checked) => setAcceptedTerms(checked === true)}
|
||||
className="rounded border-white/20 data-[state=checked]:bg-primary mt-0.5"
|
||||
/>
|
||||
<Label htmlFor="terms-checkbox" className="text-xs text-slate-300 leading-relaxed cursor-pointer select-none">
|
||||
Ich bestätige die Richtigkeit der Angaben und akzeptiere die Lizenzvereinbarungen sowie die{' '}
|
||||
<a href="/datenschutz" target="_blank" rel="noopener noreferrer" className="underline hover:text-white text-primary">
|
||||
Datenschutzerklärung
|
||||
</a>.
|
||||
</Label>
|
||||
</div>
|
||||
) : (
|
||||
<div className="space-y-2 border-t border-white/10 pt-5">
|
||||
<div className="flex justify-between text-xs text-slate-400">
|
||||
<span>Netto-Gesamtbetrag:</span>
|
||||
<span className="font-semibold text-white">{new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(monthlyNet)} / mtl.</span>
|
||||
</div>
|
||||
<div className="flex justify-between text-xs text-slate-400">
|
||||
<span>zzgl. 19% MwSt.:</span>
|
||||
<span className="font-semibold text-white">{new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(monthlyTax)} / mtl.</span>
|
||||
</div>
|
||||
<div className="flex justify-between text-base font-bold text-primary pt-3 border-t border-white/5">
|
||||
<span>Gesamtbetrag (brutto):</span>
|
||||
<span className="font-bold text-white">{new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(monthlyGross)} / mtl.</span>
|
||||
</div>
|
||||
|
||||
<div className="p-2.5 rounded-xl bg-primary/10 border border-primary/20 text-[11px] text-slate-300 flex items-center gap-2">
|
||||
<FileText className="w-4 h-4 text-primary shrink-0" />
|
||||
<span>B2B-Freigabe: Nach Absenden wird die Lizenzierungsanfrage geprüft und freigegeben.</span>
|
||||
</div>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* ─── 3. FIXED BOTTOM ACTION BAR (shrink-0) ─── */}
|
||||
<div className="shrink-0 border-t border-white/10 bg-slate-950/90 backdrop-blur-md px-6 py-3.5 flex flex-col sm:flex-row items-center justify-between gap-3 z-10">
|
||||
{/* Back Button */}
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={prevStep}
|
||||
className="w-full sm:w-auto border-white/10 text-white hover:bg-white/10 h-9 text-xs gap-1.5"
|
||||
>
|
||||
<ChevronLeft className="w-4 h-4" /> Zurück zu Schritt 3
|
||||
</Button>
|
||||
|
||||
{/* Info Chip */}
|
||||
<div className="flex items-center gap-2 px-3 py-1.5 rounded-xl bg-white/5 border border-white/10 text-white text-xs">
|
||||
<span className="text-slate-400">Positionen:</span>
|
||||
<strong className="text-white">{finalItemsToShow.length} Kassen</strong>
|
||||
<span className="text-slate-600">|</span>
|
||||
<span className="text-primary font-bold">
|
||||
{oneTimeTotal > 0 ? fmt(oneTimeGross) : `${fmt(monthlyGross)} / mtl.`}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/* Submit Button */}
|
||||
<Button
|
||||
onClick={handleSubmit}
|
||||
disabled={isSubmitting || !acceptedTerms || finalItemsToShow.length === 0}
|
||||
className="w-full sm:w-auto bg-primary hover:bg-primary/90 text-white font-bold px-6 shadow-lg shadow-primary/20 h-9 text-xs gap-2"
|
||||
>
|
||||
{isSubmitting ? (
|
||||
<>
|
||||
<Loader2 className="w-4 h-4 animate-spin" />
|
||||
{initialOrder ? 'Anfrage wird aktualisiert...' : 'Anfrage wird übertragen...'}
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Send className="w-3.5 h-3.5" />
|
||||
{initialOrder ? 'Anfrage aktualisieren' : 'Anfrage verbindlich absenden'}
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
</div>
|
||||
</Card>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user