mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-29 18:52:22 +01:00
prevent fteched settings to set react components as uncontrolled
This commit is contained in:
parent
2a4a4e6d74
commit
28c868587b
@ -14,7 +14,7 @@ export default class SettingAPI {
|
||||
params.append('names', `['${names.join("','")}']`);
|
||||
|
||||
const res: AxiosResponse = await apiClient.get(`/api/settings?${params.toString()}`);
|
||||
return SettingAPI.toSettingsMap(res?.data);
|
||||
return SettingAPI.toSettingsMap(names, res?.data);
|
||||
}
|
||||
|
||||
async update (name: SettingName, value: any): Promise<Setting> {
|
||||
@ -48,11 +48,10 @@ export default class SettingAPI {
|
||||
return wrapPromise(api.isPresent(name));
|
||||
}
|
||||
|
||||
private static toSettingsMap(data: Object): Map<SettingName, any> {
|
||||
const dataArray: Array<Array<string | any>> = Object.entries(data);
|
||||
private static toSettingsMap(names: Array<SettingName>, data: Object): Map<SettingName, any> {
|
||||
const map = new Map();
|
||||
dataArray.forEach(item => {
|
||||
map.set(item[0] as SettingName, item[1] || '');
|
||||
names.forEach(name => {
|
||||
map.set(name, data[name] || '');
|
||||
});
|
||||
return map;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ const SelectGatewayModal: React.FC<SelectGatewayModalModalProps> = ({ isOpen, to
|
||||
|
||||
useEffect(() => {
|
||||
const gateway = paymentGateway.read();
|
||||
setSelectedGateway(gateway.value);
|
||||
setSelectedGateway(gateway.value ? gateway.value : '');
|
||||
}, []);
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user