Spaces:
Running
Running
add no match block in the leaderboard page
Browse files
client/src/components/LeaderboardFilters/LeaderboardFilters.jsx
CHANGED
|
@@ -45,7 +45,7 @@ const LeaderboardFilters = ({ allSections }) => {
|
|
| 45 |
<Box
|
| 46 |
sx={{
|
| 47 |
width: {
|
| 48 |
-
xs: "
|
| 49 |
md: "60%",
|
| 50 |
},
|
| 51 |
}}
|
|
|
|
| 45 |
<Box
|
| 46 |
sx={{
|
| 47 |
width: {
|
| 48 |
+
xs: "100%",
|
| 49 |
md: "60%",
|
| 50 |
},
|
| 51 |
}}
|
client/src/pages/LeaderboardPage/LeaderboardPage.jsx
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
| 11 |
Typography,
|
| 12 |
} from "@mui/material";
|
| 13 |
import SearchIcon from "@mui/icons-material/Search";
|
|
|
|
| 14 |
import Logo from "../../components/Logo/Logo";
|
| 15 |
import PageTitle from "../../components/PageTitle/PageTitle";
|
| 16 |
import PageHeader from "../../components/PageHeader/PageHeader";
|
|
@@ -25,8 +26,14 @@ import {
|
|
| 25 |
|
| 26 |
const LeaderboardPageContent = () => {
|
| 27 |
const [loading, setLoading] = useState(true);
|
| 28 |
-
const {
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
useEffect(() => {
|
| 32 |
fetch(API_URLS.leaderboards)
|
|
@@ -44,6 +51,15 @@ const LeaderboardPageContent = () => {
|
|
| 44 |
});
|
| 45 |
}, [setLeaderboards]);
|
| 46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
return (
|
| 48 |
<Box
|
| 49 |
sx={{
|
|
@@ -93,14 +109,63 @@ const LeaderboardPageContent = () => {
|
|
| 93 |
>
|
| 94 |
<LeaderboardFilters allSections={allSections} />
|
| 95 |
|
| 96 |
-
{
|
| 97 |
-
<Box
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
/>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
</Box>
|
| 103 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
</Box>
|
| 105 |
)}
|
| 106 |
</Box>
|
|
|
|
| 11 |
Typography,
|
| 12 |
} from "@mui/material";
|
| 13 |
import SearchIcon from "@mui/icons-material/Search";
|
| 14 |
+
import SearchOffIcon from "@mui/icons-material/SearchOff";
|
| 15 |
import Logo from "../../components/Logo/Logo";
|
| 16 |
import PageTitle from "../../components/PageTitle/PageTitle";
|
| 17 |
import PageHeader from "../../components/PageHeader/PageHeader";
|
|
|
|
| 26 |
|
| 27 |
const LeaderboardPageContent = () => {
|
| 28 |
const [loading, setLoading] = useState(true);
|
| 29 |
+
const {
|
| 30 |
+
setLeaderboards,
|
| 31 |
+
filterLeaderboards,
|
| 32 |
+
sections,
|
| 33 |
+
allSections,
|
| 34 |
+
searchQuery,
|
| 35 |
+
arenaOnly,
|
| 36 |
+
} = useLeaderboard();
|
| 37 |
|
| 38 |
useEffect(() => {
|
| 39 |
fetch(API_URLS.leaderboards)
|
|
|
|
| 51 |
});
|
| 52 |
}, [setLeaderboards]);
|
| 53 |
|
| 54 |
+
// Check if any leaderboards are found after filtering
|
| 55 |
+
const totalFilteredLeaderboards = sections.reduce(
|
| 56 |
+
(total, { data }) => total + filterLeaderboards(data).length,
|
| 57 |
+
0
|
| 58 |
+
);
|
| 59 |
+
|
| 60 |
+
const hasLeaderboards = totalFilteredLeaderboards > 0;
|
| 61 |
+
const isFiltering = searchQuery || arenaOnly;
|
| 62 |
+
|
| 63 |
return (
|
| 64 |
<Box
|
| 65 |
sx={{
|
|
|
|
| 109 |
>
|
| 110 |
<LeaderboardFilters allSections={allSections} />
|
| 111 |
|
| 112 |
+
{!hasLeaderboards && isFiltering && (
|
| 113 |
+
<Box
|
| 114 |
+
sx={{
|
| 115 |
+
display: "flex",
|
| 116 |
+
flexDirection: "column",
|
| 117 |
+
alignItems: "center",
|
| 118 |
+
gap: 2,
|
| 119 |
+
mt: 8,
|
| 120 |
+
py: 7,
|
| 121 |
+
}}
|
| 122 |
+
>
|
| 123 |
+
<SearchOffIcon
|
| 124 |
+
sx={{
|
| 125 |
+
fontSize: 64,
|
| 126 |
+
color: "text.secondary",
|
| 127 |
+
opacity: 0.5,
|
| 128 |
+
}}
|
| 129 |
/>
|
| 130 |
+
<Typography variant="h5" color="text.secondary" align="center">
|
| 131 |
+
{searchQuery ? (
|
| 132 |
+
<>
|
| 133 |
+
Oops! No leaderboard matches{" "}
|
| 134 |
+
<Box
|
| 135 |
+
component="span"
|
| 136 |
+
sx={{
|
| 137 |
+
bgcolor: "primary.main",
|
| 138 |
+
color: "primary.contrastText",
|
| 139 |
+
px: 1,
|
| 140 |
+
borderRadius: 1,
|
| 141 |
+
}}
|
| 142 |
+
>
|
| 143 |
+
{searchQuery}
|
| 144 |
+
</Box>
|
| 145 |
+
</>
|
| 146 |
+
) : (
|
| 147 |
+
"Oops! No leaderboard matches your criteria"
|
| 148 |
+
)}
|
| 149 |
+
</Typography>
|
| 150 |
+
<Typography variant="body1" color="text.secondary" align="center">
|
| 151 |
+
Try adjusting your search filters
|
| 152 |
+
</Typography>
|
| 153 |
</Box>
|
| 154 |
+
)}
|
| 155 |
+
|
| 156 |
+
{(hasLeaderboards || !isFiltering) &&
|
| 157 |
+
sections.map(({ id, title, data }) => {
|
| 158 |
+
const filteredLeaderboards = filterLeaderboards(data);
|
| 159 |
+
if (filteredLeaderboards.length === 0) return null;
|
| 160 |
+
return (
|
| 161 |
+
<Box key={id} id={id}>
|
| 162 |
+
<LeaderboardSection
|
| 163 |
+
title={title}
|
| 164 |
+
leaderboards={filteredLeaderboards}
|
| 165 |
+
/>
|
| 166 |
+
</Box>
|
| 167 |
+
);
|
| 168 |
+
})}
|
| 169 |
</Box>
|
| 170 |
)}
|
| 171 |
</Box>
|