feat: add success and error toast

This commit is contained in:
Hachi-R 2025-01-03 17:36:55 -03:00
parent b68fe300ba
commit ef3bf98903
4 changed files with 12 additions and 4 deletions

View File

@ -182,7 +182,9 @@
"no_write_permission": "Cannot download into this directory. Click here to learn more.",
"reset_achievements": "Reset achievements",
"reset_achievements_description": "This will reset all achievements for {{game}}",
"reset_achievements_title": "Are you sure?"
"reset_achievements_title": "Are you sure?",
"reset_achievements_success": "Achievements successfully reset",
"reset_achievements_error": "Failed to reset achievements"
},
"activation": {
"title": "Activate Hydra",

View File

@ -170,7 +170,9 @@
"no_directory_selected": "Nenhum diretório selecionado",
"reset_achievements": "Resetar conquistas",
"reset_achievements_description": "Isso irá resetar todas as conquistas de {{game}}",
"reset_achievements_title": "Tem certeza?"
"reset_achievements_title": "Tem certeza?",
"reset_achievements_success": "Conquistas resetadas com sucesso",
"reset_achievements_error": "Falha ao resetar conquistas"
},
"activation": {
"title": "Ativação",

View File

@ -30,7 +30,7 @@ const resetGameAchievements = async (
}
);
await HydraApi.delete(`/profile/games/${game.remoteId}/achievements`)
await HydraApi.delete(`/profile/games/achievements/${game.remoteId}`)
.catch((err) => achievementsLogger.error(err))
.then((res) => achievementsLogger.log(res));
@ -46,6 +46,7 @@ const resetGameAchievements = async (
);
} catch (error) {
achievementsLogger.error(error);
throw error;
}
};

View File

@ -149,8 +149,11 @@ export function GameOptionsModal({
setIsDeletingAchievements(true);
try {
await window.electron.resetGameAchievements(game.id);
} finally {
await updateGame();
showSuccessToast(t("reset_achievements_success"));
} catch (error) {
showErrorToast(t("reset_achievements_error"));
} finally {
setIsDeletingAchievements(false);
}
};