From 1228ad4c8e40036ef4afe0d3aa6a3733197aafea Mon Sep 17 00:00:00 2001 From: Kyle Flynn Date: Sun, 29 Sep 2024 12:57:31 +0300 Subject: [PATCH] gregrepport --- .../src/seasons/fgc-2024/rankings-report.tsx | 85 ++++++++++++------- 1 file changed, 54 insertions(+), 31 deletions(-) diff --git a/front-end/src/seasons/fgc-2024/rankings-report.tsx b/front-end/src/seasons/fgc-2024/rankings-report.tsx index c492166..43b2bab 100644 --- a/front-end/src/seasons/fgc-2024/rankings-report.tsx +++ b/front-end/src/seasons/fgc-2024/rankings-report.tsx @@ -5,47 +5,70 @@ import { TableHead, TableRow, TableCell, - TableBody + TableBody, + Button } from '@mui/material'; import { FeedingTheFuture } from '@toa-lib/models'; import { RankingsReportProps } from 'src/seasons'; import { Report } from 'src/apps/reports/components/report-container'; import { useTeamIdentifiers } from 'src/hooks/use-team-identifier'; +import { mkConfig, generateCsv, download } from 'export-to-csv'; export const RankingsReport: FC< RankingsReportProps > = ({ rankings }) => { const identifiers = useTeamIdentifiers(); + const downloadCSV = () => { + const csvConfig = mkConfig({ useKeysAsHeaders: true }); + const csv = generateCsv(csvConfig)( + rankings.map((r) => ({ + rank: r.rank, + team: identifiers[r.teamKey], + played: r.played, + rankingScore: r.rankingScore ?? 0, + highestScore: r.highestScore ?? 0, + foodSecuredPoints: r.foodSecuredPoints ?? 0 + })) + ); + download(csvConfig)(csv); + }; return ( - - - - - - Rank - Team - Played - Ranking Score - Highest Score - Food Secured Points - - - - {rankings - .sort((a, b) => a.rank - b.rank) - .map((r) => ( - - {r.rank} - {identifiers[r.teamKey]} - {r.played} - {r.rankingScore ?? 0} - {r.highestScore ?? 0} - {r.foodSecuredPoints ?? 0} - - ))} - -
-
-
+ <> +
+ +
+ + + + + + Rank + Team + Played + Ranking Score + Highest Score + Food Secured Points + + + + {rankings + .sort((a, b) => a.rank - b.rank) + .map((r) => ( + + {r.rank} + {identifiers[r.teamKey]} + {r.played} + {r.rankingScore ?? 0} + {r.highestScore ?? 0} + {r.foodSecuredPoints ?? 0} + + ))} + +
+
+
+ ); };