feat: disable reset achievement button if has no achievements

This commit is contained in:
Hachi-R 2025-01-03 18:50:02 -03:00
parent 5061695500
commit 2df57b071d

View File

@ -26,7 +26,7 @@ export function GameOptionsModal({
const { showSuccessToast, showErrorToast } = useToast();
const { updateGame, setShowRepacksModal, repacks, selectGameExecutable } =
const { updateGame, setShowRepacksModal, repacks, selectGameExecutable, achievements } =
useContext(gameDetailsContext);
const [showDeleteModal, setShowDeleteModal] = useState(false);
@ -43,6 +43,10 @@ export function GameOptionsModal({
cancelDownload,
} = useDownload();
const hasAchievements =
(achievements?.filter((achievement) => achievement.unlocked).length ?? 0) >
0;
const deleting = isGameDeleting(game.id);
const { lastPacket } = useDownload();
@ -341,7 +345,7 @@ export function GameOptionsModal({
<Button
onClick={() => setShowResetAchievementsModal(true)}
theme="danger"
disabled={deleting || isDeletingAchievements}
disabled={deleting || isDeletingAchievements || !hasAchievements}
>
{t("reset_achievements")}
</Button>