From 819fe7064da9f06f594ed848ebc6ed55458bb5e1 Mon Sep 17 00:00:00 2001 From: Stanleyowskiki Date: Wed, 27 Mar 2024 09:21:46 +0100 Subject: [PATCH] Fixing links and moving about to appropriete place Orchestrate e2e tests both in dev and CI - add e2e test for registration page User settings (#31) Add user settings and user profile pages --------- Co-authored-by: Jordan Parviainen <92371238+jordus100@users.noreply.github.com> Add drawio graph of currently existing pages (#35) Update cosign tool in Docker action --- src/App.js | 2 +- src/App.scss | 3 +- src/index.js | 6 +- src/services/Api.js | 138 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 146 insertions(+), 3 deletions(-) diff --git a/src/App.js b/src/App.js index 9d78e0e..cfdd017 100644 --- a/src/App.js +++ b/src/App.js @@ -1,9 +1,9 @@ +import { useEffect, useState} from 'react'; import './App.scss' import User from "./User/User"; import {Link} from "react-router-dom"; import UserButtons from './User/UserButtons'; -function App() { return (
diff --git a/src/App.scss b/src/App.scss index fe08829..48e2eec 100644 --- a/src/App.scss +++ b/src/App.scss @@ -5,7 +5,6 @@ } .app { - h1:hover { cursor: default; } @@ -52,4 +51,6 @@ .login-btn { width: 100%; } + + height: 100vh; } \ No newline at end of file diff --git a/src/index.js b/src/index.js index c9e4144..8ad2c07 100644 --- a/src/index.js +++ b/src/index.js @@ -36,7 +36,11 @@ const tournaments = getListOfTournaments(); const router = createBrowserRouter([ { path: "/", - element: , + element: , + }, + { + path: "/player/:id", + element: , }, { path: "/player/:id", diff --git a/src/services/Api.js b/src/services/Api.js index 2557ee9..b02a7e8 100644 --- a/src/services/Api.js +++ b/src/services/Api.js @@ -157,6 +157,144 @@ function getUser(request){ } +function prepareParams(data, params) { + if (params === undefined || params.length === 0) { + return "" + } + for (var i = 0; i < params.length; i++) { + if (!data.hasOwnProperty(params[i])) { + throw Error("Invalid request, lack of parameter: " + params[i]) + } + } + + return "?" + params.map((param) => { + return "" + param + "=" + data[param] + }).join("&") +} + +function prepareBody(data, body) { + if (body === undefined || body.length === 0) { + return {} + } + + for (var i = 0; i < body.length; i++) { + if (!data.hasOwnProperty(body[i])) { + throw Error("Invalid request, lack of body parameter: " + body[i]) + } + } + + const dictionary = {}; + for (const key of body) { + if (data.hasOwnProperty(key)) { + dictionary[key] = data[key]; + } + } + + return dictionary +} + +function Request(data, endpoint, apifunc) { + const path = apifunc["path"]; + const method = apifunc["method"]; + const params = apifunc["params"]; + const body = apifunc["body"]; + + const reqParams = prepareParams(data, params); + const reqBody = prepareBody(data, body); + + console.log(reqParams) + const h = { + "accept": "*/*" + }; + + const url = c["urls"][endpoint]["path"] + path + reqParams; + return Api({ + method: method, + url: url, + data: reqBody, + headers: h + }) +} + +const achievements = c["urls"]["achievements"] +//const gametype = c["urls"]["gametype"] +//const player = c["urls"]["player"] +//const points = c["urls"]["points"] +const tournament = c["urls"]["tournament"] +//const userSettings = c["urls"]["userSettings"] + +function getAcivmentsForPlayer(request) { + return Request(request, "achievements", achievements["functions"]["GetachievementsForPlayer"]) +} + +function getTournaments(request) { + Request(request, "tournament", tournament["functions"]["GetAllTournaments"]) + .then((res) => { + return res.data + }).catch((err) => { + console.log(err) + }) +} + +function getPointsOfHistoryForPlayer(request) { + //return Request(request, "points", points["functions"]["GetPointsOfHistoryForPlayer"]) + + return { + "data": [ + { + "id": 1, + "logDate": "2024-02-06T19:21:17.85", + "rating": 12, + "playerId": 1 + }, + { + "id": 2, + "logDate": "2024-02-07T19:21:17.85", + "rating": 20, + "playerId": 1 + }, + { + "id": 3, + "logDate": "2024-02-08T19:21:17.85", + "rating": 30, + "playerId": 1 + }, + { + "id": 4, + "logDate": "2024-02-09T19:21:17.85", + "rating": 40, + "playerId": 1 + }, + { + "id": 5, + "logDate": "2024-02-10T19:21:17.85", + "rating": 50, + "playerId": 1 + }, + { + "id": 6, + "logDate": "2024-02-11T19:21:17.85", + "rating": 60, + "playerId": 1 + } + ] + } +} + +function getUser(request){ + //return Request(request, "userSettings", userSettings["functions"]["GetUser"]) + + return { + "id": request["playerId"], + "login": "RdmusR_97", + "rating": 1203, + "lastSeen": "2024-02-11T19:21:17.85", + "joined": "2024-02-06T19:21:17.85", + "photoURL": "https://img.freepik.com/free-vector/businessman-character-avatar-isolated_24877-60111.jpg?w=740&t=st=1709386522~exp=1709387122~hmac=612506df2e857afd82d8b64b5b44128ef42d1e046876d26074bb46b41abe1fb0" + } + +} + Api.processError = (err) => { throw Error(err.message) }