From 2a3abb9bf3b1a00658ac4519ab3fa3e5fb229c4e Mon Sep 17 00:00:00 2001 From: Felix Albrigtsen Date: Wed, 30 Mar 2022 00:11:11 +0200 Subject: [PATCH] Code Refactoring, design iteration --- src/client/src/FrontPage.js | 6 +- src/client/src/TournamentAnnouncement.js | 2 +- src/client/src/TournamentCreator.js | 2 +- src/client/src/TournamentManager.js | 93 +++++++++++-------- src/client/src/TournamentMatches.js | 2 +- src/client/src/TournamentOverview.js | 8 +- src/client/src/TournamentTeams.js | 6 +- .../src/components/{appbar.js => Appbar.js} | 14 +-- src/client/src/components/TournamentBar.js | 23 +++++ src/client/src/components/homeimage.js | 11 --- src/client/src/components/tournamentbar.js | 51 ---------- 11 files changed, 99 insertions(+), 119 deletions(-) rename src/client/src/components/{appbar.js => Appbar.js} (73%) create mode 100644 src/client/src/components/TournamentBar.js delete mode 100644 src/client/src/components/homeimage.js delete mode 100644 src/client/src/components/tournamentbar.js diff --git a/src/client/src/FrontPage.js b/src/client/src/FrontPage.js index af9afaf..ea75da8 100644 --- a/src/client/src/FrontPage.js +++ b/src/client/src/FrontPage.js @@ -6,7 +6,7 @@ import TournamentManager from "./TournamentManager.js"; import TournamentAnnouncement from "./TournamentAnnouncement"; import TournamentMatches from "./TournamentMatches"; import TournamentTeams from "./TournamentTeams"; -import AppBar from './components/appbar'; +import AppBar from './components/Appbar'; import { Button, Container, Typography, Box, Stack, Card, CardContent, CardMedia, Paper, Grid } from "@mui/material"; import AddCircleIcon from '@mui/icons-material/AddCircle'; @@ -45,12 +45,12 @@ function TournamentListItem(props) { - + - + + @@ -131,40 +152,32 @@ function ManageTournament(props) { ); } -function AnnounceButton(props) { - return ( - - - - ); -} - function showError(error) { alert("Something went wrong. \n" + error); console.error(error); } -function InviteButton(props) { - function event() { - copy(); - alertSuccess(); +function ClipboardButton(props) { + const [open, setOpen] = React.useState(false); + function copyString() { + navigator.clipboard.writeText(props.clipboardContent || ""); + setOpen(true); } - const copy = () => { - navigator.clipboard.writeText("discord.gg/asura"); + const handleClose = (event, reason) => { + if (reason === 'clickaway') { return } + setOpen(false); }; - const alertSuccess = () => - alert({ message: "Copied to clipboard.", type: "success" }); + const closeAction = <> + + + + + return ( - + <> + + + ); } @@ -177,8 +190,14 @@ export default function TournamentManager(props) { {/* */} - - {/* */} + + + + + + ); diff --git a/src/client/src/TournamentMatches.js b/src/client/src/TournamentMatches.js index 9c4ca52..43afb8a 100644 --- a/src/client/src/TournamentMatches.js +++ b/src/client/src/TournamentMatches.js @@ -1,6 +1,6 @@ import * as React from "react"; import { BrowserRouter as Router, Link, Route, Routes } from "react-router-dom"; -import Appbar from './components/appbar'; +import Appbar from './components/Appbar'; function MatchHistory() { diff --git a/src/client/src/TournamentOverview.js b/src/client/src/TournamentOverview.js index 755f57b..068d728 100644 --- a/src/client/src/TournamentOverview.js +++ b/src/client/src/TournamentOverview.js @@ -1,7 +1,7 @@ import * as React from "react"; import { Link } from "react-router-dom"; -import Appbar from './components/appbar'; -import TournamentBar from "./components/tournamentbar"; +import Appbar from './components/Appbar'; +import TournamentBar from "./components/TournamentBar"; import { useParams } from 'react-router-dom' import { Button, Paper, Stack } from "@mui/material"; import "./components/tournamentBracket.css"; @@ -186,8 +186,8 @@ export default function TournamentOverview(props) { return ( <> - - + + ); diff --git a/src/client/src/TournamentTeams.js b/src/client/src/TournamentTeams.js index 6cddc6b..d576233 100644 --- a/src/client/src/TournamentTeams.js +++ b/src/client/src/TournamentTeams.js @@ -1,7 +1,7 @@ import * as React from "react"; import { BrowserRouter as Router, Link, Route, Routes, useParams } from "react-router-dom"; -import Appbar from "./components/appbar"; -import TournamentBar from "./components/tournamentbar"; +import Appbar from "./components/Appbar"; +import TournamentBar from "./components/TournamentBar"; import { Button, TextField, Stack, MenuItem, Box, InputLabel, Select, Container, TableContainer, Table, TableBody, TableHead, TableCell, TableRow, Paper, Typography} from "@mui/material"; import AddCircleIcon from '@mui/icons-material/AddCircle'; import DeleteIcon from '@mui/icons-material/Delete'; @@ -205,7 +205,7 @@ export default function TournamentTeams(props) { return ( <> - +
diff --git a/src/client/src/components/appbar.js b/src/client/src/components/Appbar.js similarity index 73% rename from src/client/src/components/appbar.js rename to src/client/src/components/Appbar.js index 0d87884..a7c725c 100644 --- a/src/client/src/components/appbar.js +++ b/src/client/src/components/Appbar.js @@ -2,7 +2,7 @@ import * as React from "react"; import { BrowserRouter as Router, Link, Route, Routes, History } from "react-router-dom"; import { AppBar, Typography, Toolbar, CssBaseline, Box, Button, IconButton, Grid } from "@mui/material" import MenuIcon from '@mui/icons-material/Menu'; -import HomeImage from "./homeimage"; +import logo from "./../Asura2222.png"; export default function Appbar(props) { return ( @@ -13,7 +13,10 @@ export default function Appbar(props) { - + + + Tournament logo + {/* Asura Tournaments @@ -24,13 +27,10 @@ export default function Appbar(props) {

{props.pageTitle || ""}

- + {/* - + */} - - {/* */} - {/* */}
diff --git a/src/client/src/components/TournamentBar.js b/src/client/src/components/TournamentBar.js new file mode 100644 index 0000000..153eb2c --- /dev/null +++ b/src/client/src/components/TournamentBar.js @@ -0,0 +1,23 @@ +import * as React from "react"; +import { useParams } from "react-router-dom"; +import { BrowserRouter as Router, Link, Route, Routes, History } from "react-router-dom"; +import { Stack, Paper, Typography, Box, Button, Grid } from "@mui/material" + +function ButtonLink(props) { + return ( + + + + ); +} + +export default function TournamentBar(props) { + const { tournamentId } = useParams(); + return ( + + + + + + ) +} \ No newline at end of file diff --git a/src/client/src/components/homeimage.js b/src/client/src/components/homeimage.js deleted file mode 100644 index aa9d35b..0000000 --- a/src/client/src/components/homeimage.js +++ /dev/null @@ -1,11 +0,0 @@ -import * as React from "react"; -import { BrowserRouter as Router, Link, Route, Routes } from "react-router-dom"; -import logo from "./../Asura2222.png"; - -export default function HomeImage() { - return ( - - Tournament logo - - ); -} diff --git a/src/client/src/components/tournamentbar.js b/src/client/src/components/tournamentbar.js deleted file mode 100644 index 312eb2d..0000000 --- a/src/client/src/components/tournamentbar.js +++ /dev/null @@ -1,51 +0,0 @@ -import * as React from "react"; -import { useParams } from "react-router-dom"; -import { BrowserRouter as Router, Link, Route, Routes, History } from "react-router-dom"; -import { Stack, Paper, Typography, Box, Button, Grid } from "@mui/material" - -export default function TournamentBar(props) { - const { tournamentId } = useParams() - if (props.pageTitle == "Edit Tournament") { - return( - - - - - - - - - - - - ) - } else if (props.pageTitle == "Tournament Matches") { - return( - - - - - - - - - - - - ) - } else if (props.pageTitle == "Edit Teams") { - return( - - - - - - - - - - - - ) - } -} \ No newline at end of file