diff --git a/src/components/Leaderboard.tsx b/src/components/Leaderboard.tsx index 6ad5041..0132d26 100644 --- a/src/components/Leaderboard.tsx +++ b/src/components/Leaderboard.tsx @@ -53,6 +53,7 @@ export function Leaderboard() { const { data: allProblems } = useProblems(); const { data: leaderboardIndex } = useLeaderboardIndex(); const leaderboardData = leaderboardIndex?.combined?.[leaderboard]; + const hasAffiliation = !!leaderboardIndex?.dynamic?.[leaderboard]; useEffect(() => { document.title = leaderboardData?.name ?? "Leaderboard"; }, [leaderboardData?.name]); @@ -151,6 +152,16 @@ export function Leaderboard() { )} {calculatedUsers .filter((a) => !!a.score || a.user.id === user?.uid) + .filter( + (u) => + !hasAffiliation || + !!( + u.user.affiliation && + leaderboard + .toLowerCase() + .startsWith(u.user.affiliation.toLowerCase()) + ) + ) .sort((a, b) => b.score - a.score) .map((u, i) => ( ))} diff --git a/src/components/LeaderboardSelector.tsx b/src/components/LeaderboardSelector.tsx index 49c65a6..1cf5d7f 100644 --- a/src/components/LeaderboardSelector.tsx +++ b/src/components/LeaderboardSelector.tsx @@ -22,7 +22,7 @@ export default function LeaderboardSelector() { key={key} setLeaderboard={(leaderboard) => setLeaderboard({ leaderboard })} isSelected={key === leaderboard} - isDynamic={data.dynamic.hasOwnProperty(key)} + isDynamic={!!data.dynamic?.hasOwnProperty(key)} name={board.name ?? key} /> )); diff --git a/src/hooks/UseLeaderboard.tsx b/src/hooks/UseLeaderboard.tsx index 2104f48..0a1706a 100644 --- a/src/hooks/UseLeaderboard.tsx +++ b/src/hooks/UseLeaderboard.tsx @@ -77,7 +77,7 @@ export const useLeaderboardIndex = () => { : undefined; const data = { combined: { ...(transformedData ?? {}), ...staticLeaderboard }, - dynamic: transformedData ?? {}, + dynamic: transformedData, static: staticLeaderboard, }; return { diff --git a/src/hooks/UseUser.tsx b/src/hooks/UseUser.tsx index 46446f1..8adee82 100644 --- a/src/hooks/UseUser.tsx +++ b/src/hooks/UseUser.tsx @@ -7,6 +7,7 @@ export type User = { display_name: string; id: string; kattis_submissions: Record; + affiliation?: string; codeforces_submissions: | (Record< string, diff --git a/src/output.css b/src/output.css index d92552c..d19691e 100644 --- a/src/output.css +++ b/src/output.css @@ -838,6 +838,10 @@ video { opacity: 0.1; } +.opacity-50 { + opacity: 0.5; +} + .shadow-lg { --tw-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1); --tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);