diff --git a/src/client/package-lock.json b/src/client/package-lock.json index bf11bdc..dd036ab 100644 --- a/src/client/package-lock.json +++ b/src/client/package-lock.json @@ -4869,7 +4869,6 @@ "dependencies": { "anymatch": "~3.1.2", "braces": "~3.0.2", - "fsevents": "~2.3.2", "glob-parent": "~5.1.2", "is-binary-path": "~2.1.0", "is-glob": "~4.0.1", @@ -6117,8 +6116,7 @@ "esprima": "^4.0.1", "estraverse": "^5.2.0", "esutils": "^2.0.2", - "optionator": "^0.8.1", - "source-map": "~0.6.1" + "optionator": "^0.8.1" }, "bin": { "escodegen": "bin/escodegen.js", @@ -8726,7 +8724,6 @@ "@types/node": "*", "anymatch": "^3.0.3", "fb-watchman": "^2.0.0", - "fsevents": "^2.3.2", "graceful-fs": "^4.2.9", "jest-regex-util": "^27.5.1", "jest-serializer": "^27.5.1", @@ -10032,14 +10029,9 @@ "integrity": "sha512-EoQp/Et7OSOVu0aJknJOtlXZsnr8XE8KwuzTHOLeVSEx8pVWUICc8Q0VYRHgzyjX78nMEyC/oztWFbgyhtNfDA==", "dependencies": { "copy-anything": "^2.0.1", - "errno": "^0.1.1", "graceful-fs": "^4.1.2", - "image-size": "~0.5.0", - "make-dir": "^2.1.0", "mime": "^1.4.1", - "needle": "^2.5.2", "parse-node-version": "^1.0.1", - "source-map": "~0.6.0", "tslib": "^2.3.0" }, "bin": { @@ -12415,7 +12407,6 @@ "eslint-webpack-plugin": "^3.1.1", "file-loader": "^6.2.0", "fs-extra": "^10.0.0", - "fsevents": "^2.3.2", "html-webpack-plugin": "^5.5.0", "identity-obj-proxy": "^3.0.0", "jest": "^27.4.3", @@ -12835,9 +12826,6 @@ "version": "2.70.1", "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.70.1.tgz", "integrity": "sha512-CRYsI5EuzLbXdxC6RnYhOuRdtz4bhejPMSWjsFLfVM/7w/85n2szZv6yExqUXsBdz5KT8eoubeyDUDjhLHEslA==", - "dependencies": { - "fsevents": "~2.3.2" - }, "bin": { "rollup": "dist/bin/rollup" }, diff --git a/src/client/src/FrontPage.js b/src/client/src/FrontPage.js index 8e492f0..405b76c 100644 --- a/src/client/src/FrontPage.js +++ b/src/client/src/FrontPage.js @@ -114,7 +114,7 @@ function TournamentListItem(props) { Particpants: {props.tournament.teamCount} / {props.tournament.teamLimit} - Prize: {props.tournament.prize} + Prize: {props.tournament.prize} @@ -205,36 +205,36 @@ let showError = (message) => {}; export default function App() { const [user, setUser] = React.useState({}); - let fetchUser = () => { - fetch(process.env.REACT_APP_API_URL + `/users/getSavedUser`) - .then(res => res.json()) - .then(data => { - if (data.status !== "OK") { - setUser({ isManager: false, isLoggedIn: false }); - console.log(data.data); // "No user logged in" - return; - } - let u = data.data; - u.isLoggedIn = true; - console.log("User is logged in") - setUser(u); - }) - .catch((err) => { - showError(err.message); - setUser({ isManager: false, isLoggedIn: false }); - }); - } - // // Debug mode, allow all: // let fetchUser = () => { - // setUser({ - // name: "TEST USERTEST", - // isManager: true, - // isLoggedIn: true, - // email: "testesen@gmail.com", - // asuraId: "123456789", - // googleId: "234" - // }); + // fetch(process.env.REACT_APP_API_URL + `/users/getSavedUser`) + // .then(res => res.json()) + // .then(data => { + // if (data.status !== "OK") { + // setUser({ isManager: false, isLoggedIn: false }); + // console.log(data.data); // "No user logged in" + // return; + // } + // let u = data.data; + // u.isLoggedIn = true; + // console.log("User is logged in") + // setUser(u); + // }) + // .catch((err) => { + // showError(err.message); + // setUser({ isManager: false, isLoggedIn: false }); + // }); // } + // Debug mode, allow all: + let fetchUser = () => { + setUser({ + name: "TEST USERTEST", + isManager: true, + isLoggedIn: true, + email: "testesen@gmail.com", + asuraId: "123456789", + googleId: "234" + }); + } React.useEffect(() => { fetchUser(); diff --git a/src/client/src/TournamentHistory.js b/src/client/src/TournamentHistory.js index 9899ebb..9a24a86 100644 --- a/src/client/src/TournamentHistory.js +++ b/src/client/src/TournamentHistory.js @@ -56,7 +56,7 @@ function shorten(description, maxLength) { Participants: {props.tournament.teamCount} / {props.tournament.teamLimit} - Prize: {props.tournament.prize} + Prize: {props.tournament.prize} @@ -135,13 +135,13 @@ function shorten(description, maxLength) { } } - return <> - + return + {tournamentList && tournamentList.map((tournamentObject) => )} - ; + ; } export default function TournamentHistory(props) { @@ -149,12 +149,7 @@ export default function TournamentHistory(props) { return ( <> - - - Past Tournaments - - - + ); } \ No newline at end of file diff --git a/src/client/src/TournamentOverview.js b/src/client/src/TournamentOverview.js index a507868..d2abadc 100644 --- a/src/client/src/TournamentOverview.js +++ b/src/client/src/TournamentOverview.js @@ -91,7 +91,7 @@ function Match(props){ {team1Name} { props.match.winnerId && (props.match.team1Id === props.match.winnerId) && - + } { props.match.team1Id !== null && !props.tournament.hasEnded && props.match.tier !== Math.log2(props.tournament.teamLimit) - 1 && props.match.winnerId === null && props.user.isLoggedIn && @@ -111,7 +111,7 @@ function Match(props){ {team2Name} { props.match.winnerId && (props.match.team2Id === props.match.winnerId) && - + } { props.match.team2Id !== null && !props.tournament.hasEnded && props.match.tier !== Math.log2(props.tournament.teamLimit) - 1 && props.match.winnerId === null && props.user.isLoggedIn && @@ -162,7 +162,7 @@ function WinnerDisplay(props) { {props.team.name} - + ) } diff --git a/src/client/src/TournamentTeams.js b/src/client/src/TournamentTeams.js index 9ce878f..d73b126 100644 --- a/src/client/src/TournamentTeams.js +++ b/src/client/src/TournamentTeams.js @@ -71,17 +71,49 @@ function TeamList(props) { .catch(error => showError(error)); } + function search() { + let searchBase = [] + let searchResult = [] + let originalList = props.originalList + originalList.map((tournament) => searchBase.push(tournament.name)) + let input = document.getElementById("searchInput") + let inputUpperCase = input.value.toUpperCase() + for (let i = 0; i < searchBase.length; i++) { + let tournamentName = searchBase[i].toUpperCase() + if(tournamentName.indexOf(inputUpperCase) >= 0) { + searchResult.push(tournamentName) + } + } + + let searchedList = [] + for (let i = 0; i < originalList.length; i++) { + let name = originalList[i].name + for (let j = 0; j < searchResult.length; j++) { + if (name.toUpperCase() == searchResult[j]) { + searchedList.push(originalList[i]) + } + } + } + + if (input.value == "") { + props.setTeams(originalList) + } else { + props.setTeams(searchedList) + } + } + return (
-

Teams:

- {/* TODO: scroll denne menyen, eventuelt søkefelt */} + {/* Make a horizontal stack */} + + - Team Name +

Team Name

{/* Team Members */} - Actions +

Actions

@@ -91,7 +123,6 @@ function TeamList(props) { {team.name} - {/* {team.members} */} @@ -184,6 +215,7 @@ let showError = (message) => {}; export default function TournamentTeams(props) { const [teams, setTeams] = React.useState([]); const [selectedTeamId, setSelectedTeamId] = React.useState(-1); + const [originalList, setOriginalList] = React.useState([]) const { tournamentId } = useParams(); function getTeams() { @@ -194,6 +226,7 @@ export default function TournamentTeams(props) { showError(data.data); } setTeams(data.data); + setOriginalList(data.data) //setselectedTeamId(teams[0].id); }) .catch((err) => showError(err)); @@ -218,7 +251,7 @@ export default function TournamentTeams(props) {
- +
diff --git a/src/client/src/components/AsuraBar.js b/src/client/src/components/AsuraBar.js index 7de5361..2fc2bb0 100644 --- a/src/client/src/components/AsuraBar.js +++ b/src/client/src/components/AsuraBar.js @@ -25,11 +25,11 @@ function LoggedInMenu(props) { return ( <> + - { props.user.isManager && @@ -71,7 +71,7 @@ export default function Appbar(props) { { props.pageTitle !== "Asura Tournaments" && - + Home diff --git a/src/client/src/components/TournamentBar.js b/src/client/src/components/TournamentBar.js index abb9452..516513d 100644 --- a/src/client/src/components/TournamentBar.js +++ b/src/client/src/components/TournamentBar.js @@ -48,13 +48,13 @@ function ButtonLink(props) { export default function TournamentBar(props) { const { tournamentId } = useParams(); return ( - + - + diff --git a/src/server/index.js b/src/server/index.js index ac16cd9..7011bcc 100644 --- a/src/server/index.js +++ b/src/server/index.js @@ -43,14 +43,16 @@ app.use(require('express-log-url')); // #region frontend // Serve static files from the React app -app.use('/', express.static(path.join(__dirname, 'clientbuild'))); -app.use('/login', express.static(path.join(__dirname, 'clientbuild', 'index.html'))); -app.use('/history', express.static(path.join(__dirname, 'clientbuild', 'index.html'))); -app.use('/admins', express.static(path.join(__dirname, 'clientbuild', 'index.html'))); -app.use('/profile', express.static(path.join(__dirname, 'clientbuild', 'index.html'))); -app.use('/tournament/*', express.static(path.join(__dirname, 'clientbuild', 'index.html'))); -app.use('/static', express.static(path.join(__dirname, 'clientbuild/static'))); -app.use('/static/*', express.static(path.join(__dirname, 'clientbuild/static'))); +const indexhtmlPath = path.join(process.env.CLIENT_BUILD_DIR, "index.html"); +const staticPath = path.join(process.env.CLIENT_BUILD_DIR, "static"); +app.use('/', express.static(process.env.CLIENT_BUILD_DIR)); +app.use('/login', express.static(indexhtmlPath)); +app.use('/history', express.static(indexhtmlPath)); +app.use('/admins', express.static(indexhtmlPath)); +app.use('/profile', express.static(indexhtmlPath)); +app.use('/tournament/*', express.static(indexhtmlPath)); +app.use('/static', express.static(staticPath)); +app.use('/static/*', express.static(staticPath)); // #endregion // #region PASSPORT / OAUTH