tfrere commited on
Commit
2f38845
·
1 Parent(s): 6ba1570
client/src/components/LeaderboardFilters/LeaderboardFilters.jsx CHANGED
@@ -239,9 +239,7 @@ const LeaderboardFilters = ({ allSections = [] }) => {
239
  count={count}
240
  isActive={isSelected}
241
  onClick={() => {
242
- if (isSelected || count > 0) {
243
- setSelectedCategories(id);
244
- }
245
  }}
246
  colors={groupColors[currentGroup]}
247
  />
 
239
  count={count}
240
  isActive={isSelected}
241
  onClick={() => {
242
+ setSelectedCategories(id);
 
 
243
  }}
244
  colors={groupColors[currentGroup]}
245
  />
client/src/components/LeaderboardSection/index.jsx CHANGED
@@ -1,4 +1,4 @@
1
- import React from "react";
2
  import { Box } from "@mui/material";
3
  import { useLeaderboard } from "../../context/LeaderboardContext";
4
  import SectionHeader from "./components/SectionHeader";
@@ -30,6 +30,43 @@ const LeaderboardSection = ({
30
  const { languages, languageStats, LANGUAGE_FAMILIES, findLanguageFamily } =
31
  useLanguageStats(leaderboards, filteredLeaderboards);
32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  // Filtrer pour n'avoir que les leaderboards approuvés
34
  const approvedLeaderboards = filteredLeaderboards.filter(
35
  (leaderboard) => leaderboard.approval_status === "approved"
@@ -88,7 +125,7 @@ const LeaderboardSection = ({
88
  return (
89
  <Box sx={{ mb: 6 }}>
90
  <SectionHeader
91
- title={title}
92
  count={approvedLeaderboards.length}
93
  isExpanded={isExpanded}
94
  onToggleExpand={toggleExpanded}
@@ -110,7 +147,7 @@ const LeaderboardSection = ({
110
  {approvedLeaderboards.length === 0 ? (
111
  // Afficher EmptyState uniquement si showEmptyState est true
112
  showEmptyState ? (
113
- <EmptyState title={title} searchQuery={searchQuery} />
114
  ) : null
115
  ) : (
116
  <LeaderboardGrid
 
1
+ import React, { useMemo } from "react";
2
  import { Box } from "@mui/material";
3
  import { useLeaderboard } from "../../context/LeaderboardContext";
4
  import SectionHeader from "./components/SectionHeader";
 
30
  const { languages, languageStats, LANGUAGE_FAMILIES, findLanguageFamily } =
31
  useLanguageStats(leaderboards, filteredLeaderboards);
32
 
33
+ // Créer un titre enrichi qui inclut les filtres de langue
34
+ const enrichedTitle = useMemo(() => {
35
+ let newTitle = title;
36
+
37
+ // Ajouter les langues sélectionnées au titre si elles ne sont pas déjà incluses
38
+ if (selectedLanguage && selectedLanguage.size > 0) {
39
+ const languageNames = Array.from(selectedLanguage)
40
+ .map((lang) => lang.charAt(0).toUpperCase() + lang.slice(1))
41
+ .join(", ");
42
+
43
+ // Vérifier si le titre contient déjà "language"
44
+ if (!newTitle.toLowerCase().includes("language")) {
45
+ newTitle = `${newTitle} + Language: ${languageNames}`;
46
+ } else if (
47
+ !newTitle.toLowerCase().includes(languageNames.toLowerCase())
48
+ ) {
49
+ // Si le titre contient "language" mais pas les noms spécifiques
50
+ newTitle = newTitle.replace(
51
+ /language(\s+specific)?/i,
52
+ `Language: ${languageNames}`
53
+ );
54
+ }
55
+ }
56
+
57
+ // Ajouter le terme de recherche s'il existe
58
+ if (
59
+ searchQuery &&
60
+ !newTitle
61
+ .toLowerCase()
62
+ .includes(`matching "${searchQuery.toLowerCase()}"`)
63
+ ) {
64
+ newTitle = `${newTitle} matching "${searchQuery}"`;
65
+ }
66
+
67
+ return newTitle;
68
+ }, [title, selectedLanguage, searchQuery]);
69
+
70
  // Filtrer pour n'avoir que les leaderboards approuvés
71
  const approvedLeaderboards = filteredLeaderboards.filter(
72
  (leaderboard) => leaderboard.approval_status === "approved"
 
125
  return (
126
  <Box sx={{ mb: 6 }}>
127
  <SectionHeader
128
+ title={enrichedTitle}
129
  count={approvedLeaderboards.length}
130
  isExpanded={isExpanded}
131
  onToggleExpand={toggleExpanded}
 
147
  {approvedLeaderboards.length === 0 ? (
148
  // Afficher EmptyState uniquement si showEmptyState est true
149
  showEmptyState ? (
150
+ <EmptyState title={enrichedTitle} searchQuery={searchQuery} />
151
  ) : null
152
  ) : (
153
  <LeaderboardGrid
client/src/components/common/FilterTag.jsx CHANGED
@@ -13,18 +13,17 @@ const FilterTag = ({
13
  isActive,
14
  onClick,
15
  colors = DEFAULT_COLORS,
 
16
  }) => {
17
- const isDisabled = count === 0;
18
-
19
  return (
20
  <Button
21
  onClick={onClick}
22
  variant={isActive ? "contained" : "outlined"}
23
  size="small"
24
- disabled={isDisabled}
25
  sx={{
26
  textTransform: "none",
27
- cursor: isDisabled ? "default" : "pointer",
28
  mb: 0.75,
29
  backgroundColor: (theme) => {
30
  if (isActive) {
@@ -38,9 +37,10 @@ const FilterTag = ({
38
  if (isActive) {
39
  return "white";
40
  }
41
- return colors.main;
42
  },
43
- borderColor: colors.main,
 
44
  "&:hover": {
45
  backgroundColor: (theme) => {
46
  if (isActive) {
@@ -48,7 +48,8 @@ const FilterTag = ({
48
  }
49
  return colors.light;
50
  },
51
- opacity: isDisabled ? 0.6 : 0.8,
 
52
  },
53
  "& .MuiTouchRipple-root": {
54
  transition: "none",
@@ -66,6 +67,7 @@ const FilterTag = ({
66
  gap: 0.75,
67
  color: isActive ? "white" : "inherit",
68
  ml: 0.75,
 
69
  }}
70
  >
71
  <Box
 
13
  isActive,
14
  onClick,
15
  colors = DEFAULT_COLORS,
16
+ isDisabled = count === 0,
17
  }) => {
 
 
18
  return (
19
  <Button
20
  onClick={onClick}
21
  variant={isActive ? "contained" : "outlined"}
22
  size="small"
23
+ disabled={false}
24
  sx={{
25
  textTransform: "none",
26
+ cursor: "pointer",
27
  mb: 0.75,
28
  backgroundColor: (theme) => {
29
  if (isActive) {
 
37
  if (isActive) {
38
  return "white";
39
  }
40
+ return isDisabled ? alpha(colors.main, 0.7) : colors.main;
41
  },
42
+ borderColor: isDisabled ? alpha(colors.main, 0.6) : colors.main,
43
+ opacity: isDisabled ? 0.7 : 1,
44
  "&:hover": {
45
  backgroundColor: (theme) => {
46
  if (isActive) {
 
48
  }
49
  return colors.light;
50
  },
51
+ opacity: isDisabled ? 0.8 : 0.9,
52
+ borderColor: isDisabled ? alpha(colors.main, 0.7) : colors.main,
53
  },
54
  "& .MuiTouchRipple-root": {
55
  transition: "none",
 
67
  gap: 0.75,
68
  color: isActive ? "white" : "inherit",
69
  ml: 0.75,
70
+ opacity: isDisabled ? 0.7 : 1,
71
  }}
72
  >
73
  <Box