| @@ -31,6 +31,11 @@ function CardTypeSelect({ | |||||
| }, [open]); | }, [open]); | ||||
| const current = options.find(o => o.value === value); | const current = options.find(o => o.value === value); | ||||
| // Fallback: se il value non matcha nessuna opzione (es. tipo disattivato dalla flag), mostra il valore raw prettificato | |||||
| const displayLabel = current?.label | |||||
| ?? (typeof value === 'string' && value.length > 0 | |||||
| ? value.replace(/_/g, ' ').toLowerCase().replace(/\b\w/g, c => c.toUpperCase()) | |||||
| : ''); | |||||
| const inputBase = "w-full border border-gray-300 p-2.5 rounded-lg outline-none focus:ring-2 focus:ring-blue-500 bg-white text-gray-900"; | const inputBase = "w-full border border-gray-300 p-2.5 rounded-lg outline-none focus:ring-2 focus:ring-blue-500 bg-white text-gray-900"; | ||||
| return ( | return ( | ||||
| @@ -40,7 +45,7 @@ function CardTypeSelect({ | |||||
| onClick={() => setOpen(o => !o)} | onClick={() => setOpen(o => !o)} | ||||
| className={`${inputBase} text-left flex items-center justify-between cursor-pointer`} | className={`${inputBase} text-left flex items-center justify-between cursor-pointer`} | ||||
| > | > | ||||
| <span>{current?.label || ''}</span> | |||||
| <span className={displayLabel ? '' : 'text-gray-400'}>{displayLabel || 'Seleziona…'}</span> | |||||
| <span className={`text-gray-500 transition-transform ${open ? 'rotate-180' : ''}`}>▾</span> | <span className={`text-gray-500 transition-transform ${open ? 'rotate-180' : ''}`}>▾</span> | ||||
| </button> | </button> | ||||
| {open && ( | {open && ( | ||||