Skip to content

Commit ccc07f8

Browse files
author
pcarapic15
committed
Add filtering for leaderboard tables
1 parent 7f06252 commit ccc07f8

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/components/sd-gym/SdGymContent.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import SdGymLeaderboard from "./SdGymLeaderboard";
77
import AboutSdGym from "./AboutSdGym";
88

99
export default function SdGymContent() {
10+
const [rawData, setRawData] = useState([]);
1011
const [data, setData] = useState([]);
1112
const [dateTags, setDateTags] = useState([]);
1213
const activeDateTag = dateTags.find((dt) => dt.active);
@@ -24,6 +25,7 @@ export default function SdGymContent() {
2425
const firstSheet = workbook.SheetNames[0];
2526
const worksheet = workbook.Sheets[firstSheet];
2627
const rawData = XLSX.utils.sheet_to_json(worksheet);
28+
setRawData(rawData);
2729

2830
// Date tags for the tables
2931
const rawDateTags = extractSortedDates(rawData);
@@ -41,6 +43,13 @@ export default function SdGymContent() {
4143
fetchExcel();
4244
}, []);
4345

46+
useEffect(() => {
47+
if (activeDateTag && rawData.length) {
48+
const tableData = buildTableData(rawData, activeDateTag.date);
49+
setData(tableData);
50+
}
51+
}, [activeDateTag, rawData]);
52+
4453
const extractSortedDates = (data) => {
4554
const datesSet = new Set();
4655

0 commit comments

Comments
 (0)