0
0
Fork 0
This commit is contained in:
Xeltica 2021-09-24 02:35:58 +09:00
parent 230e952c84
commit ad366c122e
7 changed files with 68 additions and 42 deletions

View file

@ -50,6 +50,7 @@ export const SettingPage: React.VFC = () => {
];
const updateSetting = useCallback((obj: SettingDraftType) => {
const previousDraft = draft;
dispatchDraft(obj);
return fetch(`${API_ENDPOINT}session`, {
method: 'PUT',
@ -58,8 +59,16 @@ export const SettingPage: React.VFC = () => {
'Content-Type': 'application/json',
},
body: JSON.stringify(obj),
});
}, []);
})
.catch(e => {
dispatch(showModal({
type: 'dialog',
icon: 'error',
message: 'エラー'
}));
dispatchDraft(previousDraft);
});
}, [draft]);
const updateSettingWithDialog = useCallback((obj: SettingDraftType) => {
updateSetting(obj)
@ -67,10 +76,7 @@ export const SettingPage: React.VFC = () => {
type: 'dialog',
icon: 'info',
message: '保存しました。'
})))
.catch(e => {
alert(e.message);
});
})));
}, [updateSetting]);
useEffect(() => {