Skip to content

Commit f9bd61a

Browse files
BMorgan1296philon-
andauthored
Fixed overrideFrequency Input Constraints (#801)
* Fixed overrideFrequency to properly allow for floats with a minimum of 410 MHz and maximum of 930 MHz. Added 3 decimal point check. * Removed duplicate error message in FormInput.tsx * Added error message for overrideFrequency in several locales * Simplified check and reverted translated languages to English besides German. Also fixed a typo in src/components/UI/Input.tsx. * Let i18n handle fallback + linting --------- Co-authored-by: philon- <[email protected]>
1 parent bcdda8b commit f9bd61a

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

packages/web/public/i18n/locales/de-DE/common.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@
135135
"generic": "Dies ist ein Pflichtfeld.",
136136
"managed": "Mindestens ein administrativer Schlüssel wird benötigt, um diesen Knoten zu verwalten",
137137
"key": "Schlüssel erforderlich."
138+
},
139+
"invalidOverrideFreq": {
140+
"number": "Ungültiges Format, erwartet 430-930 MHz."
138141
}
139142
},
140143
"yes": "Ja",

packages/web/public/i18n/locales/en/common.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@
111111
"generic": "This field is required.",
112112
"managed": "At least one admin key is requred if the node is managed.",
113113
"key": "Key is required."
114+
},
115+
"invalidOverrideFreq": {
116+
"number": "Invalid format, expected between 430-930 MHz."
114117
}
115118
},
116119
"yes": "Yes",

packages/web/src/components/Form/DynamicFormField.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ export function DynamicFormField<T extends FieldValues>({
5252
control={control}
5353
disabled={disabled}
5454
isDirty={isDirty}
55-
invalid={invalid}
5655
/>
5756
);
5857

packages/web/src/components/Form/FormInput.tsx

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ export function GenericInput<T extends FieldValues>({
3030
control,
3131
disabled,
3232
field,
33-
invalid,
3433
}: GenericFormElementProps<T, InputFieldProps<T>>) {
3534
const { fieldLength, ...restProperties } = field.properties || {};
3635

@@ -46,8 +45,6 @@ export function GenericInput<T extends FieldValues>({
4645
},
4746
});
4847

49-
const isInvalid = invalid || Boolean(error?.message);
50-
5148
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
5249
const newValue = e.target.value;
5350

@@ -100,12 +97,6 @@ export function GenericInput<T extends FieldValues>({
10097
{currentLength}/{fieldLength.max}
10198
</div>
10299
)}
103-
104-
{isInvalid && (
105-
<div className="absolute inset-y-12 bottom-0 flex items-center pr-3">
106-
<p className="text-sm text-red-500">{error?.message ?? ""}</p>
107-
</div>
108-
)}
109100
</div>
110101
);
111102
}

packages/web/src/components/UI/Input.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const cnInvalidBase = "border-2 border-red-500 dark:border-red-500";
1010
const cnDirtyBase = "border-2 border-sky-500 dark:border-sky-500";
1111

1212
const inputVariants = cva(
13-
"flex h-10 w-full rounded-md border border-slate-300 bg-transparent py-2 px-3 text-sm placeholder:text-slate-400 focus:outline-none focus:ring-1 focus:ring-slate-400 disabled:cursor-not-allowed disabled:opacity-50 dark:border-slate-500 dark:bg-transparet dark:text-slate-100 dark:focus:ring-slate-400 dark:focus:ring-offset-slate-600",
13+
"flex h-10 w-full rounded-md border border-slate-300 bg-transparent py-2 px-3 text-sm placeholder:text-slate-400 focus:outline-none focus:ring-1 focus:ring-slate-400 disabled:cursor-not-allowed disabled:opacity-50 dark:border-slate-500 dark:bg-transparent dark:text-slate-100 dark:focus:ring-slate-400 dark:focus:ring-offset-slate-600",
1414
{
1515
variants: {
1616
variant: {

packages/web/src/validation/config/lora.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ export const LoRaValidationSchema = z.object({
1818
channelNum: z.coerce.number().int(),
1919
overrideDutyCycle: z.boolean(),
2020
sx126xRxBoostedGain: z.boolean(),
21-
overrideFrequency: z.coerce.number().int(),
21+
overrideFrequency: z.coerce
22+
.number()
23+
.refine((val) => val >= 410 && val <= 930, {
24+
message: "formValidation.invalidOverrideFreq.number",
25+
}),
2226
ignoreIncoming: z.coerce.number().array(),
2327
ignoreMqtt: z.boolean(),
2428
configOkToMqtt: z.boolean(),

0 commit comments

Comments
 (0)