1
0
mirror of https://gitlab.nic.cz/turris/reforis/foris-js.git synced 2024-12-26 00:21:36 +01:00

!fixup WiFi API update

This commit is contained in:
Aleksandr Gumroian 2024-12-05 09:36:47 +01:00
parent 01d4ae74e4
commit 30fa79b55e
No known key found for this signature in database
GPG Key ID: 9E77849C64F0A733

View File

@ -156,25 +156,25 @@ function DeviceForm({
<RadioSet <RadioSet
name={`band-${deviceID}`} name={`band-${deviceID}`}
label="GHz" label={_("Band")}
choices={getBandChoices(formData)} choices={getBandChoices(formData)}
value={formData.band} value={formData.band}
helpText={HELP_TEXTS.band} helpText={HELP_TEXTS.band}
inline inline
onChange={setFormValue((value) => { onChange={setFormValue((value) => {
// Get the last item in an array of available HT modes // Find the selected band
const [best2] = bnds[0].available_htmodes.slice(-1); const selectedBand = bnds.find(
const [best5] = bnds[1].available_htmodes.slice(-1); (band) => band.band === value
);
// Get the last item in the available HT modes for the selected band
const bestHtmode =
selectedBand.available_htmodes.slice(-1)[0];
return { return {
devices: { devices: {
[deviceIndex]: { [deviceIndex]: {
band: { $set: value }, band: { $set: value },
channel: { $set: "0" }, channel: { $set: "0" },
htmode: { htmode: { $set: bestHtmode },
$set:
// Set HT mode depending on checked frequency
value === "11a" ? best5 : best2,
},
}, },
}, },
}; };
@ -293,7 +293,7 @@ function getHtmodeChoices(device) {
function getBandChoices(device) { function getBandChoices(device) {
return device.available_bands.map((availableBand) => ({ return device.available_bands.map((availableBand) => ({
label: BANDS[availableBand.band], label: BANDS[availableBand.band] + _(" GHz"),
value: availableBand.band, value: availableBand.band,
})); }));
} }