fix: NetUp device form — hide purpose/USB/COM, auto-select network
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -189,6 +189,10 @@ function DeviceForm({
|
||||
wsOnline: boolean
|
||||
}) {
|
||||
const [type, setType] = useState<'kkt' | 'printer' | 'netup'>(initial?.type ?? 'printer')
|
||||
const handleTypeChange = (t: 'kkt' | 'printer' | 'netup') => {
|
||||
setType(t)
|
||||
if (t === 'netup') setConnection('network')
|
||||
}
|
||||
const [name, setName] = useState(initial?.name ?? '')
|
||||
const [connection, setConnection] = useState<'usb' | 'network' | 'com'>(initial?.connection ?? 'network')
|
||||
const [networkHost, setNetworkHost] = useState(initial?.networkHost ?? '')
|
||||
@@ -230,12 +234,12 @@ function DeviceForm({
|
||||
|
||||
return (
|
||||
<div className="border border-brand-200 dark:border-brand-800 rounded-xl p-4 bg-brand-50/30 dark:bg-brand-900/10 space-y-3">
|
||||
<div className="grid grid-cols-2 gap-3">
|
||||
<div className={cn('grid gap-3', type === 'netup' ? 'grid-cols-1' : 'grid-cols-2')}>
|
||||
<div>
|
||||
<label className="block text-xs font-medium text-slate-500 mb-1">Тип устройства</label>
|
||||
<select
|
||||
value={type}
|
||||
onChange={e => setType(e.target.value as 'kkt' | 'printer' | 'netup')}
|
||||
onChange={e => handleTypeChange(e.target.value as 'kkt' | 'printer' | 'netup')}
|
||||
className="w-full input text-sm"
|
||||
>
|
||||
<option value="kkt">ККТ (касса)</option>
|
||||
@@ -243,6 +247,7 @@ function DeviceForm({
|
||||
<option value="netup">NetUp IPTV</option>
|
||||
</select>
|
||||
</div>
|
||||
{type !== 'netup' && (
|
||||
<div>
|
||||
<label className="block text-xs font-medium text-slate-500 mb-1">Назначение</label>
|
||||
<select
|
||||
@@ -255,6 +260,7 @@ function DeviceForm({
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* KKT-specific: fiscal mode + DTO port */}
|
||||
@@ -305,10 +311,11 @@ function DeviceForm({
|
||||
value={name}
|
||||
onChange={e => setName(e.target.value)}
|
||||
className="w-full input text-sm"
|
||||
placeholder="Касса №1 / Принтер кухни"
|
||||
placeholder={type === 'netup' ? 'NetUp сервер' : type === 'kkt' ? 'Касса №1' : 'Принтер кухни'}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{type !== 'netup' && (
|
||||
<div>
|
||||
<label className="block text-xs font-medium text-slate-500 mb-1">Подключение</label>
|
||||
<div className="flex gap-2">
|
||||
@@ -332,6 +339,7 @@ function DeviceForm({
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{connection === 'network' && (
|
||||
<div className="grid grid-cols-3 gap-3">
|
||||
@@ -341,7 +349,7 @@ function DeviceForm({
|
||||
value={networkHost}
|
||||
onChange={e => setNetworkHost(e.target.value)}
|
||||
className="w-full input text-sm font-mono"
|
||||
placeholder="192.168.1.50"
|
||||
placeholder={type === 'netup' ? '172.16.0.12' : '192.168.1.50'}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
@@ -350,7 +358,7 @@ function DeviceForm({
|
||||
value={networkPort}
|
||||
onChange={e => setNetworkPort(e.target.value)}
|
||||
className="w-full input text-sm font-mono"
|
||||
placeholder="9100"
|
||||
placeholder={type === 'netup' ? '8880' : '9100'}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user