자잘한 통신 오류 수정 및 모바일용 디자인 변경, connect 메뉴 별도 추가

This commit is contained in:
backuppc
2026-01-23 13:23:11 +09:00
parent 3396104011
commit abb32575f4
3 changed files with 408 additions and 359 deletions

View File

@@ -26,7 +26,7 @@ export const QuickTestPanel: React.FC<Props> = ({
isScanning,
config
}) => {
return (
<div className="h-full flex flex-col items-center justify-center p-6 max-w-4xl mx-auto">
<div className="text-center mb-10">
@@ -35,61 +35,55 @@ export const QuickTestPanel: React.FC<Props> = ({
</div>
<h1 className="text-3xl font-bold text-slate-800 mb-2">Quick Test Mode</h1>
<p className="text-slate-500">
Automatically detects the first tag in the field and performs a Read or Write operation.<br/>
Target: <strong>EPC Bank</strong>, Start Address: <strong>2</strong><br/>
Length: <strong>{config.length} Words</strong>, Format: <strong>{config.format.toUpperCase()}</strong>
.
</p>
</div>
<div className="grid grid-cols-1 md:grid-cols-2 gap-8 w-full">
{/* Read Card */}
{/* Read/Write Card */}
<div className="bg-white p-8 rounded-2xl shadow-sm border border-slate-200 hover:shadow-md transition-shadow flex flex-col items-center text-center">
<div className="mb-6 p-4 bg-blue-50 text-blue-600 rounded-full">
<HardDriveDownload className="w-8 h-8" />
</div>
<h2 className="text-xl font-bold text-slate-800 mb-2">Auto Read</h2>
{/* 1. Read Button */}
<div className="w-full mb-6">
{isPending ? (
<button
onClick={onCancel}
className="w-full py-4 bg-red-500 hover:bg-red-600 text-white rounded-xl font-bold text-lg shadow-lg shadow-red-500/30 transition-all flex items-center justify-center gap-2"
>
<XCircle className="w-5 h-5" /> Cancel
</button>
) : (
<button
onClick={onQuickRead}
disabled={isScanning && !isPending}
className="w-full py-4 bg-blue-600 hover:bg-blue-700 disabled:bg-slate-300 disabled:cursor-not-allowed text-white rounded-xl font-bold text-lg shadow-lg shadow-blue-500/30 transition-all flex items-center justify-center gap-2"
>
Start Read Test
</button>
)}
</div>
{/* 2. Read Result Display */}
<div className="w-full bg-slate-50 border border-slate-200 rounded-xl p-4 mb-6 min-h-[80px] flex items-center justify-center font-mono text-lg text-slate-700 break-all">
{isPending ? (
<div className="flex items-center gap-2 text-amber-500 animate-pulse">
<Activity className="w-5 h-5" /> Scanning & Reading...
</div>
) : (
result ? (
<span className="text-emerald-600 font-bold">{result}</span>
) : (
<span className="text-slate-300">No Data Read</span>
)
)}
{isPending ? (
<div className="flex items-center gap-2 text-amber-500 animate-pulse">
<Activity className="w-5 h-5" /> Scanning & Reading...
</div>
) : (
result ? (
<span className="text-emerald-600 font-bold">{result}</span>
) : (
<span className="text-slate-300">No Data Read</span>
)
)}
</div>
{isPending ? (
<button
onClick={onCancel}
className="w-full py-4 bg-red-500 hover:bg-red-600 text-white rounded-xl font-bold text-lg shadow-lg shadow-red-500/30 transition-all flex items-center justify-center gap-2"
>
<XCircle className="w-5 h-5" /> Cancel
</button>
) : (
<button
onClick={onQuickRead}
disabled={isScanning && !isPending}
className="w-full py-4 bg-blue-600 hover:bg-blue-700 disabled:bg-slate-300 disabled:cursor-not-allowed text-white rounded-xl font-bold text-lg shadow-lg shadow-blue-500/30 transition-all flex items-center justify-center gap-2"
>
Start Read Test
</button>
)}
</div>
{/* Write Card */}
<div className="bg-white p-8 rounded-2xl shadow-sm border border-slate-200 hover:shadow-md transition-shadow flex flex-col items-center text-center">
<div className="mb-6 p-4 bg-purple-50 text-purple-600 rounded-full">
<HardDriveUpload className="w-8 h-8" />
</div>
<h2 className="text-xl font-bold text-slate-800 mb-2">Auto Write</h2>
<input
{/* 3. Write Input */}
<input
type="text"
value={writeInput}
onChange={(e) => onWriteInputChange(e.target.value)}
@@ -97,30 +91,72 @@ export const QuickTestPanel: React.FC<Props> = ({
className="w-full bg-slate-50 border border-slate-300 text-center text-lg rounded-xl p-4 mb-6 font-mono focus:ring-2 focus:ring-purple-500 outline-none"
/>
{isPending ? (
<button
onClick={onCancel}
className="w-full py-4 bg-red-500 hover:bg-red-600 text-white rounded-xl font-bold text-lg shadow-lg shadow-red-500/30 transition-all flex items-center justify-center gap-2"
>
<XCircle className="w-5 h-5" /> Cancel
</button>
) : (
<button
onClick={() => onQuickWrite(writeInput)}
disabled={(isScanning && !isPending) || !writeInput}
className="w-full py-4 bg-slate-800 hover:bg-slate-900 disabled:bg-slate-300 disabled:cursor-not-allowed text-white rounded-xl font-bold text-lg shadow-lg shadow-slate-500/30 transition-all flex items-center justify-center gap-2"
>
Start Write Test
</button>
)}
{/* 4. Write Button */}
<div className="w-full">
{isPending ? (
<button
onClick={onCancel}
className="w-full py-4 bg-red-500 hover:bg-red-600 text-white rounded-xl font-bold text-lg shadow-lg shadow-red-500/30 transition-all flex items-center justify-center gap-2"
>
<XCircle className="w-5 h-5" /> Cancel
</button>
) : (
<button
onClick={() => onQuickWrite(writeInput)}
disabled={(isScanning && !isPending) || !writeInput}
className="w-full py-4 bg-slate-800 hover:bg-slate-900 disabled:bg-slate-300 disabled:cursor-not-allowed text-white rounded-xl font-bold text-lg shadow-lg shadow-slate-500/30 transition-all flex items-center justify-center gap-2"
>
Start Write Test
</button>
)}
</div>
</div>
{/* Info / Config Card */}
<div className="flex flex-col justify-center space-y-6">
<div className="bg-white p-6 rounded-2xl shadow-sm border border-slate-200 hover:shadow-md transition-shadow">
<h3 className="text-lg font-bold text-slate-800 mb-4 flex items-center gap-2">
<Zap className="w-5 h-5 text-indigo-500" />
Test Configuration
</h3>
<div className="space-y-4">
<div className="flex justify-between items-center p-3 bg-slate-50 rounded-lg">
<span className="text-slate-500 text-sm">Target Bank</span>
<span className="font-bold text-slate-700">EPC (01)</span>
</div>
<div className="flex justify-between items-center p-3 bg-slate-50 rounded-lg">
<span className="text-slate-500 text-sm">Start Address</span>
<span className="font-bold text-slate-700">2 (User Data)</span>
</div>
<div className="flex justify-between items-center p-3 bg-slate-50 rounded-lg">
<span className="text-slate-500 text-sm">Data Length</span>
<span className="font-bold text-slate-700">{config.length} Words</span>
</div>
<div className="flex justify-between items-center p-3 bg-slate-50 rounded-lg">
<span className="text-slate-500 text-sm">Format</span>
<span className="font-bold text-slate-700">{config.format.toUpperCase()}</span>
</div>
</div>
</div>
<div className="bg-indigo-50 p-6 rounded-2xl border border-indigo-100 text-sm text-indigo-800">
<h4 className="font-bold mb-2 flex items-center gap-2">
<AlertCircle className="w-4 h-4" />
Note
</h4>
<p>
(, ) <strong>Settings</strong> .
</p>
</div>
</div>
</div>
{isScanning && !isPending && (
<div className="mt-8 flex items-center gap-2 px-4 py-2 bg-amber-50 text-amber-700 border border-amber-200 rounded-full text-sm animate-pulse">
<Activity className="w-4 h-4" /> Background scanning is active in Inventory...
</div>
<div className="mt-8 flex items-center gap-2 px-4 py-2 bg-amber-50 text-amber-700 border border-amber-200 rounded-full text-sm animate-pulse">
<Activity className="w-4 h-4" /> Background scanning is active in Inventory...
</div>
)}
</div>
);

View File

@@ -72,10 +72,10 @@ export const SettingsPanel: React.FC<Props> = ({
};
const handleSaveLocalSettings = () => {
onSaveQuickTestConfig({
length: qtLength,
format: qtFormat
});
onSaveQuickTestConfig({
length: qtLength,
format: qtFormat
});
};
const baudRates = [9600, 19200, 38400, 57600, 115200];
@@ -85,287 +85,293 @@ export const SettingsPanel: React.FC<Props> = ({
return (
<div className="bg-white p-8 rounded-xl shadow-sm border border-slate-200 h-full overflow-auto flex flex-col">
{/* Header */}
<div className="mb-8 pb-6 border-b border-slate-100">
<h2 className="text-2xl font-bold text-slate-800">System Configuration</h2>
<p className="text-slate-500 mt-1">
Manage device parameters and local browser settings.
</p>
<h2 className="text-2xl font-bold text-slate-800">System Configuration</h2>
<p className="text-slate-500 mt-1">
.
</p>
</div>
{/* 1. Quick Test Settings Card */}
<div className="mb-10">
<div className="flex items-center gap-2 mb-4">
<Settings2 className="w-5 h-5 text-indigo-600" />
<h3 className="text-lg font-bold text-slate-800">Quick Test Settings (Local)</h3>
</div>
<div className="bg-indigo-50/50 p-6 rounded-xl border border-indigo-100">
<p className="text-sm text-indigo-900 mb-6 border-l-4 border-indigo-400 pl-3">
These settings are stored in your browser's local storage and control the behavior of the "Quick Test" tab.
</p>
<div className="grid grid-cols-1 md:grid-cols-2 gap-8 mb-6">
<div className="space-y-3">
<label className="text-sm font-medium text-slate-600">Read/Write Length (Words)</label>
<div className="flex items-center gap-4">
<label className="flex items-center gap-2 cursor-pointer bg-white px-4 py-2 rounded-lg border border-indigo-100 shadow-sm">
<input
type="radio"
checked={qtLength === 3}
onChange={() => setQtLength(3)}
className="w-4 h-4 text-indigo-600 focus:ring-indigo-500 border-gray-300"
/>
<span className="text-sm text-slate-700">3 Words (6 Bytes)</span>
</label>
<label className="flex items-center gap-2 cursor-pointer bg-white px-4 py-2 rounded-lg border border-indigo-100 shadow-sm">
<input
type="radio"
checked={qtLength === 4}
onChange={() => setQtLength(4)}
className="w-4 h-4 text-indigo-600 focus:ring-indigo-500 border-gray-300"
/>
<span className="text-sm text-slate-700">4 Words (8 Bytes)</span>
</label>
</div>
</div>
<div className="space-y-3">
<label className="text-sm font-medium text-slate-600">Data Display Format</label>
<div className="flex items-center gap-4">
<label className="flex items-center gap-2 cursor-pointer bg-white px-4 py-2 rounded-lg border border-indigo-100 shadow-sm">
<input
type="radio"
checked={qtFormat === 'hex'}
onChange={() => setQtFormat('hex')}
className="w-4 h-4 text-indigo-600 focus:ring-indigo-500 border-gray-300"
/>
<span className="text-sm text-slate-700">HEX</span>
</label>
<label className="flex items-center gap-2 cursor-pointer bg-white px-4 py-2 rounded-lg border border-indigo-100 shadow-sm">
<input
type="radio"
checked={qtFormat === 'ascii'}
onChange={() => setQtFormat('ascii')}
className="w-4 h-4 text-indigo-600 focus:ring-indigo-500 border-gray-300"
/>
<span className="text-sm text-slate-700">ASCII</span>
</label>
</div>
</div>
</div>
<button
onClick={handleSaveLocalSettings}
className="flex items-center justify-center gap-2 px-5 py-2.5 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700 shadow-sm hover:shadow transition-colors font-medium"
title="Save these settings to browser"
{/* 2. Reader Configuration */}
<div className="flex-1">
<div className="flex flex-col md:flex-row md:items-center justify-between gap-4 mb-6">
<div className="flex items-center gap-2">
<HardDrive className="w-5 h-5 text-blue-600" />
<h3 className="text-lg font-bold text-slate-800">Reader Configuration (Device)</h3>
</div>
{/* Device Actions */}
<div className="flex flex-wrap items-center gap-3">
<button
onClick={onGetInfo}
className="flex items-center justify-center gap-2 px-4 py-2 bg-slate-100 text-slate-700 border border-slate-200 rounded-lg hover:bg-slate-200 hover:text-slate-900 transition-all font-medium"
>
<RefreshCw className={`w-4 h-4 ${!isLoaded ? 'animate-pulse' : ''}`} />
Read
</button>
<button
onClick={handleApplyReaderSettings}
className="flex items-center justify-center gap-2 px-5 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 shadow-sm hover:shadow transition-colors font-medium"
>
<Save className="w-4 h-4" />
Save Local Settings
Write
</button>
<button
onClick={onFactoryReset}
className="flex items-center justify-center gap-2 px-4 py-2 bg-white border border-red-200 text-red-600 rounded-lg hover:bg-red-50 hover:text-red-700 hover:border-red-300 transition-colors font-medium"
>
<RotateCcw className="w-4 h-4" />
Reset
</button>
</div>
</div>
{/* Status Info */}
<div className="grid grid-cols-2 md:grid-cols-4 gap-4 mb-8">
<div className="bg-slate-50 border border-slate-100 rounded-lg p-4 flex items-center gap-3">
<div className="p-2 bg-white rounded-md shadow-sm text-blue-600"><Cpu className="w-5 h-5" /></div>
<div>
<div className="text-xs text-slate-400 font-semibold uppercase">Model</div>
<div className="text-sm font-bold text-slate-700">{readerInfo?.model || '--'}</div>
</div>
</div>
<div className="bg-slate-50 border border-slate-100 rounded-lg p-4 flex items-center gap-3">
<div className="p-2 bg-white rounded-md shadow-sm text-emerald-600"><Activity className="w-5 h-5" /></div>
<div>
<div className="text-xs text-slate-400 font-semibold uppercase">Firmware</div>
<div className="text-sm font-bold text-slate-700">{readerInfo?.version || '--'}</div>
</div>
</div>
<div className="bg-slate-50 border border-slate-100 rounded-lg p-4 flex items-center gap-3">
<div className="p-2 bg-white rounded-md shadow-sm text-violet-600"><Radio className="w-5 h-5" /></div>
<div>
<div className="text-xs text-slate-400 font-semibold uppercase">Protocol</div>
<div className="text-sm font-bold text-slate-700">{readerInfo?.protocol || 'EPCC1-G2'}</div>
</div>
</div>
<div className="bg-slate-50 border border-slate-100 rounded-lg p-4 flex items-center gap-3">
<div className="p-2 bg-white rounded-md shadow-sm text-amber-600"><Zap className="w-5 h-5" /></div>
<div>
<div className="text-xs text-slate-400 font-semibold uppercase">Power</div>
<div className="text-sm font-bold text-slate-700">{readerInfo ? `${readerInfo.power} dBm` : '--'}</div>
</div>
</div>
</div>
{/* Device Settings Form */}
<div className={`space-y-8 transition-all duration-300 ${isLoaded ? 'opacity-100' : 'opacity-50 pointer-events-none grayscale'}`}>
{/* 1. Communication Settings */}
<div>
<h3 className="text-sm font-bold text-slate-900 uppercase tracking-wider mb-4 flex items-center gap-2">
<span className="w-1 h-4 bg-blue-500 rounded-full"></span>
Communication Parameters
</h3>
<div className="grid grid-cols-1 md:grid-cols-3 gap-6">
<div className="space-y-1">
<label className="text-sm font-medium text-slate-600">Reader Address (Hex)</label>
<input
type="text"
value={address.toString(16).toUpperCase()}
onChange={e => {
const val = parseInt(e.target.value, 16);
if (!isNaN(val) && val >= 0 && val <= 0xFF) setAddress(val);
}}
className="w-full bg-white border border-slate-300 rounded-lg px-3 py-2 text-slate-900 focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none transition-all"
maxLength={2}
/>
</div>
<div className="space-y-1">
<label className="text-sm font-medium text-slate-600">Baud Rate</label>
<select
value={baudRate}
onChange={e => setBaudRate(Number(e.target.value))}
className="w-full bg-white border border-slate-300 rounded-lg px-3 py-2 text-slate-900 focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none transition-all"
>
{baudRates.map(b => <option key={b} value={b}>{b} bps</option>)}
</select>
</div>
<div className="space-y-1">
<label className="text-sm font-medium text-slate-600">Max Response Time</label>
<select
value={maxResponseTime}
onChange={e => setMaxResponseTime(Number(e.target.value))}
className="w-full bg-white border border-slate-300 rounded-lg px-3 py-2 text-slate-900 focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none transition-all"
>
<option value={0}>Auto</option>
<option value={10}>10ms</option>
<option value={20}>20ms</option>
</select>
</div>
</div>
</div>
{/* 2. RF Settings */}
<div>
<h3 className="text-sm font-bold text-slate-900 uppercase tracking-wider mb-4 flex items-center gap-2">
<span className="w-1 h-4 bg-emerald-500 rounded-full"></span>
RF Configuration
</h3>
<div className="grid grid-cols-1 md:grid-cols-3 gap-6 mb-6">
<div className="space-y-1">
<label className="text-sm font-medium text-slate-600">Power Output</label>
<select
value={power}
onChange={e => setPower(Number(e.target.value))}
className="w-full bg-white border border-slate-300 rounded-lg px-3 py-2 text-slate-900 focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none transition-all"
>
{powerLevels.map(p => <option key={p} value={p}>{p} dBm</option>)}
</select>
</div>
<div className="space-y-1">
<label className="text-sm font-medium text-slate-600">Min Frequency</label>
<select
value={minFreq}
onChange={e => setMinFreq(Number(e.target.value))}
disabled={isSingleFreq}
className="w-full bg-white border border-slate-300 rounded-lg px-3 py-2 text-slate-900 focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none transition-all disabled:bg-slate-50 disabled:text-slate-400"
>
<option value={0}>Default</option>
<option value={1}>Custom 1</option>
</select>
</div>
<div className="space-y-1">
<div className="flex justify-between items-center">
<label className="text-sm font-medium text-slate-600">Max Frequency</label>
<label className="flex items-center gap-1.5 cursor-pointer">
<input
type="checkbox"
checked={isSingleFreq}
onChange={e => setIsSingleFreq(e.target.checked)}
className="w-3.5 h-3.5 rounded text-blue-600 focus:ring-blue-500 border-slate-300"
/>
<span className="text-xs text-slate-500">Single Freq</span>
</label>
</div>
<select
value={maxFreq}
onChange={e => setMaxFreq(Number(e.target.value))}
disabled={isSingleFreq}
className="w-full bg-white border border-slate-300 rounded-lg px-3 py-2 text-slate-900 focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none transition-all disabled:bg-slate-50 disabled:text-slate-400"
>
<option value={0}>Default</option>
<option value={1}>Custom 1</option>
</select>
</div>
</div>
<div className="bg-slate-50/80 rounded-lg p-5 border border-slate-200">
<label className="text-xs font-bold text-slate-500 uppercase tracking-wide mb-3 block">Frequency Region / Band</label>
<div className="flex flex-wrap gap-x-8 gap-y-4">
{[
{ label: 'User Defined', value: FrequencyBand.USER },
{ label: 'Chinese Band', value: FrequencyBand.CHINESE },
{ label: 'US Band', value: FrequencyBand.US },
{ label: 'Korean Band', value: FrequencyBand.KOREAN },
{ label: 'EU Band', value: FrequencyBand.EU },
].map((item) => (
<label key={item.value} className="flex items-center gap-2 cursor-pointer group">
<div className={`w-4 h-4 rounded-full border flex items-center justify-center transition-colors ${band === item.value ? 'border-blue-600 bg-blue-600' : 'border-slate-300 bg-white group-hover:border-blue-400'}`}>
{band === item.value && <div className="w-1.5 h-1.5 rounded-full bg-white" />}
</div>
<input
type="radio"
name="band"
checked={band === item.value}
onChange={() => setBand(item.value)}
className="hidden"
/>
<span className={`text-sm ${band === item.value ? 'text-slate-900 font-medium' : 'text-slate-600'}`}>{item.label}</span>
</label>
))}
</div>
</div>
</div>
</div>
</div>
<hr className="border-slate-100 mb-10" />
{/* 2. Reader Configuration */}
<div className="flex-1">
<div className="flex flex-col md:flex-row md:items-center justify-between gap-4 mb-6">
<div className="flex items-center gap-2">
<HardDrive className="w-5 h-5 text-blue-600" />
<h3 className="text-lg font-bold text-slate-800">Reader Configuration (Device)</h3>
</div>
{/* Device Actions */}
<div className="flex flex-wrap items-center gap-3">
<button
onClick={onGetInfo}
className="flex items-center justify-center gap-2 px-4 py-2 bg-slate-100 text-slate-700 border border-slate-200 rounded-lg hover:bg-slate-200 hover:text-slate-900 transition-all font-medium"
>
<RefreshCw className={`w-4 h-4 ${!isLoaded ? 'animate-pulse' : ''}`} />
Read Config
</button>
<button
onClick={handleApplyReaderSettings}
className="flex items-center justify-center gap-2 px-5 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 shadow-sm hover:shadow transition-colors font-medium"
>
<Save className="w-4 h-4" />
Apply Config
</button>
{/* 1. Quick Test Settings Card */}
<div className="mb-10">
<div className="flex items-center gap-2 mb-4">
<Settings2 className="w-5 h-5 text-indigo-600" />
<h3 className="text-lg font-bold text-slate-800">Quick Test Settings (Local)</h3>
</div>
<button
onClick={onFactoryReset}
className="flex items-center justify-center gap-2 px-4 py-2 bg-white border border-red-200 text-red-600 rounded-lg hover:bg-red-50 hover:text-red-700 hover:border-red-300 transition-colors font-medium"
>
<RotateCcw className="w-4 h-4" />
Reset
</button>
</div>
</div>
{/* Status Info */}
<div className="grid grid-cols-2 md:grid-cols-4 gap-4 mb-8">
<div className="bg-slate-50 border border-slate-100 rounded-lg p-4 flex items-center gap-3">
<div className="p-2 bg-white rounded-md shadow-sm text-blue-600"><Cpu className="w-5 h-5" /></div>
<div>
<div className="text-xs text-slate-400 font-semibold uppercase">Model</div>
<div className="text-sm font-bold text-slate-700">{readerInfo?.model || '--'}</div>
<div className="bg-indigo-50/50 p-6 rounded-xl border border-indigo-100">
<p className="text-sm text-indigo-900 mb-6 border-l-4 border-indigo-400 pl-3">
&quot;Quick Test&quot; .
</p>
<div className="grid grid-cols-1 md:grid-cols-2 gap-8 mb-6">
<div className="space-y-3">
<label className="text-sm font-medium text-slate-600">Read/Write Length (Words)</label>
<div className="flex items-center gap-4">
<label className="flex items-center gap-2 cursor-pointer bg-white px-4 py-2 rounded-lg border border-indigo-100 shadow-sm">
<input
type="radio"
checked={qtLength === 3}
onChange={() => setQtLength(3)}
className="w-4 h-4 text-indigo-600 focus:ring-indigo-500 border-gray-300"
/>
<span className="text-sm text-slate-700">3 Words</span>
</label>
<label className="flex items-center gap-2 cursor-pointer bg-white px-4 py-2 rounded-lg border border-indigo-100 shadow-sm">
<input
type="radio"
checked={qtLength === 4}
onChange={() => setQtLength(4)}
className="w-4 h-4 text-indigo-600 focus:ring-indigo-500 border-gray-300"
/>
<span className="text-sm text-slate-700">4 Words</span>
</label>
</div>
</div>
<div className="bg-slate-50 border border-slate-100 rounded-lg p-4 flex items-center gap-3">
<div className="p-2 bg-white rounded-md shadow-sm text-emerald-600"><Activity className="w-5 h-5" /></div>
<div>
<div className="text-xs text-slate-400 font-semibold uppercase">Firmware</div>
<div className="text-sm font-bold text-slate-700">{readerInfo?.version || '--'}</div>
</div>
</div>
<div className="bg-slate-50 border border-slate-100 rounded-lg p-4 flex items-center gap-3">
<div className="p-2 bg-white rounded-md shadow-sm text-violet-600"><Radio className="w-5 h-5" /></div>
<div>
<div className="text-xs text-slate-400 font-semibold uppercase">Protocol</div>
<div className="text-sm font-bold text-slate-700">{readerInfo?.protocol || 'EPCC1-G2'}</div>
</div>
</div>
<div className="bg-slate-50 border border-slate-100 rounded-lg p-4 flex items-center gap-3">
<div className="p-2 bg-white rounded-md shadow-sm text-amber-600"><Zap className="w-5 h-5" /></div>
<div>
<div className="text-xs text-slate-400 font-semibold uppercase">Power</div>
<div className="text-sm font-bold text-slate-700">{readerInfo ? `${readerInfo.power} dBm` : '--'}</div>
<div className="space-y-3">
<label className="text-sm font-medium text-slate-600">Data Display Format</label>
<div className="flex items-center gap-4">
<label className="flex items-center gap-2 cursor-pointer bg-white px-4 py-2 rounded-lg border border-indigo-100 shadow-sm">
<input
type="radio"
checked={qtFormat === 'hex'}
onChange={() => setQtFormat('hex')}
className="w-4 h-4 text-indigo-600 focus:ring-indigo-500 border-gray-300"
/>
<span className="text-sm text-slate-700">HEX</span>
</label>
<label className="flex items-center gap-2 cursor-pointer bg-white px-4 py-2 rounded-lg border border-indigo-100 shadow-sm">
<input
type="radio"
checked={qtFormat === 'ascii'}
onChange={() => setQtFormat('ascii')}
className="w-4 h-4 text-indigo-600 focus:ring-indigo-500 border-gray-300"
/>
<span className="text-sm text-slate-700">ASCII</span>
</label>
</div>
</div>
</div>
{/* Device Settings Form */}
<div className={`space-y-8 transition-all duration-300 ${isLoaded ? 'opacity-100' : 'opacity-50 pointer-events-none grayscale'}`}>
{/* 1. Communication Settings */}
<div>
<h3 className="text-sm font-bold text-slate-900 uppercase tracking-wider mb-4 flex items-center gap-2">
<span className="w-1 h-4 bg-blue-500 rounded-full"></span>
Communication Parameters
</h3>
<div className="grid grid-cols-1 md:grid-cols-3 gap-6">
<div className="space-y-1">
<label className="text-sm font-medium text-slate-600">Reader Address (Hex)</label>
<input
type="text"
value={address.toString(16).toUpperCase()}
onChange={e => {
const val = parseInt(e.target.value, 16);
if (!isNaN(val) && val >= 0 && val <= 0xFF) setAddress(val);
}}
className="w-full bg-white border border-slate-300 rounded-lg px-3 py-2 text-slate-900 focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none transition-all"
maxLength={2}
/>
</div>
<div className="space-y-1">
<label className="text-sm font-medium text-slate-600">Baud Rate</label>
<select
value={baudRate}
onChange={e => setBaudRate(Number(e.target.value))}
className="w-full bg-white border border-slate-300 rounded-lg px-3 py-2 text-slate-900 focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none transition-all"
>
{baudRates.map(b => <option key={b} value={b}>{b} bps</option>)}
</select>
</div>
<div className="space-y-1">
<label className="text-sm font-medium text-slate-600">Max Response Time</label>
<select
value={maxResponseTime}
onChange={e => setMaxResponseTime(Number(e.target.value))}
className="w-full bg-white border border-slate-300 rounded-lg px-3 py-2 text-slate-900 focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none transition-all"
>
<option value={0}>Auto</option>
<option value={10}>10ms</option>
<option value={20}>20ms</option>
</select>
</div>
</div>
</div>
{/* 2. RF Settings */}
<div>
<h3 className="text-sm font-bold text-slate-900 uppercase tracking-wider mb-4 flex items-center gap-2">
<span className="w-1 h-4 bg-emerald-500 rounded-full"></span>
RF Configuration
</h3>
<div className="grid grid-cols-1 md:grid-cols-3 gap-6 mb-6">
<div className="space-y-1">
<label className="text-sm font-medium text-slate-600">Power Output</label>
<select
value={power}
onChange={e => setPower(Number(e.target.value))}
className="w-full bg-white border border-slate-300 rounded-lg px-3 py-2 text-slate-900 focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none transition-all"
>
{powerLevels.map(p => <option key={p} value={p}>{p} dBm</option>)}
</select>
</div>
<div className="space-y-1">
<label className="text-sm font-medium text-slate-600">Min Frequency</label>
<select
value={minFreq}
onChange={e => setMinFreq(Number(e.target.value))}
disabled={isSingleFreq}
className="w-full bg-white border border-slate-300 rounded-lg px-3 py-2 text-slate-900 focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none transition-all disabled:bg-slate-50 disabled:text-slate-400"
>
<option value={0}>Default</option>
<option value={1}>Custom 1</option>
</select>
</div>
<div className="space-y-1">
<div className="flex justify-between items-center">
<label className="text-sm font-medium text-slate-600">Max Frequency</label>
<label className="flex items-center gap-1.5 cursor-pointer">
<input
type="checkbox"
checked={isSingleFreq}
onChange={e => setIsSingleFreq(e.target.checked)}
className="w-3.5 h-3.5 rounded text-blue-600 focus:ring-blue-500 border-slate-300"
/>
<span className="text-xs text-slate-500">Single Freq</span>
</label>
</div>
<select
value={maxFreq}
onChange={e => setMaxFreq(Number(e.target.value))}
disabled={isSingleFreq}
className="w-full bg-white border border-slate-300 rounded-lg px-3 py-2 text-slate-900 focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none transition-all disabled:bg-slate-50 disabled:text-slate-400"
>
<option value={0}>Default</option>
<option value={1}>Custom 1</option>
</select>
</div>
</div>
<div className="bg-slate-50/80 rounded-lg p-5 border border-slate-200">
<label className="text-xs font-bold text-slate-500 uppercase tracking-wide mb-3 block">Frequency Region / Band</label>
<div className="flex flex-wrap gap-x-8 gap-y-4">
{[
{ label: 'User Defined', value: FrequencyBand.USER },
{ label: 'Chinese Band', value: FrequencyBand.CHINESE },
{ label: 'US Band', value: FrequencyBand.US },
{ label: 'Korean Band', value: FrequencyBand.KOREAN },
{ label: 'EU Band', value: FrequencyBand.EU },
].map((item) => (
<label key={item.value} className="flex items-center gap-2 cursor-pointer group">
<div className={`w-4 h-4 rounded-full border flex items-center justify-center transition-colors ${band === item.value ? 'border-blue-600 bg-blue-600' : 'border-slate-300 bg-white group-hover:border-blue-400'}`}>
{band === item.value && <div className="w-1.5 h-1.5 rounded-full bg-white" />}
</div>
<input
type="radio"
name="band"
checked={band === item.value}
onChange={() => setBand(item.value)}
className="hidden"
/>
<span className={`text-sm ${band === item.value ? 'text-slate-900 font-medium' : 'text-slate-600'}`}>{item.label}</span>
</label>
))}
</div>
</div>
</div>
</div>
<button
onClick={handleSaveLocalSettings}
className="flex items-center justify-center gap-2 px-5 py-2.5 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700 shadow-sm hover:shadow transition-colors font-medium"
title="Save these settings to browser"
>
<Save className="w-4 h-4" />
Save Local Settings
</button>
</div>
</div>
</div>
);
};