website refactor
This commit is contained in:
@@ -34,12 +34,31 @@ export function TeamLeaderboardPageWrapper({ viewData }: ClientWrapperProps<Team
|
||||
router.push('/teams');
|
||||
};
|
||||
|
||||
// Apply filtering and sorting
|
||||
const filteredAndSortedTeams = viewData.teams
|
||||
.filter((team) => {
|
||||
const matchesSearch = team.name.toLowerCase().includes(searchQuery.toLowerCase());
|
||||
const matchesLevel = filterLevel === 'all' || team.performanceLevel === filterLevel;
|
||||
return matchesSearch && matchesLevel;
|
||||
})
|
||||
.sort((a, b) => {
|
||||
if (sortBy === 'rating') return (b.rating || 0) - (a.rating || 0);
|
||||
if (sortBy === 'wins') return b.totalWins - a.totalWins;
|
||||
if (sortBy === 'winRate') {
|
||||
const rateA = a.totalRaces > 0 ? a.totalWins / a.totalRaces : 0;
|
||||
const rateB = b.totalRaces > 0 ? b.totalWins / b.totalRaces : 0;
|
||||
return rateB - rateA;
|
||||
}
|
||||
if (sortBy === 'races') return b.totalRaces - a.totalRaces;
|
||||
return 0;
|
||||
});
|
||||
|
||||
const templateViewData = {
|
||||
teams: viewData.teams,
|
||||
searchQuery,
|
||||
filterLevel,
|
||||
sortBy,
|
||||
filteredAndSortedTeams: viewData.teams,
|
||||
filteredAndSortedTeams,
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user