feat: disable reset achievements button if user is not logged in

This commit is contained in:
Hachi-R 2025-01-03 19:15:31 -03:00
parent 3efb1425b9
commit cade56bb12

View File

@ -5,7 +5,7 @@ import type { Game } from "@types";
import * as styles from "./game-options-modal.css";
import { gameDetailsContext } from "@renderer/context";
import { DeleteGameModal } from "@renderer/pages/downloads/delete-game-modal";
import { useDownload, useToast } from "@renderer/hooks";
import { useDownload, useToast, useUserDetails } from "@renderer/hooks";
import { RemoveGameFromLibraryModal } from "./remove-from-library-modal";
import { ResetAchievementsModal } from "./reset-achievements-modal";
import { FileDirectoryIcon, FileIcon } from "@primer/octicons-react";
@ -48,6 +48,8 @@ export function GameOptionsModal({
cancelDownload,
} = useDownload();
const { userDetails } = useUserDetails();
const hasAchievements =
(achievements?.filter((achievement) => achievement.unlocked).length ?? 0) >
0;
@ -350,7 +352,12 @@ export function GameOptionsModal({
<Button
onClick={() => setShowResetAchievementsModal(true)}
theme="danger"
disabled={deleting || isDeletingAchievements || !hasAchievements}
disabled={
deleting ||
isDeletingAchievements ||
!hasAchievements ||
!userDetails
}
>
{t("reset_achievements")}
</Button>