fix: address comments

This commit is contained in:
abdou6666 2024-12-16 17:44:08 +01:00
parent e55b801cb0
commit 6b7a5bf0a2
3 changed files with 3 additions and 8 deletions

View File

@ -150,7 +150,7 @@ export class SettingRepository extends BaseRepository<Setting> {
} else if (type === SettingType.secret && typeof value !== 'string') {
throw new Error('Setting Model (secret) : Value must be a string');
} else if (type === SettingType.select && typeof value !== 'string') {
throw new Error('Setting Model (select): Value must be a string array!');
throw new Error('Setting Model (select): Value must be a string!');
}
}

View File

@ -95,6 +95,7 @@ const SettingInput: React.FC<RenderSettingInputProps> = ({
label={label}
helperText={helperText}
{...field}
onChange={(e) => field.onChange(Number(e.target.value))}
disabled={isDisabled(setting)}
/>
);

View File

@ -133,14 +133,8 @@ export const Settings = () => {
useEffect(() => {
const subscription = watch((values, { name }) => {
const [group, label] = (name as string).split(".");
const currentSettingValue = values[group][label] as any;
// if setting value is Number but typed string convert it to number
const settingValue =
typeof values[group][label] === "string" && isNaN(currentSettingValue)
? values[group][label]
: Number(values[group][label]);
debouncedUpdate(group, label, settingValue);
debouncedUpdate(group, label, values[group][label]);
});
return () => {