This commit is contained in:
Hunter Thornsberry
2024-08-10 19:07:02 -04:00
parent 1eedb6d97b
commit e7892fd6a0
6 changed files with 52 additions and 41 deletions
+15 -23
View File
@@ -59,48 +59,40 @@ export const Channel = ({ channel }: SettingsPanelProps): JSX.Element => {
};
const validatePass = (input: string, count: number) => {
if (count == 32) {
if (input.length != 44) {
if (count === 32) {
if (input.length !== 44) {
setValidationText("Please enter a valid 256 bit PSK.");
}
else {
} else {
setValidationText(undefined);
}
}
else if (count == 16)
{
if (input.length != 24) {
} else if (count === 16) {
if (input.length !== 24) {
setValidationText("Please enter a valid 128 bit PSK.");
}
else {
} else {
setValidationText(undefined);
}
}
else if (count == 1)
{
if (input.length != 4) {
} else if (count === 1) {
if (input.length !== 4) {
setValidationText("Please enter a valid 1 bit PSK");
}
else {
} else {
setValidationText(undefined);
}
}
else {
} else {
setValidationText("Unkown PSK length.");
}
}
};
const inputChangeEvent = (e) => {
let psk = e.currentTarget?.value;
const psk = e.currentTarget?.value;
setPass(psk);
validatePass(psk, bitCount);
};
const selectChangeEvent = (e: string) => {
let count = Number.parseInt(e);
const count = Number.parseInt(e);
setBits(count);
validatePass(pass, count);
}
};
return (
<DynamicForm<ChannelValidation>
@@ -152,7 +144,7 @@ export const Channel = ({ channel }: SettingsPanelProps): JSX.Element => {
selectChange: selectChangeEvent,
buttonClick: clickEvent,
properties: {
value: pass
value: pass,
},
},
{