Desktop: fix bugs when changing numbers in configuration

This commit is contained in:
Igor Katson 2023-12-08 12:14:17 +00:00
parent 7b5c9cad60
commit 808bef11db
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
8 changed files with 21 additions and 19 deletions

View file

@ -24,7 +24,7 @@ function errorToUIError(
let reason: ErrorDetails = {
method: "INVOKE",
path: path,
text: e.human_readable,
text: e.human_readable ?? e.toString(),
status: e.status,
statusText: e.status_text,
};

View file

@ -9,7 +9,7 @@ const FormCheck: React.FC<{
label: string;
name: string;
checked: boolean;
onChange: (e: any) => void;
onChange: React.ChangeEventHandler<HTMLInputElement>;
disabled?: boolean;
help?: string;
}> = ({ label, name, checked, onChange, disabled, help }) => {
@ -35,7 +35,7 @@ const FormInput: React.FC<{
name: string;
value: string | number;
inputType: string;
onChange: (e: any) => void;
onChange: React.ChangeEventHandler<HTMLInputElement>;
disabled?: boolean;
help?: string;
}> = ({ label, name, value, inputType, onChange, disabled, help }) => {
@ -76,9 +76,13 @@ export const ConfigModal: React.FC<{
const [error, setError] = useState<any | null>(null);
const handleInputChange = (e: any) => {
const handleInputChange: React.ChangeEventHandler<HTMLInputElement> = (e) => {
const name: string = e.target.name;
const value: any = e.target.value;
let value: string | number = e.target.value;
if (e.target.type == "number") {
value = e.target.valueAsNumber;
}
console.log(value, typeof value);
const [mainField, subField] = name.split(".", 2);
if (subField) {
@ -97,7 +101,9 @@ export const ConfigModal: React.FC<{
}
};
const handleToggleChange = (e: any) => {
const handleToggleChange: React.ChangeEventHandler<HTMLInputElement> = (
e
) => {
const name: string = e.target.name;
const [mainField, subField] = name.split(".", 2);