mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
reset modal values on close
This commit is contained in:
parent
a8624058e4
commit
1eef86a40c
2 changed files with 19 additions and 4 deletions
|
@ -25,7 +25,7 @@ const updateProfile = async (
|
||||||
_event: Electron.IpcMainInvokeEvent,
|
_event: Electron.IpcMainInvokeEvent,
|
||||||
displayName: string,
|
displayName: string,
|
||||||
newProfileImagePath: string | null
|
newProfileImagePath: string | null
|
||||||
): Promise<UserProfile | null> => {
|
): Promise<UserProfile> => {
|
||||||
if (!newProfileImagePath) {
|
if (!newProfileImagePath) {
|
||||||
return (await patchUserProfile(displayName)).data;
|
return (await patchUserProfile(displayName)).data;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,9 +55,8 @@ export const UserEditProfileModal = ({
|
||||||
patchUser(displayName, newImagePath)
|
patchUser(displayName, newImagePath)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
updateUser();
|
updateUser();
|
||||||
setNewImagePath(null);
|
|
||||||
showSuccessToast("Salvo com sucesso");
|
showSuccessToast("Salvo com sucesso");
|
||||||
onClose();
|
cleanFormAndClose();
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
showErrorToast("Tente novamente");
|
showErrorToast("Tente novamente");
|
||||||
|
@ -66,9 +65,25 @@ export const UserEditProfileModal = ({
|
||||||
setIsSaving(false);
|
setIsSaving(false);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const resetModal = () => {
|
||||||
|
setDisplayName(userProfile.displayName);
|
||||||
|
setNewImagePath(null);
|
||||||
|
setNewImageBase64(null);
|
||||||
|
};
|
||||||
|
|
||||||
|
const cleanFormAndClose = () => {
|
||||||
|
resetModal();
|
||||||
|
onClose();
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Modal visible={visible} title="Editar Perfil" onClose={onClose}>
|
<Modal
|
||||||
|
visible={visible}
|
||||||
|
title="Editar Perfil"
|
||||||
|
onClose={cleanFormAndClose}
|
||||||
|
>
|
||||||
<section
|
<section
|
||||||
style={{
|
style={{
|
||||||
display: "flex",
|
display: "flex",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue