Skip to content

Commit 79aa296

Browse files
jackstownNevexo
authored andcommitted
custom-vidpid: fix for initial values being empty
1 parent c23101a commit 79aa296

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

ui/src/components/USBConfigDialog.tsx

+9-11
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,13 @@ function UpdateUsbConfigModal({
7878
onCancel: () => void;
7979
error: string | null;
8080
}) {
81-
const [usbConfig, setUsbConfig] = useState({
81+
const [usbConfigState, setUsbConfigState] = useState<UsbConfigState>({
8282
vendor_id: '',
8383
product_id: '',
8484
serial_number: '',
8585
manufacturer: '',
86-
product: '',
87-
})
88-
89-
const [usbConfigState, setUsbConfigState] = useState<UsbConfigState>();
86+
product: ''
87+
});
9088
const [send] = useJsonRpc();
9189

9290
const syncUsbConfig = useCallback(() => {
@@ -105,23 +103,23 @@ function UpdateUsbConfigModal({
105103
}, [syncUsbConfig]);
106104

107105
const handleUsbVendorIdChange = (value: string) => {
108-
setUsbConfig({... usbConfig, vendor_id: value})
106+
setUsbConfigState({... usbConfigState, vendor_id: value})
109107
};
110108

111109
const handleUsbProductIdChange = (value: string) => {
112-
setUsbConfig({... usbConfig, product_id: value})
110+
setUsbConfigState({... usbConfigState, product_id: value})
113111
};
114112

115113
const handleUsbSerialChange = (value: string) => {
116-
setUsbConfig({... usbConfig, serial_number: value})
114+
setUsbConfigState({... usbConfigState, serial_number: value})
117115
};
118116

119117
const handleUsbManufacturer = (value: string) => {
120-
setUsbConfig({... usbConfig, manufacturer: value})
118+
setUsbConfigState({... usbConfigState, manufacturer: value})
121119
};
122120

123121
const handleUsbProduct = (value: string) => {
124-
setUsbConfig({... usbConfig, product: value})
122+
setUsbConfigState({... usbConfigState, product: value})
125123
};
126124

127125
return (
@@ -180,7 +178,7 @@ function UpdateUsbConfigModal({
180178
size="SM"
181179
theme="primary"
182180
text="Update USB Config"
183-
onClick={() => onSetUsbConfig(usbConfig)}
181+
onClick={() => onSetUsbConfig(usbConfigState)}
184182
/>
185183
<Button size="SM" theme="light" text="Not Now" onClick={onCancel} />
186184
</div>

0 commit comments

Comments
 (0)