Skip to content

Commit

Permalink
Fixing links and moving about to appropriete place
Browse files Browse the repository at this point in the history
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 <[email protected]>

Add drawio graph of currently existing pages (#35)

Update cosign tool in Docker action
  • Loading branch information
StanislawMalinski committed May 10, 2024
1 parent e1e3a76 commit 819fe70
Show file tree
Hide file tree
Showing 4 changed files with 146 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/App.js
Original file line number Diff line number Diff line change
@@ -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 (
<div className="app">
<UserButtons/>
Expand Down
3 changes: 2 additions & 1 deletion src/App.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
}

.app {

h1:hover {
cursor: default;
}
Expand Down Expand Up @@ -52,4 +51,6 @@
.login-btn {
width: 100%;
}

height: 100vh;
}
6 changes: 5 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ const tournaments = getListOfTournaments();
const router = createBrowserRouter([
{
path: "/",
element: <App/>,
element: <App mode={"home"}/>,
},
{
path: "/player/:id",
element: <ProfileView/>,
},
{
path: "/player/:id",
Expand Down
138 changes: 138 additions & 0 deletions src/services/Api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 819fe70

Please sign in to comment.