mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
fix: address comments
This commit is contained in:
parent
e55b801cb0
commit
6b7a5bf0a2
@ -150,7 +150,7 @@ export class SettingRepository extends BaseRepository<Setting> {
|
|||||||
} else if (type === SettingType.secret && typeof value !== 'string') {
|
} else if (type === SettingType.secret && typeof value !== 'string') {
|
||||||
throw new Error('Setting Model (secret) : Value must be a string');
|
throw new Error('Setting Model (secret) : Value must be a string');
|
||||||
} else if (type === SettingType.select && typeof value !== '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!');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,6 +95,7 @@ const SettingInput: React.FC<RenderSettingInputProps> = ({
|
|||||||
label={label}
|
label={label}
|
||||||
helperText={helperText}
|
helperText={helperText}
|
||||||
{...field}
|
{...field}
|
||||||
|
onChange={(e) => field.onChange(Number(e.target.value))}
|
||||||
disabled={isDisabled(setting)}
|
disabled={isDisabled(setting)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
@ -133,14 +133,8 @@ export const Settings = () => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const subscription = watch((values, { name }) => {
|
const subscription = watch((values, { name }) => {
|
||||||
const [group, label] = (name as string).split(".");
|
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 () => {
|
return () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user