diff --git a/src/client/.env b/src/client/.env index 02a4337..b046e98 100644 --- a/src/client/.env +++ b/src/client/.env @@ -1,2 +1,3 @@ -REACT_APP_API_URL=https://asura.feal.no/api +REACT_APP_API_URL=http://10.24.1.22:3001/api +REACT_APP_LOGIN_URL=http://localhost:3001/auth/google BROWSER=none diff --git a/src/client/public/btn_google_signing_dark.png b/src/client/public/btn_google_signing_dark.png new file mode 100644 index 0000000..f27bb24 Binary files /dev/null and b/src/client/public/btn_google_signing_dark.png differ diff --git a/src/client/src/AdminsOverview.js b/src/client/src/AdminsOverview.js index 5484b19..f04db42 100644 --- a/src/client/src/AdminsOverview.js +++ b/src/client/src/AdminsOverview.js @@ -1,10 +1,12 @@ import * as React from "react"; -import { BrowserRouter as Router, Link, Route, Routes } from "react-router-dom"; -import AppBar from "./components/AsuraBar"; +import { BrowserRouter as Router, Link, Route, Routes, useParams } from "react-router-dom"; +import Appbar from "./components/AsuraBar"; import ErrorSnackbar from "./components/ErrorSnackbar"; -import {Button, Textfield, Stack, InputLabel, Paper, Typography} from '@mui/material'; -import DeleteIcon from '@mui/icons/Delete'; +import {Button, Box, TextField, Stack, InputLabel, Paper, TableContainer, Table, TableBody, TableHead, TableCell, TableRow, Typography} from '@mui/material'; +import AddCircleIcon from '@mui/icons-material/AddCircle'; +import DeleteIcon from '@mui/icons-material/Delete'; +import EditIcon from '@mui/icons-material/Edit'; function showError(error) { alert("Something went wrong. \n" + error); @@ -14,14 +16,14 @@ function showError(error) { function AdminCreator(props){ function postCreate(){ let adminEmail = document.getElementById("adminEmailInput").value; - if (!adminName) { + if (!adminEmail) { showError("Admin email is required"); return; } let formData = new FormData(); - formData.append("name", teamName) + formData.append("email", adminEmail) let body = new URLSearchParams(formData) fetch(process.env.REACT_APP_API_URL + `/admins/create`, { @@ -58,5 +60,75 @@ function AdminCreator(props){ function AdminList(props){ const deleteAdmin = adminId => { - fetch(process.env.REACT_APP_API_URL) + fetch(process.env.REACT_APP_API_URL + `/admins/${adminId}`, {method: "DELETE"}) + .then(res => res.json()) + .then(data => { + if(data.status !== "OK"){ + showError(data.data); + return; + } + props.setAdmins(props.admins.filter(admin => admin.id !== adminId)); + }) + .catch(error => showError(error)); + } + + return( + +
+ {/* TODO: scroll denne menyen, eventuelt søkefelt */} + + + + Admin + Actions + + + + {props.admins.map((admin) => ( + + + {admin.name} + + {/* {team.members} */} + + {/* */} + + + + ))} + +
+
+
+ ) +} + +export default function Admins(props) { + const [admins, setAdmins] = React.useState([]); + const { adminId } = useParams(); + + function getAdmins() { + fetch(process.env.REACT_APP_API_URL + `/admins/getAdmins`) + .then((res) => res.json()) + .then((data) =>{ + if(data.status !== "OK") { + showError(data.data); + } + setAdmins(data.data); + }) + .catch((err) => showError(err)); + } + React.useEffect(() => { + getAdmins() + }, []); + + return ( + <> + +
+ + +
+ + ); } \ No newline at end of file diff --git a/src/client/src/FrontPage.js b/src/client/src/FrontPage.js index 25bbe9e..99687b5 100644 --- a/src/client/src/FrontPage.js +++ b/src/client/src/FrontPage.js @@ -5,6 +5,7 @@ import TournamentOverview from "./TournamentOverview.js"; import TournamentManager from "./TournamentManager.js"; import TournamentHistory from "./TournamentHistory"; import TournamentTeams from "./TournamentTeams"; +import LoginPage from "./LoginPage"; import AppBar from './components/AsuraBar'; import { Button, Container, Typography, Box, Stack, Card, CardContent, CardMedia, Paper, Grid, Icon } from "@mui/material"; import AddCircleIcon from '@mui/icons-material/AddCircle'; @@ -162,6 +163,7 @@ export default function App() { } /> } /> } /> + } /> diff --git a/src/client/src/LoginPage.js b/src/client/src/LoginPage.js index 09205fe..f723b63 100644 --- a/src/client/src/LoginPage.js +++ b/src/client/src/LoginPage.js @@ -6,3 +6,14 @@ import ErrorSnackbar from "./components/ErrorSnackbar"; import {Button, Textfield, Stack, InputLabel, Paper, Typography} from '@mui/material'; +export default function LoginPage() { + return ( + <> + +

Sign in with google

+ + Sign in with google + + + ); +} \ No newline at end of file diff --git a/src/client/src/TournamentMatches.js b/src/client/src/TournamentMatches.js index 43afb8a..44772c8 100644 --- a/src/client/src/TournamentMatches.js +++ b/src/client/src/TournamentMatches.js @@ -5,7 +5,7 @@ import Appbar from './components/Appbar'; function MatchHistory() { return( - `Hei` + `Hei på deg din gamle sei` ); }