diff --git a/src/components/payment-status.tsx b/src/components/payment-status.tsx new file mode 100644 index 0000000..5172186 --- /dev/null +++ b/src/components/payment-status.tsx @@ -0,0 +1,98 @@ +import type { ClientView } from '@/lib/client-view'; +import { Card } from '@/components/ui/card'; +import { Badge } from '@/components/ui/badge'; + +interface PaymentStatusProps { + accepted_total: string; + payments: ClientView['payments']; +} + +type PaymentStatusValue = 'da_saldare' | 'inviata' | 'saldato'; + +const statusConfig: Record< + PaymentStatusValue, + { label: string; badgeClass: string; dotClass: string } +> = { + da_saldare: { + label: 'Da Saldare', + badgeClass: 'border-transparent bg-[#2563eb] text-white', + dotClass: 'bg-[#2563eb]', + }, + inviata: { + label: 'Inviata', + badgeClass: 'border-transparent bg-[#ca8a04] text-white', + dotClass: 'bg-[#ca8a04]', + }, + saldato: { + label: 'Saldato', + badgeClass: 'border-transparent bg-[#16a34a] text-white', + dotClass: 'bg-[#16a34a]', + }, +}; + +export function PaymentStatus({ accepted_total, payments }: PaymentStatusProps) { + const totalFormatted = parseFloat(accepted_total || '0').toLocaleString('it-IT', { + style: 'currency', + currency: 'EUR', + minimumFractionDigits: 2, + maximumFractionDigits: 2, + }); + + return ( + + {/* Totale accettato — unico importo visibile al cliente (LOCKED) */} +
+

+ Totale Preventivo Accettato +

+

+ {totalFormatted} +

+
+ + {/* Righe pagamento: solo etichetta + stato, MAI importo singolo */} +
+ {payments.length === 0 ? ( +

+ Nessun piano di pagamento configurato. +

+ ) : ( + payments.map((payment) => { + const status = payment.status as PaymentStatusValue; + const config = statusConfig[status] ?? statusConfig.da_saldare; + + return ( +
+ {/* Indicatore dot + etichetta */} +
+
+ + {/* Badge stato — nessun importo */} + + {config.label} + +
+ ); + }) + )} +
+ + {/* Nota informativa */} +
+

+ Per dettagli o domande sui pagamenti, contattaci direttamente. +

+
+
+ ); +} \ No newline at end of file