Skip to content

Commit

Permalink
fix(user): calculate ranking (#367)
Browse files Browse the repository at this point in the history
  • Loading branch information
haydencleary authored Oct 10, 2024
1 parent 607cb29 commit 3532b90
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class ApplicationListItem implements ApplicationListItemInterface {
getRank(): string {
const position = this.applicant?.globalRank;

if (position === undefined) {
if (typeof position !== "number") {
return "";
}

Expand Down
3 changes: 2 additions & 1 deletion core/domain/user/models/user-public-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ export class UserPublic implements UserPublicInterface {

getRank(): string {
const position = this.statsSummary?.rank;
if (position === undefined) {

if (typeof position !== "number") {
return "";
}
// Check the last two digits to handle special cases like 11th, 12th, 13th, etc.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export function ProfileCard({ user, headerProps, footerContent }: ProfileCardPro
}, [headerProps]);

const showRankPercentile = !!user.statsSummary?.rankPercentile && user.statsSummary?.rankPercentile !== 100;
const userRank = user.getRank();

return (
<Paper border={"primary"} classNames={{ base: "flex flex-col gap-lg" }}>
{renderHeader}
Expand All @@ -35,7 +37,8 @@ export function ProfileCard({ user, headerProps, footerContent }: ProfileCardPro
{user.login}
</Typo>
<Typo as={"div"} size={"sm"} color={"tertiary"}>
{user.getTitle().wording}{user.getRank()}
{user.getTitle().wording}
{userRank ? ` • ${userRank}` : null}
{showRankPercentile ? (
<>
{" • "}
Expand Down

0 comments on commit 3532b90

Please sign in to comment.