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