From a444c7efd3bce626d80de1a5daa048afa75aef4b Mon Sep 17 00:00:00 2001 From: julius Date: Sat, 2 Nov 2024 09:47:25 +0100 Subject: [PATCH] add table with suggested teams --- prefs_page/src/App.tsx | 13 ++++++++--- prefs_page/src/Table.tsx | 48 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 prefs_page/src/Table.tsx diff --git a/prefs_page/src/App.tsx b/prefs_page/src/App.tsx index fc262ea..7ca7b27 100644 --- a/prefs_page/src/App.tsx +++ b/prefs_page/src/App.tsx @@ -17,6 +17,7 @@ import { FormHelperText, Stack, } from "@mui/material"; +import TeamTables from "./Table"; function getStyles(name: string, players: readonly string[], theme: Theme) { return { @@ -29,7 +30,8 @@ function getStyles(name: string, players: readonly string[], theme: Theme) { async function submit( person: string, players: string[], - setResponseStatus: (value: number) => void + setResponseStatus: (value: number) => void, + setDialog: (value: boolean) => void ) { // console.log(JSON.stringify({ person: person, players: players })); const response = await fetch("https://0124816.xyz/team/submit/", { @@ -40,6 +42,7 @@ async function submit( body: JSON.stringify({ person: person, players: players }), }); setResponseStatus(response.status); + setDialog(true); } type SubmitButtonProps = { @@ -49,17 +52,20 @@ type SubmitButtonProps = { function SubmitButton(props: SubmitButtonProps) { const [responseStatus, setResponseStatus] = React.useState(0); + const [dialog, setDialog] = React.useState(false); return (
- + setDialog(false)} open={dialog}> thank you. please leave now.
@@ -194,6 +200,7 @@ function App() { {SubmitButton({ person, players })}

now: click submit.

+ {TeamTables()}

something not working? message me.

diff --git a/prefs_page/src/Table.tsx b/prefs_page/src/Table.tsx new file mode 100644 index 0000000..0b40054 --- /dev/null +++ b/prefs_page/src/Table.tsx @@ -0,0 +1,48 @@ +import * as React from "react"; +import Table from "@mui/material/Table"; +import TableBody from "@mui/material/TableBody"; +import TableCell from "@mui/material/TableCell"; +import TableContainer from "@mui/material/TableContainer"; +import TableHead from "@mui/material/TableHead"; +import TableRow from "@mui/material/TableRow"; +import Paper from "@mui/material/Paper"; +import data from "./table.json"; + +export default function TeamTables() { + return ( + <> + {Object.keys(data).map((teamname) => ( + <> +

{teamname as String}

+ + + + + player + wishes fulfilled + + + + {data[teamname].map((row) => ( + + {row[0]} + + {"♥️".repeat(row[1]) + "♡".repeat(row[2] - row[1])} + + + ))} + +
+
+ + ))} + + ); +}