-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: badge acquiring logic (#280)
* refactor: badge acquiring logic * Update user.ts
- Loading branch information
Showing
2 changed files
with
22 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,20 @@ | ||
export const getPointsBadge = (points: number) => { | ||
const badges = []; | ||
if (points >= 100000) { | ||
return "gold"; | ||
} else if (points >= 50000) { | ||
return "silver"; | ||
} else if (points >= 20000) { | ||
return "bronze"; | ||
badges.push("gold"); | ||
} | ||
return ""; | ||
if (points >= 50000) { | ||
badges.push("silver"); | ||
} | ||
if (points >= 20000) { | ||
badges.push("bronze"); | ||
} | ||
return badges; | ||
}; | ||
|
||
export const verifyAcquiredPointsBadge = ( | ||
badgeName: string, | ||
badgeNames: string[], | ||
currentBadges: string[], | ||
) => { | ||
return badgeName !== "" && !currentBadges.includes(badgeName); | ||
return badgeNames.filter((badge) => !currentBadges.includes(badge)); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters