feat: update compare achievement response

This commit is contained in:
Zamitto 2024-10-20 14:37:30 -03:00
parent 1d7858438d
commit 33e91e2007
6 changed files with 43 additions and 29 deletions

View file

@ -317,10 +317,10 @@ export function AchievementsContent({
...userDetails,
userId: userDetails.id,
totalAchievementCount: comparedAchievements
? comparedAchievements.ownerUser.totalAchievementCount
? comparedAchievements.owner.totalAchievementCount
: achievements!.length,
unlockedAchievementCount: comparedAchievements
? comparedAchievements.ownerUser.unlockedAchievementCount
? comparedAchievements.owner.unlockedAchievementCount
: achievements!.filter((achievement) => achievement.unlocked)
.length,
}}

View file

@ -53,12 +53,11 @@ export default function Achievements() {
return {
userId: otherUserId,
displayName: comparedAchievements.otherUser.displayName,
profileImageUrl: comparedAchievements.otherUser.profileImageUrl,
totalAchievementCount:
comparedAchievements.otherUser.totalAchievementCount,
displayName: comparedAchievements.target.displayName,
profileImageUrl: comparedAchievements.target.profileImageUrl,
totalAchievementCount: comparedAchievements.target.totalAchievementCount,
unlockedAchievementCount:
comparedAchievements.otherUser.unlockedAchievementCount,
comparedAchievements.target.unlockedAchievementCount,
};
}, [otherUserId, comparedAchievements]);

View file

@ -21,7 +21,7 @@ export function ComparedAchievementList({
className={styles.listItem}
style={{
display: "grid",
gridTemplateColumns: achievement.onwerUserStat
gridTemplateColumns: achievement.ownerStat
? "3fr 1fr 1fr"
: "3fr 2fr",
}}
@ -48,8 +48,8 @@ export function ComparedAchievementList({
</div>
</div>
{achievement.onwerUserStat ? (
achievement.onwerUserStat.unlocked ? (
{achievement.ownerStat ? (
achievement.ownerStat.unlocked ? (
<div
style={{
whiteSpace: "nowrap",
@ -61,7 +61,7 @@ export function ComparedAchievementList({
>
<CheckCircleIcon />
<small>
{formatDateTime(achievement.onwerUserStat.unlockTime!)}
{formatDateTime(achievement.ownerStat.unlockTime!)}
</small>
</div>
) : (
@ -77,7 +77,7 @@ export function ComparedAchievementList({
)
) : null}
{achievement.otherUserStat.unlocked ? (
{achievement.targetStat.unlocked ? (
<div
style={{
whiteSpace: "nowrap",
@ -89,7 +89,7 @@ export function ComparedAchievementList({
>
<CheckCircleIcon />
<small>
{formatDateTime(achievement.otherUserStat.unlockTime!)}
{formatDateTime(achievement.targetStat.unlockTime!)}
</small>
</div>
) : (