Skip to content

Commit cdec894

Browse files
committed
Transform podium into a Link to the user profile
1 parent 5c0c5ec commit cdec894

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

components/tabs/Ranking/leaderboard.tsx

+16-13
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import { CrownIcon } from "lucide-react";
33
import React from "react";
44

55
import { cn } from "@/lib/utils";
6-
import { transformSecondsToTimeString } from "@/utils/helperFunctions";
6+
import { Link } from "@/navigation";
77

88
import { UsernameLink } from "./UsernameLink";
99

1010
interface PodiumProps {
11-
name: string;
11+
username: string;
1212
value: string;
1313
position: number;
1414
}
@@ -32,12 +32,15 @@ const podiumVariants = cva("", {
3232
},
3333
});
3434

35-
const Podium = ({ name, value, position }: PodiumProps) => {
35+
const Podium = ({ username, value, position }: PodiumProps) => {
3636
const variant =
3737
position === 1 ? "gold" : position === 2 ? "silver" : "bronze";
3838

3939
return (
40-
<div className="w-1/3">
40+
<Link
41+
href={`/profile/${username.replace("@", "")}`}
42+
className={`w-1/3 ${username ? "cursor-pointer" : "pointer-events-none"}`}
43+
>
4144
<div className="flex flex-col items-center md:min-w-[12rem]">
4245
<div className="flex w-full items-center justify-center border-4 border-b-4 border-t-0 border-transparent border-b-neutral-200 dark:border-b-neutral-600">
4346
<div
@@ -65,8 +68,8 @@ const Podium = ({ name, value, position }: PodiumProps) => {
6568
</div>
6669
</div>
6770
<div className="flex w-full flex-col items-center gap-0.5 md:gap-0">
68-
<span className="xs:text-sm max-w-[calc(100%-1rem)] overflow-hidden text-ellipsis whitespace-nowrap text-xs text-neutral-800 dark:text-neutral-50 md:text-lg">
69-
{name}
71+
<span className="xs:text-sm max-w-[calc(100%-1rem)] overflow-hidden text-ellipsis whitespace-nowrap text-xs font-normal text-neutral-800 dark:text-neutral-50 md:text-lg">
72+
{username}
7073
</span>
7174
<div className="flex flex-col items-center gap-1">
7275
<span
@@ -106,11 +109,11 @@ const Podium = ({ name, value, position }: PodiumProps) => {
106109
</div>
107110
</div>
108111
</div>
109-
</div>
112+
</Link>
110113
);
111114
};
112115

113-
export const LeaderboardRow = ({ name, value, position }: PodiumProps) => {
116+
export const LeaderboardRow = ({ username, value, position }: PodiumProps) => {
114117
return (
115118
<li className="py-3 sm:py-4">
116119
<div className="flex items-start space-x-4">
@@ -123,7 +126,7 @@ export const LeaderboardRow = ({ name, value, position }: PodiumProps) => {
123126
</span>
124127
</div>
125128
<div className="min-w-0 flex-1">
126-
<UsernameLink username={name} />
129+
<UsernameLink username={username} />
127130
{/* <div className="text-sm text-muted-foreground ">
128131
{format.dateTime(new Date(entry.created_at), {
129132
dateStyle: "short",
@@ -151,17 +154,17 @@ export const Leaderboard = ({ entries }: LeaderboardProps) => {
151154
<>
152155
<div className="xs:gap-2 bg-light-theme-dotted-pattern dark:bg-dark-theme-dotted-pattern bg-dotted-pattern-size flex items-end justify-center gap-0 border-t border-t-neutral-100 bg-center bg-repeat dark:border-t-neutral-700/75 md:gap-4">
153156
<Podium
154-
name={entries[1]?.name || ""}
157+
username={entries[1]?.name || ""}
155158
value={entries[1]?.value || ""}
156159
position={2}
157160
/>
158161
<Podium
159-
name={entries[0]?.name || ""}
162+
username={entries[0]?.name || ""}
160163
value={entries[0]?.value || ""}
161164
position={1}
162165
/>
163166
<Podium
164-
name={entries[2]?.name || ""}
167+
username={entries[2]?.name || ""}
165168
value={entries[2]?.value || ""}
166169
position={3}
167170
/>
@@ -173,7 +176,7 @@ export const Leaderboard = ({ entries }: LeaderboardProps) => {
173176
entry ? (
174177
<LeaderboardRow
175178
key={entry.name}
176-
name={entry?.name}
179+
username={entry?.name}
177180
position={entry?.position}
178181
value={entry?.value}
179182
/>

0 commit comments

Comments
 (0)