Skip to content

Commit

Permalink
fix(UnlockableAchievementAvatar): swap t() for <Trans /> (#3063)
Browse files Browse the repository at this point in the history
  • Loading branch information
wescopeland authored Jan 17, 2025
1 parent b6aa4a8 commit bfac07e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 19 deletions.
4 changes: 2 additions & 2 deletions lang/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -626,5 +625,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}}</1> from <2>{{gameTitle}}</2>": "<1>{{achievementTitle}}</1> from <2>{{gameTitle}}</2>"
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,14 @@ describe('Component: AchievementGroup', () => {
render(<AchievementGroup group={group} showGame={true} />);

// 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();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -17,8 +17,6 @@ export const UnlockableAchievementAvatar: FC<UnlockableAchievementAvatarProps> =
showGame = false,
imageSize = 48,
}) => {
const { t } = useTranslation();

const badgeUrl =
!achievement.unlockedAt && !achievement.unlockedHardcoreAt
? achievement.badgeLockedUrl
Expand All @@ -30,21 +28,26 @@ export const UnlockableAchievementAvatar: FC<UnlockableAchievementAvatarProps> =
{...achievement}
showHardcoreUnlockBorder={!!achievement.unlockedHardcoreAt}
badgeUnlockedUrl={badgeUrl}
// TODO: showPointsInTitle={true}
showLabel={false}
size={imageSize}
/>

<div>
<div className="flex items-center gap-2">
<AchievementAvatar {...achievement} showImage={false} />

{showGame && achievement.game ? (
<>
<span>{t('from')}</span>
<GameAvatar {...achievement.game} showImage={false} />
</>
) : null}
<Trans
i18nKey="<1>{{achievementTitle}}</1> from <2>{{gameTitle}}</2>"
components={{
1: (
<AchievementAvatar {...achievement} showImage={false} showPointsInTitle={true} />
),
2: <GameAvatar {...achievement.game} showImage={false} />,
}}
values={{ achievementTitle: achievement.title, gameTitle: achievement.game.title }}
/>
) : (
<AchievementAvatar {...achievement} showImage={false} showPointsInTitle={true} />
)}
</div>

<span>{achievement.description}</span>
Expand Down

0 comments on commit bfac07e

Please sign in to comment.