diff --git a/cryptide_project/DB/socialgraph.db b/cryptide_project/DB/socialgraph.db
index a2e8950..7c46717 100644
Binary files a/cryptide_project/DB/socialgraph.db and b/cryptide_project/DB/socialgraph.db differ
diff --git a/cryptide_project/package-lock.json b/cryptide_project/package-lock.json
index f52d070..3e570f0 100644
--- a/cryptide_project/package-lock.json
+++ b/cryptide_project/package-lock.json
@@ -26,6 +26,7 @@
"jspdf": "^2.5.1",
"jszip": "^3.10.1",
"lodash": "^4.17.21",
+ "nuka-carousel": "^7.0.0",
"react": "^18.2.0",
"react-bootstrap": "^2.9.1",
"react-country-flag": "^3.1.0",
@@ -14203,6 +14204,18 @@
"url": "https://github.com/fb55/nth-check?sponsor=1"
}
},
+ "node_modules/nuka-carousel": {
+ "version": "7.0.0",
+ "resolved": "https://registry.npmjs.org/nuka-carousel/-/nuka-carousel-7.0.0.tgz",
+ "integrity": "sha512-KE0WV1MuE4Gq6ynL8P3qJH2rGq/DkJ0ej+ezo0IuZp4oklV8WNqu6P6O1utJqihHLGoEuFppq5wlHSHfhdCHXA==",
+ "engines": {
+ "node": ">=12.0.0"
+ },
+ "peerDependencies": {
+ "react": ">=18.0.0",
+ "react-dom": ">=18.0.0"
+ }
+ },
"node_modules/nwsapi": {
"version": "2.2.7",
"resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.7.tgz",
diff --git a/cryptide_project/package.json b/cryptide_project/package.json
index 3e51147..4bf2b23 100644
--- a/cryptide_project/package.json
+++ b/cryptide_project/package.json
@@ -21,6 +21,7 @@
"jspdf": "^2.5.1",
"jszip": "^3.10.1",
"lodash": "^4.17.21",
+ "nuka-carousel": "^7.0.0",
"react": "^18.2.0",
"react-bootstrap": "^2.9.1",
"react-country-flag": "^3.1.0",
diff --git a/cryptide_project/server/api/controllers/ScoreboardController.js b/cryptide_project/server/api/controllers/ScoreboardController.js
new file mode 100644
index 0000000..9d58d27
--- /dev/null
+++ b/cryptide_project/server/api/controllers/ScoreboardController.js
@@ -0,0 +1,209 @@
+const path = require('path');
+const DatabaseService = require(path.resolve(__dirname, '../services/DatabaseService'));
+
+const ENIGME_FACILE = "enigme_facile";
+const ENIGME_MOYEN = "enigme_moyenne";
+const ENIGME_DIFFICILE = "enigme_difficile";
+
+class SessionController {
+ // ---------------------------------------------------
+ // ----------------- GET DAILY STATS -----------------
+ // ---------------------------------------------------
+
+ static async getDailyMastermind(req, res){
+ const db = new DatabaseService();
+
+ try{
+ await db.connect();
+
+ const dailyMastermindStats = await db.getDailyMastermindStats();
+
+ res.status(200).json({ tab : dailyMastermindStats });
+ }
+ catch(error){
+ console.error(error);
+ res.status(500).json({ error: 'Erreur lors de la récupération des stats dailyMastermind.' });
+ }
+ finally{
+ await db.disconnect();
+ }
+ }
+
+ static async getDailyEasyEnigma(req, res){
+ const db = new DatabaseService();
+
+ try{
+ await db.connect();
+
+ const dailyEasyEnigmaStats = await db.getDailyEnigmaStats(ENIGME_FACILE);
+
+ res.status(200).json({ tab : dailyEasyEnigmaStats });
+ }
+ catch(error){
+ console.error(error);
+ res.status(500).json({ error: 'Erreur lors de la récupération des stats dailyEasyEnigma.' });
+ }
+ finally{
+ await db.disconnect();
+ }
+ }
+
+ static async getDailyMediumEnigma(req, res){
+ const db = new DatabaseService();
+
+ try{
+ await db.connect();
+
+ const dailyMediumEnigmaStats = await db.getDailyEnigmaStats(ENIGME_MOYEN);
+
+ res.status(200).json({ tab : dailyMediumEnigmaStats });
+ }
+ catch(error){
+ console.error(error);
+ res.status(500).json({ error: 'Erreur lors de la récupération des stats dailyMediumEnigma.' });
+ }
+ finally{
+ await db.disconnect();
+ }
+ }
+
+ static async getDailyHardEnigma(req, res){
+ const db = new DatabaseService();
+
+ try{
+ await db.connect();
+
+ const dailyHardEnigmaStats = await db.getDailyEnigmaStats(ENIGME_DIFFICILE);
+
+ res.status(200).json({ tab : dailyHardEnigmaStats });
+ }
+ catch(error){
+ console.error(error);
+ res.status(500).json({ error: 'Erreur lors de la récupération des stats dailyHardEnigma.' });
+ }
+ finally{
+ await db.disconnect();
+ }
+ }
+
+ static async getDailyOnline(req, res){
+ const db = new DatabaseService();
+
+ try{
+ await db.connect();
+
+ const dailyOnlineStats = await db.getDailyOnlineStats();
+
+ res.status(200).json({ tab : dailyOnlineStats });
+ }
+ catch(error){
+ console.error(error);
+ res.status(500).json({ error: 'Erreur lors de la récupération des stats dailyOnline' });
+ }
+ finally{
+ await db.disconnect();
+ }
+ }
+
+ // ---------------------------------------------------
+ // ---------------- GET WEEKLY STATS -----------------
+ // ---------------------------------------------------
+
+ static async getWeeklyMastermind(req, res){
+ const db = new DatabaseService();
+
+ try{
+ await db.connect();
+
+ const weeklyMastermindStats = await db.getWeeklyMastermindStats();
+
+ res.status(200).json({ tab : weeklyMastermindStats });
+ }
+ catch(error){
+ console.error(error);
+ res.status(500).json({ error: 'Erreur lors de la récupération des stats weeklyMastermind.' });
+ }
+ finally{
+ await db.disconnect();
+ }
+ }
+
+ static async getWeeklyEasyEnigma(req, res){
+ const db = new DatabaseService();
+
+ try{
+ await db.connect();
+
+ const weeklyEasyEnigmaStats = await db.getWeeklyEnigmaStats(ENIGME_FACILE);
+
+ res.status(200).json({ tab : weeklyEasyEnigmaStats });
+ }
+ catch(error){
+ console.error(error);
+ res.status(500).json({ error: 'Erreur lors de la récupération des stats weeklyEasyEnigma.' });
+ }
+ finally{
+ await db.disconnect();
+ }
+ }
+
+ static async getWeeklyMediumEnigma(req, res){
+ const db = new DatabaseService();
+
+ try{
+ await db.connect();
+
+ const weeklyMediumEnigmaStats = await db.getWeeklyEnigmaStats(ENIGME_MOYEN);
+
+ res.status(200).json({ tab : weeklyMediumEnigmaStats });
+ }
+ catch(error){
+ console.error(error);
+ res.status(500).json({ error: 'Erreur lors de la récupération des stats weeklyMediumEnigma.' });
+ }
+ finally{
+ await db.disconnect();
+ }
+ }
+
+ static async getWeeklyHardEnigma(req, res){
+ const db = new DatabaseService();
+
+ try{
+ await db.connect();
+
+ const weeklyHardEnigmaStats = await db.getWeeklyEnigmaStats(ENIGME_DIFFICILE);
+
+ res.status(200).json({ tab : weeklyHardEnigmaStats });
+ }
+ catch(error){
+ console.error(error);
+ res.status(500).json({ error: 'Erreur lors de la récupération des stats weeklyHardEnigma.' });
+ }
+ finally{
+ await db.disconnect();
+ }
+ }
+
+ static async getWeeklyOnline(req, res){
+ const db = new DatabaseService();
+
+ try{
+ await db.connect();
+
+ const weeklyOnlineStats = await db.getWeeklyOnlineStats();
+
+ res.status(200).json({ tab : weeklyOnlineStats });
+ }
+ catch(error){
+ console.error(error);
+ res.status(500).json({ error: 'Erreur lors de la récupération des stats weeklyOnline' });
+ }
+ finally{
+ await db.disconnect();
+ }
+ }
+
+}
+
+module.exports = SessionController;
\ No newline at end of file
diff --git a/cryptide_project/server/api/controllers/SessionController.js b/cryptide_project/server/api/controllers/SessionController.js
index dc23ea0..1fc1fc4 100644
--- a/cryptide_project/server/api/controllers/SessionController.js
+++ b/cryptide_project/server/api/controllers/SessionController.js
@@ -88,8 +88,6 @@ class SessionController {
nbWins: nbWinsOL,
ratio: ratioOL};
-
- console.log("[" + hour + ":" + minutes + "] " + req.session.user.pseudo + " have a session.");
res.status(200).json({ user: req.session.user });
}
catch(error){
diff --git a/cryptide_project/server/api/routes/AuthRoutes.js b/cryptide_project/server/api/routes/AuthRoutes.js
index 3e053e0..95b3c80 100644
--- a/cryptide_project/server/api/routes/AuthRoutes.js
+++ b/cryptide_project/server/api/routes/AuthRoutes.js
@@ -2,6 +2,7 @@ const express = require('express');
const router = express.Router();
const AuthController = require('../controllers/AuthController');
const SessionController = require('../controllers/SessionController');
+const ScoreboardController = require('../controllers/ScoreboardController');
// Routes pour l'authentification
router.post('/auth/signup', AuthController.signUp);
@@ -20,4 +21,19 @@ router.post('/session/addHardEnigmaStats', SessionController.addHardEnigmaStats)
router.post('/session/addOnlineStats', SessionController.addOnlineStats);
router.put('/session/updatePseudo', SessionController.UpdatePseudo);
+// Routes pour le daily scoreboard
+router.get('/scoreboard/getDailyMastermind', ScoreboardController.getDailyMastermind);
+router.get('/scoreboard/getDailyEasyEnigma', ScoreboardController.getDailyEasyEnigma);
+router.get('/scoreboard/getDailyMediumEnigma', ScoreboardController.getDailyMediumEnigma);
+router.get('/scoreboard/getDailyHardEnigma', ScoreboardController.getDailyHardEnigma);
+router.get('/scoreboard/getDailyOnline', ScoreboardController.getDailyOnline);
+
+// Routes pour le weekly scoreboard
+router.get('/scoreboard/getWeeklyMastermind', ScoreboardController.getWeeklyMastermind);
+router.get('/scoreboard/getWeeklyEasyEnigma', ScoreboardController.getWeeklyEasyEnigma);
+router.get('/scoreboard/getWeeklyMediumEnigma', ScoreboardController.getWeeklyMediumEnigma);
+router.get('/scoreboard/getWeeklyHardEnigma', ScoreboardController.getWeeklyHardEnigma);
+router.get('/scoreboard/getWeeklyOnline', ScoreboardController.getWeeklyOnline);
+
+
module.exports = router;
diff --git a/cryptide_project/server/api/server.js b/cryptide_project/server/api/server.js
index f511624..a216eda 100644
--- a/cryptide_project/server/api/server.js
+++ b/cryptide_project/server/api/server.js
@@ -14,7 +14,7 @@ const port = 3003;
// Middleware
app.use(cors(
{
- origin: ["http://localhost:3000", "http://172.20.10.4:3000"],
+ origin: ["http://172.20.10.4:3000", "http://localhost:3000"],
credentials: true
}
)); // Autoriser les requêtes cross-origin
diff --git a/cryptide_project/server/api/services/DatabaseService.js b/cryptide_project/server/api/services/DatabaseService.js
index e8baba2..8742bfc 100644
--- a/cryptide_project/server/api/services/DatabaseService.js
+++ b/cryptide_project/server/api/services/DatabaseService.js
@@ -127,6 +127,140 @@ class DatabaseService {
});
}
+ // ---------------------------------------------------------------
+ // ------------------- STATS JOURNALIERE -------------------------
+ // ---------------------------------------------------------------
+
+ async getDailyMastermindStats() {
+ return new Promise((resolve, reject) => {
+ // Obtenez la date actuelle au format AAAA-MM-JJ
+ const currentDate = new Date().toISOString().slice(0, 10);
+
+ // Récupérer les 5 meilleurs scores de la journée
+ this.client.all(
+ 'SELECT pseudo, score FROM users INNER JOIN games ON users.idUser = games.idUser WHERE gameType = ? AND SUBSTR(playedDate, 1, 10) = ? ORDER BY score ASC LIMIT 10',
+ "mastermind",
+ currentDate,
+ (err, result) => {
+ if (err) {
+ reject(err);
+ } else {
+ resolve(result);
+ }
+ }
+ );
+ });
+ }
+
+ async getDailyEnigmaStats(enigmaLevel) {
+ return new Promise((resolve, reject) => {
+ const currentDate = new Date().toISOString().slice(0, 10);
+
+ this.client.all(
+ 'SELECT pseudo, time FROM users INNER JOIN games ON users.idUser = games.idUser WHERE gameType = ? AND SUBSTR(playedDate, 1, 10) = ? ORDER BY time ASC LIMIT 10',
+ enigmaLevel,
+ currentDate,
+ (err, result) => {
+ if (err) {
+ reject(err);
+ } else {
+ resolve(result);
+ }
+ }
+ );
+ });
+ }
+
+ async getDailyOnlineStats() {
+ return new Promise((resolve, reject) => {
+ const currentDate = new Date().toISOString().slice(0, 10);
+
+ this.client.all(
+ 'SELECT pseudo, COUNT(*) AS wins FROM users INNER JOIN games ON users.idUser = games.idUser WHERE gameType = ? AND SUBSTR(playedDate, 1, 10) = ? AND win = ? GROUP BY users.idUser ORDER BY wins ASC LIMIT 10',
+ "multijoueur", currentDate, 1,
+ (err, result) => {
+ if (err) {
+ reject(err);
+ } else {
+ resolve(result);
+ }
+ }
+ );
+ });
+ }
+
+
+ // ---------------------------------------------------------------
+ // ------------------- STATS HEBDOMADAIRE ------------------------
+ // ---------------------------------------------------------------
+
+ async getWeeklyMastermindStats() {
+ return new Promise((resolve, reject) => {
+ const currentDate = new Date().toISOString().slice(0, 10);
+ const currentDay = new Date().getDay();
+ const firstDayOfWeek = new Date(new Date().setDate(new Date().getDate() - currentDay)).toISOString().slice(0, 10);
+
+ this.client.all(
+ 'SELECT pseudo, score FROM users INNER JOIN games ON users.idUser = games.idUser WHERE gameType = ? AND SUBSTR(playedDate, 1, 10) BETWEEN ? AND ? ORDER BY score ASC LIMIT 10',
+ "mastermind",
+ firstDayOfWeek,
+ currentDate,
+ (err, result) => {
+ if (err) {
+ reject(err);
+ } else {
+ resolve(result);
+ }
+ }
+ );
+ });
+ }
+
+ async getWeeklyEnigmaStats(enigmaLevel) {
+ return new Promise((resolve, reject) => {
+ const currentDate = new Date().toISOString().slice(0, 10);
+ const currentDay = new Date().getDay();
+ const firstDayOfWeek = new Date(new Date().setDate(new Date().getDate() - currentDay)).toISOString().slice(0, 10);
+
+ this.client.all(
+ 'SELECT pseudo, time FROM users INNER JOIN games ON users.idUser = games.idUser WHERE gameType = ? AND SUBSTR(playedDate, 1, 10) BETWEEN ? AND ? ORDER BY time ASC LIMIT 10',
+ enigmaLevel,
+ firstDayOfWeek,
+ currentDate,
+ (err, result) => {
+ if (err) {
+ reject(err);
+ } else {
+ resolve(result);
+ }
+ }
+ );
+ });
+ }
+
+ async getWeeklyOnlineStats() {
+ return new Promise((resolve, reject) => {
+ const currentDate = new Date().toISOString().slice(0, 10);
+ const currentDay = new Date().getDay();
+ const firstDayOfWeek = new Date(new Date().setDate(new Date().getDate() - currentDay)).toISOString().slice(0, 10);
+
+ this.client.all(
+ 'SELECT pseudo, COUNT(*) as wins FROM users INNER JOIN games ON users.idUser = games.idUser WHERE gameType = ? AND SUBSTR(playedDate, 1, 10) BETWEEN ? AND ? AND win = ? ORDER BY wins ASC LIMIT 10',
+ "multijoueur",
+ firstDayOfWeek,
+ currentDate,
+ 1,
+ (err, result) => {
+ if (err) {
+ reject(err);
+ } else {
+ resolve(result);
+ }
+ }
+ );
+ });
+ }
+
// -------------------------------------------------------------
// ------------------- STATS MASTERMIND ------------------------
// -------------------------------------------------------------
diff --git a/cryptide_project/src/AdressSetup.ts b/cryptide_project/src/AdressSetup.ts
index da5fce5..a5b4f64 100644
--- a/cryptide_project/src/AdressSetup.ts
+++ b/cryptide_project/src/AdressSetup.ts
@@ -1,5 +1,7 @@
+// const ADRESSE_WEBSERVER = "http://172.20.10.4:3002"
const ADRESSE_WEBSERVER = "http://localhost:3002"
+// const ADRESSE_DBSERVER = "http://172.20.10.4:3003"
const ADRESSE_DBSERVER = "http://localhost:3003"
const tmp = ADRESSE_DBSERVER
diff --git a/cryptide_project/src/Components/GraphContainer.tsx b/cryptide_project/src/Components/GraphContainer.tsx
index e83fe26..bf76136 100644
--- a/cryptide_project/src/Components/GraphContainer.tsx
+++ b/cryptide_project/src/Components/GraphContainer.tsx
@@ -76,7 +76,8 @@ let firstPlayer = 0
let cptBug = 0
let cptUseEffect = 0
let testPlayers: Player[] = []
-
+let testTemps = 0
+let testFirst = false
const MyGraphComponent: React.FC = ({onNodeClick, handleShowTurnBar, handleTurnBarTextChange, playerTouched, setPlayerTouched, changecptTour, solo, isDaily, isEasy, addToHistory, showLast, setNetwork, setNetworkEnigme, setPlayerIndex, askedWrong, setAskedWrong, importToPdf, setImportToPdf, importToJSON, setImportToJSON, setPutCorrectBackground, setPutGreyBackground, setPutImposssibleGrey, putCorrectBackground, putGreyBackground, putImposssibleGrey}) => {
@@ -86,7 +87,7 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS
let initMtn = 0
const {isLoggedIn, user, manager} = useAuth();
- const { indices, indice, person, personNetwork, setNodeIdData, players, setPlayersData, askedPersons, setActualPlayerIndexData, room, actualPlayerIndex, turnPlayerIndex, setTurnPlayerIndexData, setWinnerData, dailyEnigme, setNbCoupData, settempsData, setNetworkDataData, setSeedData, nodesC} = useGame();
+ const { indices, indice, person, personNetwork, setNodeIdData, players, setPlayersData, askedPersons, setActualPlayerIndexData, room, actualPlayerIndex, turnPlayerIndex, setTurnPlayerIndexData, setWinnerData, dailyEnigme, setNbCoupData, settempsData, setNetworkDataData, setSeedData, nodesC, temps} = useGame();
const params = new URLSearchParams(window.location.search);
const navigate = useNavigate();
@@ -95,10 +96,16 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS
const [elapsedTime, setElapsedTime] = useState(0);
useEffect(() => {
+ if (testFirst){
+ testTemps = 0
+ endgame = false
+ testFirst = false
+ }
// Démarrez le timer au montage du composant
const intervalId = setInterval(() => {
setElapsedTime((prevElapsedTime) => prevElapsedTime + 0.5);
settempsData(elapsedTime)
+ testTemps += 0.5
cptBug ++
if (cptBug > 10){
@@ -110,6 +117,7 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS
// Vérifiez si la durée est écoulée, puis arrêtez le timer
if (endgame) {
clearInterval(intervalId);
+ testTemps = 0
}
}, 500);
@@ -800,7 +808,7 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS
setLastIndex(-1)
setPlayerTouched(-1)
setWinnerData(winner)
- setElapsedTime(0)
+
first = true
cptHistory = 0
@@ -817,10 +825,10 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS
// console.log("nbGames: " + user.onlineStats.nbGames + " nbWins: " + user.onlineStats.nbWins);
if(winner.id === currentPlayer.id){
// Ajouter une victoire
- manager.userService.addOnlineStats(user.pseudo, 1, elapsedTime);
+ manager.userService.addOnlineStats(user.pseudo, 1, testTemps - 0.5);
}
else{
- manager.userService.addOnlineStats(user.pseudo, 0, elapsedTime);
+ manager.userService.addOnlineStats(user.pseudo, 0, testTemps - 0.5);
}
}
else{
@@ -833,6 +841,7 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS
console.log(e);
}
finally{
+ setElapsedTime(0)
socket.off("end game")
socket.off("asked all")
socket.off("opacity activated")
@@ -1006,6 +1015,8 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS
if(node == undefined)return;
if (personTest != undefined && !node.label.includes(positionToEmoji(index, true)) && !node.label.includes(positionToEmoji(index, false))){ //si la personne existe et que le noeud n'a pas déjà été cliqué
let index =0
+ let works = true
+ const statsTime = elapsedTime;
for (const i of indices){
const tester = IndiceTesterFactory.Create(i)
const test = tester.Works(personTest)
@@ -1019,38 +1030,46 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS
index++
}
if (person !== null && person.getId() === params.nodes[0]){
-
if (user!=null){
setWinnerData(user)
setNetworkDataData(networkData)
}
cptTour ++;
setNbCoupData(cptTour)
- setElapsedTime(0)
- endgame = true
try{
+ console.log("time: " + testTemps)
if(user && isLoggedIn){
if(solo){
if(isDaily){
// TODO: verif difficulté et add les stats
// TODO: verif pour facile et difficile, si réussi en one shot ou non
if(isEasy){
- manager.userService.addEasyEnigmaStats(user.pseudo, 1, elapsedTime);
+ manager.userService.addEasyEnigmaStats(user.pseudo, 1, testTemps - 0.5);
}
else{
- manager.userService.addHardEnigmaStats(user.pseudo, 1, elapsedTime);
+ manager.userService.addHardEnigmaStats(user.pseudo, 1, testTemps - 0.5);
}
}
else{
// add stats mastermind
if(user && user.mastermindStats){
- manager.userService.addMastermindStats(user.pseudo, cptTour, elapsedTime);
+ manager.userService.addMastermindStats(user.pseudo, cptTour, testTemps - 0.5);
}
}
}
+ }
+ else{
+ // add stats mastermind
+ if(user && user.mastermindStats){
+ manager.userService.addMastermindStats(user.pseudo, cptTour, elapsedTime);
+ }
}
- }
+ testFirst = true
+ setElapsedTime(0)
+ endgame = true
+ navigate(`${basePath}/endgame?solo=true&daily=${isDaily}`)
+ }
catch(error){
console.log(error);
}
diff --git a/cryptide_project/src/Components/NavBar.tsx b/cryptide_project/src/Components/NavBar.tsx
index a91f0a6..548f34a 100644
--- a/cryptide_project/src/Components/NavBar.tsx
+++ b/cryptide_project/src/Components/NavBar.tsx
@@ -12,6 +12,7 @@ import { BsFillPersonPlusFill } from 'react-icons/bs';
/* Images */
import logo from '../res/img/logo2_preview_rev_1.png';
+import defaultImg from '../res/img/Person.png';
/* Components */
import LanguageNavItem from './LangNavItem';
@@ -26,19 +27,23 @@ import { useAuth } from '../Contexts/AuthContext';
import { useNavigate } from 'react-router-dom';
import {basePath} from "../AdressSetup"
+import Player from '../model/Player';
+import { set } from 'lodash';
// @ts-ignore
function AppNavbar({changeLocale}) {
const theme = useTheme();
- const {user, isLoggedIn, logout} = useAuth();
-
const navigate = useNavigate();
-
+ const {isLoggedIn, login, user, setUserData, manager } = useAuth();
function navigateToProfile(){
navigate(`${basePath}/profile`)
}
+ function navigateToLogin(){
+ navigate(`${basePath}/login`)
+ }
+
function navigateToHome(){
navigate(`${basePath}/`)
}
@@ -64,40 +69,27 @@ function AppNavbar({changeLocale}) {
diff --git a/cryptide_project/src/Components/ScoreBoard.css b/cryptide_project/src/Components/ScoreBoard.css
new file mode 100644
index 0000000..2272e63
--- /dev/null
+++ b/cryptide_project/src/Components/ScoreBoard.css
@@ -0,0 +1,15 @@
+/* Ajoutez ces styles dans votre fichier CSS ou utilisez un préprocesseur comme SCSS */
+.tabsStats {
+ padding: 20px;
+ }
+
+ .stats {
+ background-color: #f0f0f0;
+ padding: 20px;
+ border-radius: 8px;
+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
+ text-align: center;
+ }
+
+ /* Personnalisez davantage selon vos préférences */
+
\ No newline at end of file
diff --git a/cryptide_project/src/Components/ScoreBoard.tsx b/cryptide_project/src/Components/ScoreBoard.tsx
index 3dbe23c..2ceb2a0 100644
--- a/cryptide_project/src/Components/ScoreBoard.tsx
+++ b/cryptide_project/src/Components/ScoreBoard.tsx
@@ -1,13 +1,13 @@
-import React from 'react';
+import React, {useState, useEffect} from 'react';
+import Carousel from 'nuka-carousel';
/* Style */
import '../Pages/Play.css';
import '../Style/Global.css'
+import './ScoreBoard.css';
import { useTheme } from '../Style/ThemeContext';
/* Ressources */
-import Person from '../res/img/Person.png'
-import leave from '../res/img/bot.png'
import trophy from '../res/icon/trophy.png'
import share from '../res/icon/share.png';
@@ -19,155 +19,346 @@ import Row from 'react-bootstrap/Row';
import Col from 'react-bootstrap/Col';
/* Component */
-import ButtonImgNav from './ButtonImgNav';
import User from '../model/User';
-/* Types */
+/* Services */
+import ScoreboardService from '../services/ScoreboardService';
+import { BiLineChart, BiLineChartDown } from 'react-icons/bi';
+import { CarouselCaption } from 'react-bootstrap';
+import { BsLine } from 'react-icons/bs';
//@ts-ignore
const ScoreBoard: React.FC<{ Player: User }> = ({ Player }) => {
const theme=useTheme();
- console.log(Player);
+ const [carouselKey, setCarouselKey] = useState(0);
+ const [activeTab, setActiveTab] = useState("perso");
+
+ // DAILY STATS
+ const [dailyMastermindStats, setDailyMastermindStats] = useState(null);
+ const [dailyEasyEnigmaStats, setDailyEasyEnigmaStats] = useState(null);
+ const [dailyMediumEnigmaStats, setDailyMediumEnigmaStats] = useState(null);
+ const [dailyHardEnigmaStats, setDailyHardEnigmaStats] = useState(null);
+ const [dailyOnlineStats, setDailyOnlineStats] = useState(null);
+
+ // WEEKLY STATS
+ const [weeklyMastermindStats, setWeeklyMastermindStats] = useState(null);
+ const [weeklyEasyEnigmaStats, setWeeklyEasyEnigmaStats] = useState(null);
+ const [weeklyMediumEnigmaStats, setWeeklyMediumEnigmaStats] = useState(null);
+ const [weeklyHardEnigmaStats, setWeeklyHardEnigmaStats] = useState(null);
+ const [weeklyOnlineStats, setWeeklyOnlineStats] = useState(null);
+
+ // Récupérer les records daily
+ useEffect(() => {
+ async function fetchDailyStats() {
+ try {
+ const resultMM = await ScoreboardService.getDailyMastermindStats();
+ const resultEF = await ScoreboardService.getDailyEasyEnigmaStats();
+ const resultEM = await ScoreboardService.getDailyMediumEnigmaStats();
+ const resultED = await ScoreboardService.getDailyHardEnigmaStats();
+ const resultOL = await ScoreboardService.getDailyOnlineStats();
+
+ setDailyMastermindStats(resultMM);
+ setDailyEasyEnigmaStats(resultEF);
+ setDailyMediumEnigmaStats(resultEM);
+ setDailyHardEnigmaStats(resultED);
+ setDailyOnlineStats(resultOL);
+ } catch (error) {
+ console.error(error);
+ }
+ }
+
+ async function fetchWeeklyStats() {
+ try{
+ const resultMM = await ScoreboardService.getWeeklyMastermindStats();
+ const resultEF = await ScoreboardService.getWeeklyEasyEnigmaStats();
+ const resultEM = await ScoreboardService.getWeeklyMediumEnigmaStats();
+ const resultED = await ScoreboardService.getWeeklyHardEnigmaStats();
+ const resultOL = await ScoreboardService.getWeeklyOnlineStats();
+
+ setWeeklyMastermindStats(resultMM);
+ setWeeklyEasyEnigmaStats(resultEF);
+ setWeeklyMediumEnigmaStats(resultEM);
+ setWeeklyHardEnigmaStats(resultED);
+ setWeeklyOnlineStats(resultOL);
+ } catch (error) {
+ console.error(error);
+ }
+ }
+
+ fetchDailyStats();
+ fetchWeeklyStats();
+ }, []);
return (
- //
-
-
-
-
- Stats en MasterMind :
-
- Partie Jouées :
- {Player !== null ? Player.mastermindStats.nbGames : "0"}
-
-
- Best-Score :
- {Player !== null ? Player.mastermindStats.bestScore : "0"}
-
-
- Moyenne d'essai :
- {Player !== null ? Player.mastermindStats.avgNbTry : "0"}
-
-
- Stats en Enigme facile :
-
- Partie jouée :
- {Player !== null ? Player.easyEnigmaStats.nbGames : "0"}
-
-
- Nombre de victoire :
- {Player !== null ? Player.easyEnigmaStats.nbWins : "0"}
-
-
- Ratio V/D :
- {Player !== null ? Player.easyEnigmaStats.ratio.toFixed(2) + "%" : "00.0%"}
-
-
- Meilleur temps :
- {Player !== null ? Player.easyEnigmaStats.bestTime : "0"}
-
-
- Moyenne de temps :
- {Player !== null ? Player.easyEnigmaStats.avgTime.toFixed(2) : "0"}
-
-
- Stats en Enigme moyenne :
-
- Partie jouée :
- {Player !== null ? Player.mediumEnigmaStats.nbGames : "0"}
-
-
- Best-Score :
- {Player !== null ? Player.mediumEnigmaStats.bestScore : "0"}
-
-
- Moyenne d'essai :
- {Player !== null ? Player.mediumEnigmaStats.avgNbTry.toFixed(2) : "0"}
-
-
- Stats en Enigme difficile :
-
- Partie jouée :
- {Player !== null ? Player.hardEnigmaStats.nbGames : "0"}
-
-
- Nombre de victoire :
- {Player !== null ? Player.hardEnigmaStats.nbWins : "0"}
-
-
- Ratio V/D :
- {Player !== null ? Player.hardEnigmaStats.ratio.toFixed(2) + "%" : "00.0%"}
-
-
- Meilleur temps :
- {Player !== null ? Player.hardEnigmaStats.bestTime : "0"}
-
-
- Moyenne de temps :
- {Player !== null ? Player.hardEnigmaStats.avgTime.toFixed(2) : "0"}
-
-
- Stats en ligne :
-
- Partie jouée :
- {Player !== null ? Player.onlineStats.nbGames : "0"}
-
-
- Nombre de victoire :
- {Player !== null ? Player.onlineStats.nbWins : "0"}
-
-
- Ratio V/D :
- {Player !== null ? Player.onlineStats.ratio.toFixed(2) + "%" : "0"}
-
-
-
-
-
-
-
- Partie Jouées :
- 10
-
-
- Partie gagnées :
- 2
-
-
- Pions posés :
- 2
-
-
-
- Partie solo :
- 21
-
-
- Nombre de coups moyen :
- 19
-
-
-
-
-
-
-
-
-
-
- //
+ {
+ setActiveTab(key);
+ // Forcer une mise à jour du carousel
+ setCarouselKey((prevKey) => prevKey + 1);
+ }}
+ id="ScoreBoard"
+ className="tabsStats justify-content-around">
+
+
+
+
+
Mastermind
+
+
Parties Jouées: {Player.mastermindStats.nbGames}
+
Best-Score: {Player.mastermindStats.bestScore}
+
Moyenne d'essai: {Player.mastermindStats.avgNbTry.toFixed(2)}
+
+
+
Enigme facile
+
+
Parties Jouées: {Player.easyEnigmaStats.nbGames}
+
Nombre de victoires: {Player.easyEnigmaStats.nbWins}
+
Ratio V/D: {Player.easyEnigmaStats.ratio.toFixed(2) + "%"}
+
Meilleur temps: {Player.easyEnigmaStats.bestTime + "s"}
+
Moyenne de temps: {Player.easyEnigmaStats.avgTime.toFixed(2) + "s"}
+
+
+
Enigme moyenne
+
+
Parties Jouées: {Player.mediumEnigmaStats.nbGames}
+
Best-Score: {Player.mediumEnigmaStats.bestScore}
+
Moyenne d'essai: {Player.mediumEnigmaStats.avgNbTry.toFixed(2)}
+
+
+
Enigme difficile
+
+
Parties Jouées: {Player.hardEnigmaStats.nbGames}
+
Nombre de victoires: {Player.hardEnigmaStats.nbWins}
+
Ratio V/D: {Player.hardEnigmaStats.ratio.toFixed(2) + "%"}
+
Meilleur temps: {Player.hardEnigmaStats.bestTime + "s"}
+
Moyenne de temps: {Player.hardEnigmaStats.avgTime.toFixed(2) + "s"}
+
+
+
En ligne
+
+
Parties Jouées: {Player.onlineStats.nbGames}
+
Nombre de victoires: {Player.onlineStats.nbWins}
+
Ratio V/D: {Player.onlineStats.ratio.toFixed(2) + "s"}
+
+
+
+
+
+
+
+
+
Mastermind
+
+ {dailyMastermindStats !== null ? (dailyMastermindStats.tab.length !== 0 ? dailyMastermindStats.tab.map((stats: any, index: number) => (
+ <>
+
+
+ {index+1}.{stats.pseudo}
+
+
+ {stats.score + " essai(s)"}
+
+
+ >
+ )) : (
+
Nothing for the moment
+ )) : (
+
Nothing for the moment
+ )}
+
+
+
Enigme facile
+
+ {dailyEasyEnigmaStats !== null ? (dailyEasyEnigmaStats.tab.length !== 0 ? dailyEasyEnigmaStats.tab.map((stats: any, index: number) => (
+ <>
+
+
+ {index+1}.{stats.pseudo}
+
+
+ {stats.time + "s"}
+
+
+ >
+ )) : (
+
Nothing for the moment
+ )) : (
+
Nothing for the moment
+ )}
+
+
+
Enigme moyenne
+
+ {dailyMediumEnigmaStats !== null ? (dailyMediumEnigmaStats.tab.length !== 0 ? dailyMediumEnigmaStats.tab.map((stats: any, index: number) => (
+ <>
+
+
+ {index+1}.{stats.pseudo}
+
+
+ {stats.time + "s"}
+
+
+ >
+ )) : (
+
Nothing for the moment
+ )) : (
+
Nothing for the moment
+ )}
+
+
+
Enigme difficile
+
+ {dailyHardEnigmaStats !== null ? (dailyHardEnigmaStats.tab.length !== 0 ? dailyHardEnigmaStats.tab.map((stats: any, index: number) => (
+ <>
+
+
+ {index+1}.{stats.pseudo}
+
+
+ {stats.time + "s"}
+
+
+ >
+ )) : (
+
Nothing for the moment
+ )) : (
+
Nothing for the moment
+ )}
+
+
+
En ligne
+
+ {dailyOnlineStats !== null ? (dailyOnlineStats.tab.length !== 0 ? dailyOnlineStats.tab.map((stats: any, index: number) => (
+ <>
+
+
+ {index+1}.{stats.pseudo}
+
+
+ {stats.wins + " victoires"}
+
+
+ >
+ )) : (
+
Nothing for the moment
+ )) : (
+
Nothing for the moment
+ )}
+
+
+
+
+
+
+
+
+
Mastermind
+
+ {weeklyMastermindStats !== null ? (weeklyMastermindStats.tab.length !== 0 ? weeklyMastermindStats.tab.map((stats: any, index: number) => (
+ <>
+
+
+ {index+1}.{stats.pseudo}
+
+
+ {stats.score + " essai(s)"}
+
+
+ >
+ )) : (
+
Nothing for the moment
+ )) : (
+
Nothing for the moment
+ )}
+
+
+
Enigme facile
+
+ {weeklyEasyEnigmaStats !== null ? (weeklyEasyEnigmaStats.tab.length !== 0 ? weeklyEasyEnigmaStats.tab.map((stats: any, index: number) => (
+ <>
+
+
+ {index+1}.{stats.pseudo}
+
+
+ {stats.time + "s"}
+
+
+ >
+ )) : (
+
Nothing for the moment
+ )) : (
+
Nothing for the moment
+ )}
+
+
+
Enigme moyenne
+
+ {weeklyMediumEnigmaStats !== null ? (weeklyMediumEnigmaStats.tab.length !== 0 ? weeklyMediumEnigmaStats.tab.map((stats: any, index: number) => (
+ <>
+
+
+ {index+1}.{stats.pseudo}
+
+
+ {stats.time + "s"}
+
+
+ >
+ )) : (
+
Nothing for the moment
+ )) : (
+
Nothing for the moment
+ )}
+
+
+
Enigme difficile
+
+ {weeklyHardEnigmaStats !== null ? (weeklyHardEnigmaStats.tab.length !== 0 ? weeklyHardEnigmaStats.tab.map((stats: any, index: number) => (
+ <>
+
+
+ {index+1}.{stats.pseudo}
+
+
+ {stats.time + "s"}
+
+
+ >
+ )) : (
+
Nothing for the moment
+ )) : (
+
Nothing for the moment
+ )}
+
+
+
En ligne
+
+ {weeklyOnlineStats !== null ? (weeklyOnlineStats.tab.length !== 0 ? weeklyOnlineStats.tab.map((stats: any, index: number) => (
+ <>
+
+
+ {index+1}.{stats.pseudo}
+
+
+ {stats.wins + " victoires"}
+
+
+ >
+ )) : (
+
Nothing for the moment
+ )) : (
+
Nothing for the moment
+ )}
+
+
+
+
+
);
}
-export default ScoreBoard;
+export default ScoreBoard;
\ No newline at end of file
diff --git a/cryptide_project/src/Contexts/AuthContext.tsx b/cryptide_project/src/Contexts/AuthContext.tsx
index e0f6f1a..ac1b880 100644
--- a/cryptide_project/src/Contexts/AuthContext.tsx
+++ b/cryptide_project/src/Contexts/AuthContext.tsx
@@ -24,8 +24,6 @@ const AuthProvider: React.FC<{ children: ReactNode }> = ({ children }) => {
const login = async () => {
setIsLoggedIn(true);
- const [u, bool] = await manager.userService.fetchUserInformation()
- setUser(u)
};
const setUserData = (newPlayer: User) => {
diff --git a/cryptide_project/src/Pages/InfoPage.tsx b/cryptide_project/src/Pages/InfoPage.tsx
index dadd9ac..046cef6 100644
--- a/cryptide_project/src/Pages/InfoPage.tsx
+++ b/cryptide_project/src/Pages/InfoPage.tsx
@@ -1,4 +1,4 @@
-import React from 'react';
+import React, {useEffect} from 'react';
/* Style */
import '../Style/Global.css';
@@ -24,11 +24,31 @@ import Alert from 'react-bootstrap/Alert';
import MGlass from "../res/icon/magnifying-glass.png";
import Param from "../res/icon/param.png";
import Info from "../res/icon/infoGreen.png"; //todo changer la couleur de l'icon
+import { useAuth } from '../Contexts/AuthContext';
+
//@ts-ignore
function InfoPage({locale, changeLocale}) {
-
const theme = useTheme();
+ const {isLoggedIn, login, user, setUserData, manager } = useAuth();
+
+ useEffect(() => {
+ if (user == null){
+ console.log(user)
+ manager.userService.fetchUserInformation().then(([user, loggedIn]) =>{
+ console.log(user);
+ if (user!=null){
+ if (loggedIn){
+ login()
+ setUserData(user)
+ }
+ else{
+ setUserData(user)
+ }
+ }
+ })
+ }
+ }, [isLoggedIn]);
const styles = {
roux: { backgroundColor: ColorToHexa(Color.REDHEAD), width: '15px', height: '15px', display: 'inline-block', marginRight: '5px' },
@@ -61,10 +81,8 @@ function InfoPage({locale, changeLocale}) {
:
-
-
-
-
+
+
: 🟪🟦🟩🟨🟥🟫
@@ -73,7 +91,6 @@ function InfoPage({locale, changeLocale}) {
: 🟣🔵🟢🟡🔴🟤
-
@@ -122,6 +139,7 @@ function InfoPage({locale, changeLocale}) {
+
@@ -270,7 +288,6 @@ function InfoPage({locale, changeLocale}) {
-
diff --git a/cryptide_project/src/Pages/LoginForm.tsx b/cryptide_project/src/Pages/LoginForm.tsx
index 8e62695..c484498 100644
--- a/cryptide_project/src/Pages/LoginForm.tsx
+++ b/cryptide_project/src/Pages/LoginForm.tsx
@@ -4,16 +4,16 @@ import { useNavigate } from 'react-router-dom';
import { useAuth } from '../Contexts/AuthContext';
import AuthService from '../services/AuthService';
import '../Style/Global.css';
+import { Link } from 'react-router-dom';
import {basePath} from "../AdressSetup"
const SignIn = () => {
const navigate = useNavigate();
- const { login } = useAuth();
-
const [error, setError] = useState(null);
+ const {login} = useAuth();
const [showConfirmation, setShowConfirmation] = useState(false);
-
+
const handleSubmit = async (event: React.FormEvent) => {
event.preventDefault();
@@ -80,7 +80,7 @@ const SignIn = () => {
- Mot de passe oublié ?
+ Pas encore inscrit ?
diff --git a/cryptide_project/src/Pages/NewPlay.tsx b/cryptide_project/src/Pages/NewPlay.tsx
index d10c53a..27e2153 100644
--- a/cryptide_project/src/Pages/NewPlay.tsx
+++ b/cryptide_project/src/Pages/NewPlay.tsx
@@ -195,20 +195,15 @@ function NewPlay() {
// const returnVisibility: Visibility = goBackRoom !== -1 ? "visible" : "hidden";
- const returnVisibility: any= goBackRoom !== -1 ? "visible" : "hidden" ;
-
+ const returnVisibility = goBackRoom !== -1 ? "block" : "none" ;
return (
-
-
- {/* Menu de boutons */}
-
+
+ {/* Boutons pour jouer */}
-
-
{({ placement, arrowProps, show: _show, popper, ...props }) => (
@@ -233,7 +228,7 @@ function NewPlay() {
{/* */}
{/* {goBackRoom != -1 && } */}
-
+
@@ -241,21 +236,11 @@ function NewPlay() {
-
-
-
-
-
- {user && user.pseudo}
-
-

-
- {user && (
)}
+
+
+ {user && }
+
);
}
diff --git a/cryptide_project/src/Pages/Play.css b/cryptide_project/src/Pages/Play.css
index f0a843e..f650357 100644
--- a/cryptide_project/src/Pages/Play.css
+++ b/cryptide_project/src/Pages/Play.css
@@ -1,17 +1,16 @@
-
-.MainContainer{
- flex: 1 1 0;
+.MainContainer {
display: flex;
flex-direction: row;
- justify-content:space-around
+ justify-content: center;
+ align-items: center;
+ height: 100%;
}
-.MidContainer{
+.MidContainer {
display: flex;
- /* justify-content:center; */
- align-items:center;
+ justify-content: center;
+ align-items: center;
flex-direction: column;
-
margin-top: 15px;
width: 30%;
}
@@ -21,20 +20,24 @@
justify-content: center;
}
-.leftContainer{
- width: 30%;
+.leftContainer {
+ height: 100%;
+ margin: 20px 30px;
+ width: 70%;
}
-.rightContainer{
+.rightContainer {
+ height: 100%;
+ margin: 20px 30px;
width: 30%;
}
-.NewleftContainer{
+.NewleftContainer {
margin: 20px 30px;
width: 70%;
}
-.NewrightContainer{
+.NewrightContainer {
display: flex;
flex-direction: column;
justify-content: center;
@@ -42,81 +45,55 @@
width: 30%;
}
-/* .textBoard div{
- display: flex;
- flex-direction:column-reverse;
- justify-content:space-between
-} */
-
-/* .textBoard div:nth-child(2){
+.buttonGroupVertical {
display: flex;
- justify-content: end;
-} */
-
-/**Button**/
-.buttonGroupVertical{
- display: flex;
- justify-content:center;
- align-items:center;
+ justify-content: center;
+ align-items: center;
flex-direction: column;
}
-.NewbuttonGroupVertical{
+.NewbuttonGroupVertical {
display: flex;
- justify-content:space-around;
- align-items:start;
+ flex-direction: row;
+ justify-content: space-evenly;
}
-
-.ButtonNav{
+.ButtonNav {
margin: 15px 10px;
- width:200px;
+ width: 200px;
height: 8vh;
-
- /* background-color: #85C9C2;
- color: #2A4541; */
color: white;
-
- border: solid;
+ border: 2px solid #0056b3;
border-radius: 15px;
- border-width: 2px;
-
- font-size:larger;
+ font-size: larger;
}
-
-.ButtonNavRejoin{
+.ButtonNavRejoin {
margin: 15px 10px;
- width:200px;
+ width: 200px;
height: 8vh;
-
color: white;
background-color: aquamarine;
-
- border: solid 2px rgb(40, 225, 163);
+ border: 2px solid #0056b3;
border-radius: 15px;
-
- font-size:larger;
+ font-size: larger;
}
-.returnDiv{
+
+.returnDiv {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
-
- margin:40px 15px;
-
- border: solid 2px whitesmoke;
+ margin: 40px 15px;
+ border: 2px solid whitesmoke;
border-radius: 15px;
-
background-color: white;
}
.returnDiv p {
margin: 15px;
padding: 10px;
- border: solid 1px whitesmoke;
+ border: 1px solid whitesmoke;
border-radius: 10px;
-
- font-weight:500;
-}
\ No newline at end of file
+ font-weight: 500;
+}
diff --git a/cryptide_project/src/Pages/Profile.css b/cryptide_project/src/Pages/Profile.css
index 3f183ed..2959742 100644
--- a/cryptide_project/src/Pages/Profile.css
+++ b/cryptide_project/src/Pages/Profile.css
@@ -1,6 +1,5 @@
.mainContainer{
display: flex;
- /* flex-direction: column; */
justify-content: center;
align-items: center;
margin: 50px;
diff --git a/cryptide_project/src/Pages/Profile.tsx b/cryptide_project/src/Pages/Profile.tsx
index 4fa324f..dda92be 100644
--- a/cryptide_project/src/Pages/Profile.tsx
+++ b/cryptide_project/src/Pages/Profile.tsx
@@ -1,4 +1,4 @@
-import React, { useState } from 'react';
+import React, { useState, useEffect } from 'react';
import ProfilePDP from '../Components/ProfilePDP';
import SessionService from '../services/SessionService';
@@ -24,20 +24,34 @@ import Modal from 'react-bootstrap/Modal';
import Form from 'react-bootstrap/Form';
import ProgressBar from 'react-bootstrap/ProgressBar';
-
import {basePath} from "../AdressSetup"
//@ts-ignore
const Profile = () => {
-
const navigate = useNavigate();
- //let player;
- const {user, logout} = useAuth()
-
const [editingUsername, setEditingUsername] = useState(false);
+ const {isLoggedIn, login, logout, user, setUserData, manager } = useAuth();
const [newUsername, setNewUsername] = useState(user?.pseudo);
- //@ts-ignore
+ useEffect(() => {
+ if (user == null){
+ manager.userService.fetchUserInformation().then(([user, loggedIn]) =>{
+ if (user!=null){
+ if (loggedIn){
+ login()
+ setUserData(user)
+ }
+ }
+ })
+ }
+ }, [isLoggedIn]);
+
+ const handleLogout = () => {
+ logout();
+ navigate(`${basePath}/`);
+ };
+
+ // @ts-ignore
const onUsernameChange = (newUsername) => {
if(user?.pseudo != null){
SessionService.UpdatePseudo(user.pseudo, newUsername)
@@ -351,7 +365,10 @@ const Profile = () => {
>
-
+
+ {/* Bouton de déconnexion */}
+
+
>
diff --git a/cryptide_project/src/Pages/SignUpForm.tsx b/cryptide_project/src/Pages/SignUpForm.tsx
index 57dd802..0988471 100644
--- a/cryptide_project/src/Pages/SignUpForm.tsx
+++ b/cryptide_project/src/Pages/SignUpForm.tsx
@@ -9,7 +9,6 @@ import {basePath} from "../AdressSetup"
const SignUp = () => {
const navigate = useNavigate();
-
const [error, setError] = useState(null);
const [showConfirmation, setShowConfirmation] = useState(false);
diff --git a/cryptide_project/src/services/ScoreboardService.tsx b/cryptide_project/src/services/ScoreboardService.tsx
new file mode 100644
index 0000000..c7e699e
--- /dev/null
+++ b/cryptide_project/src/services/ScoreboardService.tsx
@@ -0,0 +1,244 @@
+import {ADRESSE_DBSERVER} from '../AdressSetup';
+
+class ScoreboardService {
+
+ // ------------------------------ GET ------------------------------
+ // ----------------------------- DAILY -----------------------------
+ // ----------------------------- STATS -----------------------------
+
+ static async getDailyMastermindStats() {
+ try {
+ const response = await fetch(ADRESSE_DBSERVER + '/scoreboard/getDailyMastermind', {
+ method: 'GET',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ credentials: 'include',
+ });
+
+ if (response.ok) {
+ const result = await response.json();
+ return result;
+ } else {
+ const errorResponse = await response.json();
+ throw new Error(errorResponse.error);
+ }
+ } catch (error) {
+ console.error(error);
+ throw error;
+ }
+ }
+
+ static async getDailyEasyEnigmaStats() {
+ try {
+ const response = await fetch(ADRESSE_DBSERVER + '/scoreboard/getDailyEasyEnigma', {
+ method: 'GET',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ credentials: 'include',
+ });
+
+ if (response.ok) {
+ const result = await response.json();
+ return result;
+ } else {
+ const errorResponse = await response.json();
+ throw new Error(errorResponse.error);
+ }
+ } catch (error) {
+ console.error(error);
+ throw error;
+ }
+ }
+
+ static async getDailyMediumEnigmaStats() {
+ try {
+ const response = await fetch(ADRESSE_DBSERVER + '/scoreboard/getDailyMediumEnigma', {
+ method: 'GET',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ credentials: 'include',
+ });
+
+ if (response.ok) {
+ const result = await response.json();
+ return result;
+ } else {
+ const errorResponse = await response.json();
+ throw new Error(errorResponse.error);
+ }
+ } catch (error) {
+ console.error(error);
+ throw error;
+ }
+ }
+
+ static async getDailyHardEnigmaStats() {
+ try {
+ const response = await fetch(ADRESSE_DBSERVER + '/scoreboard/getDailyHardEnigma', {
+ method: 'GET',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ credentials: 'include',
+ });
+
+ if (response.ok) {
+ const result = await response.json();
+ return result;
+ } else {
+ const errorResponse = await response.json();
+ throw new Error(errorResponse.error);
+ }
+ } catch (error) {
+ console.error(error);
+ throw error;
+ }
+ }
+
+ static async getDailyOnlineStats() {
+ try {
+ const response = await fetch(ADRESSE_DBSERVER + '/scoreboard/getDailyOnline', {
+ method: 'GET',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ credentials: 'include',
+ });
+
+ if (response.ok) {
+ const result = await response.json();
+ return result;
+ } else {
+ const errorResponse = await response.json();
+ throw new Error(errorResponse.error);
+ }
+ } catch (error) {
+ console.error(error);
+ throw error;
+ }
+ }
+
+ // ------------------------------ GET ------------------------------
+ // ----------------------------- WEEKLY ----------------------------
+ // ----------------------------- STATS -----------------------------
+
+ static async getWeeklyMastermindStats() {
+ try {
+ const response = await fetch(ADRESSE_DBSERVER + '/scoreboard/getWeeklyMastermind', {
+ method: 'GET',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ credentials: 'include',
+ });
+
+ if (response.ok) {
+ const result = await response.json();
+ return result;
+ } else {
+ const errorResponse = await response.json();
+ throw new Error(errorResponse.error);
+ }
+ } catch (error) {
+ console.error(error);
+ throw error;
+ }
+ }
+
+ static async getWeeklyEasyEnigmaStats() {
+ try {
+ const response = await fetch(ADRESSE_DBSERVER + '/scoreboard/getWeeklyEasyEnigma', {
+ method: 'GET',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ credentials: 'include',
+ });
+
+ if (response.ok) {
+ const result = await response.json();
+ return result;
+ } else {
+ const errorResponse = await response.json();
+ throw new Error(errorResponse.error);
+ }
+ } catch (error) {
+ console.error(error);
+ throw error;
+ }
+ }
+
+ static async getWeeklyMediumEnigmaStats() {
+ try {
+ const response = await fetch(ADRESSE_DBSERVER + '/scoreboard/getWeeklyMediumEnigma', {
+ method: 'GET',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ credentials: 'include',
+ });
+
+ if (response.ok) {
+ const result = await response.json();
+ return result;
+ } else {
+ const errorResponse = await response.json();
+ throw new Error(errorResponse.error);
+ }
+ } catch (error) {
+ console.error(error);
+ throw error;
+ }
+ }
+
+ static async getWeeklyHardEnigmaStats() {
+ try {
+ const response = await fetch(ADRESSE_DBSERVER + '/scoreboard/getWeeklyHardEnigma', {
+ method: 'GET',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ credentials: 'include',
+ });
+
+ if (response.ok) {
+ const result = await response.json();
+ return result;
+ } else {
+ const errorResponse = await response.json();
+ throw new Error(errorResponse.error);
+ }
+ } catch (error) {
+ console.error(error);
+ throw error;
+ }
+ }
+
+ static async getWeeklyOnlineStats() {
+ try {
+ const response = await fetch(ADRESSE_DBSERVER + '/scoreboard/getWeeklyOnline', {
+ method: 'GET',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ credentials: 'include',
+ });
+
+ if (response.ok) {
+ const result = await response.json();
+ return result;
+ } else {
+ const errorResponse = await response.json();
+ throw new Error(errorResponse.error);
+ }
+ } catch (error) {
+ console.error(error);
+ throw error;
+ }
+ }
+}
+
+export default ScoreboardService;
\ No newline at end of file
diff --git a/cryptide_project/src/services/SessionService.tsx b/cryptide_project/src/services/SessionService.tsx
index e17de92..f555132 100644
--- a/cryptide_project/src/services/SessionService.tsx
+++ b/cryptide_project/src/services/SessionService.tsx
@@ -165,7 +165,6 @@ class SessionService {
throw error;
}
}
-
}
export default SessionService;
diff --git a/cryptide_project/yarn.lock b/cryptide_project/yarn.lock
index e14f7e0..8bcad7e 100644
--- a/cryptide_project/yarn.lock
+++ b/cryptide_project/yarn.lock
@@ -8011,6 +8011,11 @@ nth-check@^2.0.1:
dependencies:
boolbase "^1.0.0"
+nuka-carousel@^7.0.0:
+ version "7.0.0"
+ resolved "https://registry.npmjs.org/nuka-carousel/-/nuka-carousel-7.0.0.tgz"
+ integrity sha512-KE0WV1MuE4Gq6ynL8P3qJH2rGq/DkJ0ej+ezo0IuZp4oklV8WNqu6P6O1utJqihHLGoEuFppq5wlHSHfhdCHXA==
+
nwsapi@^2.2.0:
version "2.2.7"
resolved "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.7.tgz"
@@ -9186,7 +9191,7 @@ react-dev-utils@^12.0.1:
strip-ansi "^6.0.1"
text-table "^0.2.0"
-"react-dom@^15.3.0 || ^16.0.0 || ^17.0.0 || ^18.0.0", react-dom@^18.0.0, react-dom@^18.2.0, react-dom@>=16.14.0, react-dom@>=16.6.0, react-dom@>=16.8:
+"react-dom@^15.3.0 || ^16.0.0 || ^17.0.0 || ^18.0.0", react-dom@^18.0.0, react-dom@^18.2.0, react-dom@>=16.14.0, react-dom@>=16.6.0, react-dom@>=16.8, react-dom@>=18.0.0:
version "18.2.0"
resolved "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz"
integrity sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g==
@@ -9349,7 +9354,7 @@ react-transition-group@^4.4.5:
loose-envify "^1.4.0"
prop-types "^15.6.2"
-react@*, "react@^15.3.0 || ^16.0.0 || ^17.0.0 || ^18.0.0", "react@^16.6.0 || 17 || 18", "react@^16.8.0 || ^17.0.0-rc.1 || ^18.0.0", react@^18.0.0, react@^18.2.0, "react@>= 16", react@>=0.14.0, react@>=15, react@>=15.0.0, react@>=16, react@>=16.14.0, react@>=16.3, react@>=16.6.0, react@>=16.8, react@>=16.8.0:
+react@*, "react@^15.3.0 || ^16.0.0 || ^17.0.0 || ^18.0.0", "react@^16.6.0 || 17 || 18", "react@^16.8.0 || ^17.0.0-rc.1 || ^18.0.0", react@^18.0.0, react@^18.2.0, "react@>= 16", react@>=0.14.0, react@>=15, react@>=15.0.0, react@>=16, react@>=16.14.0, react@>=16.3, react@>=16.6.0, react@>=16.8, react@>=16.8.0, react@>=18.0.0:
version "18.2.0"
resolved "https://registry.npmjs.org/react/-/react-18.2.0.tgz"
integrity sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==