From 567c261481b6fe05c5fcd78ddbc684e618667a33 Mon Sep 17 00:00:00 2001 From: Wes Copeland Date: Wed, 15 Jan 2025 08:22:46 -0500 Subject: [PATCH 1/4] fix(UnlockableAchievementAvatar): use --- lang/en_US.json | 4 ++-- .../UnlockableAchievementAvatar.tsx | 16 +++++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lang/en_US.json b/lang/en_US.json index d406bd1efb..c7156fd0ee 100644 --- a/lang/en_US.json +++ b/lang/en_US.json @@ -136,7 +136,6 @@ "Forum Index": "Forum Index", "Forum Posts": "Forum Posts", "Forum Posts - {{user}}": "Forum Posts - {{user}}", - "from": "from", "Game": "Game", "Game Details": "Game Details", "Games": "Games", @@ -613,5 +612,6 @@ "Similar masteries": "Similar masteries", "Beaten by players of": "Beaten by players of", "Mastered by players of": "Mastered by players of", - "Roll again": "Roll again" + "Roll again": "Roll again", + "<1>{{achievementTitle}} from <2>{{gameTitle}}": "<1>{{achievementTitle}} from <2>{{gameTitle}}" } \ No newline at end of file diff --git a/resources/js/features/achievements/components/UnlockableAchievementAvatar/UnlockableAchievementAvatar.tsx b/resources/js/features/achievements/components/UnlockableAchievementAvatar/UnlockableAchievementAvatar.tsx index 11aa7b3934..f6125e5932 100644 --- a/resources/js/features/achievements/components/UnlockableAchievementAvatar/UnlockableAchievementAvatar.tsx +++ b/resources/js/features/achievements/components/UnlockableAchievementAvatar/UnlockableAchievementAvatar.tsx @@ -1,5 +1,5 @@ import type { FC } from 'react'; -import { useTranslation } from 'react-i18next'; +import { Trans } from 'react-i18next'; import { AchievementAvatar } from '@/common/components/AchievementAvatar'; import { GameAvatar } from '@/common/components/GameAvatar'; @@ -17,8 +17,6 @@ export const UnlockableAchievementAvatar: FC = showGame = false, imageSize = 48, }) => { - const { t } = useTranslation(); - const badgeUrl = !achievement.unlockedAt && !achievement.unlockedHardcoreAt ? achievement.badgeLockedUrl @@ -30,7 +28,7 @@ export const UnlockableAchievementAvatar: FC = {...achievement} showHardcoreUnlockBorder={!!achievement.unlockedHardcoreAt} badgeUnlockedUrl={badgeUrl} - // TODO: showPointsInTitle={true} + showPointsInTitle={true} showLabel={false} size={imageSize} /> @@ -41,7 +39,15 @@ export const UnlockableAchievementAvatar: FC = {showGame && achievement.game ? ( <> - {t('from')} + , + 2: , + }} + values={{ achievementTitle: achievement.title, gameTitle: achievement.game.title }} + /> + ) : null} From ff7de61b11dd0a96ab2f07d6729042a4dd137ef3 Mon Sep 17 00:00:00 2001 From: Wes Copeland Date: Wed, 15 Jan 2025 08:27:52 -0500 Subject: [PATCH 2/4] chore: vitest --- .../AchievementGroup/AchievementGroup.test.tsx | 10 ++++++---- .../UnlockableAchievementAvatar.test.tsx | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/resources/js/features/achievements/components/AchievementGroup/AchievementGroup.test.tsx b/resources/js/features/achievements/components/AchievementGroup/AchievementGroup.test.tsx index df104cb0f0..fb97989e5e 100644 --- a/resources/js/features/achievements/components/AchievementGroup/AchievementGroup.test.tsx +++ b/resources/js/features/achievements/components/AchievementGroup/AchievementGroup.test.tsx @@ -68,12 +68,14 @@ describe('Component: AchievementGroup', () => { render(); // ASSERT - expect(screen.getByText(/First Achievement/)).toBeVisible(); - expect(screen.getByText(/First Game/)).toBeVisible(); + expect(screen.getAllByText(/First Achievement/)[0]).toBeVisible(); + expect(screen.getAllByText(/First Game/)[0]).toBeVisible(); expect(screen.getByText(/Do the first thing/)).toBeVisible(); - expect(screen.getByText(/Second Achievement/)).toBeVisible(); + + expect(screen.getAllByText(/Second Achievement/)[0]).toBeVisible(); expect(screen.getByText(/Do the second thing/)).toBeVisible(); - expect(screen.getByText(/Third Achievement/)).toBeVisible(); + + expect(screen.getAllByText(/Third Achievement/)[0]).toBeVisible(); expect(screen.getByText(/Do the third thing/)).toBeVisible(); }); }); diff --git a/resources/js/features/achievements/components/UnlockableAchievementAvatar/UnlockableAchievementAvatar.test.tsx b/resources/js/features/achievements/components/UnlockableAchievementAvatar/UnlockableAchievementAvatar.test.tsx index 3f30ddaf47..2d21a739e6 100644 --- a/resources/js/features/achievements/components/UnlockableAchievementAvatar/UnlockableAchievementAvatar.test.tsx +++ b/resources/js/features/achievements/components/UnlockableAchievementAvatar/UnlockableAchievementAvatar.test.tsx @@ -106,8 +106,8 @@ describe('Component: UnlockableAchievementAvatar', () => { expect(img).toBeVisible(); expect(img.src).toContain(achievement.badgeLockedUrl); - expect(screen.getByText(/Creative Name/)).toBeVisible(); - expect(screen.getByText(/Container Set/)).toBeVisible(); + expect(screen.getAllByText(/Creative Name/)[0]).toBeVisible(); + expect(screen.getAllByText(/Container Set/)[0]).toBeVisible(); expect(screen.getByText(/Do the thing/)).toBeVisible(); expect(screen.queryByText(/unlocked/i)).toBeNull(); }); From 9280b7a68efdc8f272ad0fc5d8a9e76ab1fa9b0e Mon Sep 17 00:00:00 2001 From: Wes Copeland Date: Wed, 15 Jan 2025 08:32:50 -0500 Subject: [PATCH 3/4] chore: fix points in title --- .../UnlockableAchievementAvatar.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/resources/js/features/achievements/components/UnlockableAchievementAvatar/UnlockableAchievementAvatar.tsx b/resources/js/features/achievements/components/UnlockableAchievementAvatar/UnlockableAchievementAvatar.tsx index f6125e5932..5924cbd321 100644 --- a/resources/js/features/achievements/components/UnlockableAchievementAvatar/UnlockableAchievementAvatar.tsx +++ b/resources/js/features/achievements/components/UnlockableAchievementAvatar/UnlockableAchievementAvatar.tsx @@ -28,14 +28,13 @@ export const UnlockableAchievementAvatar: FC = {...achievement} showHardcoreUnlockBorder={!!achievement.unlockedHardcoreAt} badgeUnlockedUrl={badgeUrl} - showPointsInTitle={true} showLabel={false} size={imageSize} />
- + {showGame && achievement.game ? ( <> From 47d00c8e8680e794557d5060f6d55ad957b0a656 Mon Sep 17 00:00:00 2001 From: Wes Copeland Date: Thu, 16 Jan 2025 19:45:02 -0500 Subject: [PATCH 4/4] fix: address pr feedback --- .../UnlockableAchievementAvatar.tsx | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/resources/js/features/achievements/components/UnlockableAchievementAvatar/UnlockableAchievementAvatar.tsx b/resources/js/features/achievements/components/UnlockableAchievementAvatar/UnlockableAchievementAvatar.tsx index 5924cbd321..c5f5eae761 100644 --- a/resources/js/features/achievements/components/UnlockableAchievementAvatar/UnlockableAchievementAvatar.tsx +++ b/resources/js/features/achievements/components/UnlockableAchievementAvatar/UnlockableAchievementAvatar.tsx @@ -34,22 +34,20 @@ export const UnlockableAchievementAvatar: FC =
- - {showGame && achievement.game ? ( - <> - , - 2: , - }} - values={{ achievementTitle: achievement.title, gameTitle: achievement.game.title }} - /> - - - - ) : null} + + ), + 2: , + }} + values={{ achievementTitle: achievement.title, gameTitle: achievement.game.title }} + /> + ) : ( + + )}
{achievement.description}