Merge branch 'master' of https://codefirst.iut.uca.fr/git/Crypteam/Cryptid into tuto
continuous-integration/drone/push Build is passing Details

pull/104/head
Pierre Ferreira 1 year ago
commit 441c980866

@ -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",

@ -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",

@ -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;

@ -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){

@ -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;

@ -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

@ -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 ------------------------
// -------------------------------------------------------------

@ -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

@ -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<MyGraphComponentProps> = ({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<MyGraphComponentProps> = ({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<MyGraphComponentProps> = ({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<MyGraphComponentProps> = ({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<MyGraphComponentProps> = ({onNodeClick, handleS
setLastIndex(-1)
setPlayerTouched(-1)
setWinnerData(winner)
setElapsedTime(0)
first = true
cptHistory = 0
@ -817,10 +825,10 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({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<MyGraphComponentProps> = ({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<MyGraphComponentProps> = ({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,37 +1030,45 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({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);

@ -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}) {
</Nav>
<div className='leftdiv'>
<Nav className="ml-auto navbar-title-dd">
{isLoggedIn ? (
<NavDropdown
title={<span style={{ color: theme.colors.text }}>Menu <BiDoorOpen /></span>}
id="basic-nav-dropdown"
align="end"
drop='down-centered'
>
<NavDropdown.Item onClick={navigateToProfile}>Profil</NavDropdown.Item>
<LanguageNavItem
countryCode="FR"
languageKey="languageSelector.french"
onClick={() => changeLocale('fr')}
/>
<LanguageNavItem
countryCode="GB"
languageKey="languageSelector.english"
onClick={() => changeLocale('en')}
/>
<NavDropdown.Divider />
<NavDropdown.Item onClick={logout}>Déconnexion</NavDropdown.Item>
</NavDropdown>
) : (
<>
<Nav.Link href={`${basePath}/login`} className='navbar-title-dd' style={{ backgroundColor: theme.colors.secondary }}>
<BiLogInCircle />
<FormattedMessage id="log_in" />
</Nav.Link>
<Nav.Link href={`${basePath}/signup`} className='navbar-title-dd' style={{ backgroundColor: theme.colors.secondary }}>
<BsFillPersonPlusFill />
<FormattedMessage id="sign_up" />
</Nav.Link>
<LangDropDown changeLocale={changeLocale}/>
</>
)}
{isLoggedIn ? (
<>
{/* Boutou qui lors du clique nous redirige vers le profile */}
<Nav.Link onClick={navigateToProfile} style={{ color: theme.colors.text }}>
<span>
<img src={user? user.profilePicture : defaultImg} height="50" width="50" alt="profile"/>
{user && user.pseudo}
</span>
</Nav.Link>
</>
):(
<>
{/* Bouton qui lors du clique nous redirige vers la connexion */}
<Nav.Link onClick={navigateToLogin} style={{ color: theme.colors.text }}>
<span>
<img src={user?.profilePicture} height="50" width="50" alt="profile"/>
{user && user.pseudo}
</span>
</Nav.Link>
</>
)}
</Nav>
</div>
</Navbar.Collapse>

@ -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 */

@ -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,154 +19,345 @@ 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<any>(null);
const [dailyEasyEnigmaStats, setDailyEasyEnigmaStats] = useState<any>(null);
const [dailyMediumEnigmaStats, setDailyMediumEnigmaStats] = useState<any>(null);
const [dailyHardEnigmaStats, setDailyHardEnigmaStats] = useState<any>(null);
const [dailyOnlineStats, setDailyOnlineStats] = useState<any>(null);
// WEEKLY STATS
const [weeklyMastermindStats, setWeeklyMastermindStats] = useState<any>(null);
const [weeklyEasyEnigmaStats, setWeeklyEasyEnigmaStats] = useState<any>(null);
const [weeklyMediumEnigmaStats, setWeeklyMediumEnigmaStats] = useState<any>(null);
const [weeklyHardEnigmaStats, setWeeklyHardEnigmaStats] = useState<any>(null);
const [weeklyOnlineStats, setWeeklyOnlineStats] = useState<any>(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 (
// <div className='LeaderBoardiv'>
<div className='LeaderBoardiv'>
<Tabs style={{width:"100%"}}
defaultActiveKey="daily"
id="ScoreBoard"
className="mb-3">
<Tab eventKey="perso" title="Vos Stats" disabled = { !Player.pseudo.startsWith("Guest_") ? false : true}>
<Container fluid>
<Row>Stats en MasterMind :</Row>
<Row>
<Col sm={10}>Partie Jouées :</Col>
<Col className='leftRow'>{Player !== null ? Player.mastermindStats.nbGames : "0"}</Col>
</Row>
<Row>
<Col sm={10}>Best-Score :</Col>
<Col className='leftRow'>{Player !== null ? Player.mastermindStats.bestScore : "0"}</Col>
</Row>
<Row>
<Col sm={10}>Moyenne d'essai :</Col>
<Col className='leftRow'>{Player !== null ? Player.mastermindStats.avgNbTry : "0"}</Col>
</Row>
<hr/>
<Row>Stats en Enigme facile :</Row>
<Row>
<Col sm={10}>Partie jouée :</Col>
<Col className='leftRow'>{Player !== null ? Player.easyEnigmaStats.nbGames : "0"}</Col>
</Row>
<Row>
<Col sm={10}>Nombre de victoire :</Col>
<Col className='leftRow'>{Player !== null ? Player.easyEnigmaStats.nbWins : "0"}</Col>
</Row>
<Row>
<Col sm={10}>Ratio V/D :</Col>
<Col className='leftRow'>{Player !== null ? Player.easyEnigmaStats.ratio.toFixed(2) + "%" : "00.0%"}</Col>
</Row>
<Row>
<Col sm={10}>Meilleur temps :</Col>
<Col className='leftRow'>{Player !== null ? Player.easyEnigmaStats.bestTime : "0"}</Col>
</Row>
<Row>
<Col sm={10}>Moyenne de temps :</Col>
<Col className='leftRow'>{Player !== null ? Player.easyEnigmaStats.avgTime.toFixed(2) : "0"}</Col>
</Row>
<hr/>
<Row>Stats en Enigme moyenne :</Row>
<Row>
<Col sm={10}>Partie jouée :</Col>
<Col className='leftRow'>{Player !== null ? Player.mediumEnigmaStats.nbGames : "0"}</Col>
</Row>
<Row>
<Col sm={10}>Best-Score :</Col>
<Col className='leftRow'>{Player !== null ? Player.mediumEnigmaStats.bestScore : "0"}</Col>
</Row>
<Row>
<Col sm={10}>Moyenne d'essai :</Col>
<Col className='leftRow'>{Player !== null ? Player.mediumEnigmaStats.avgNbTry.toFixed(2) : "0"}</Col>
</Row>
<hr/>
<Row>Stats en Enigme difficile :</Row>
<Row>
<Col sm={10}>Partie jouée :</Col>
<Col className='leftRow'>{Player !== null ? Player.hardEnigmaStats.nbGames : "0"}</Col>
</Row>
<Row>
<Col sm={10}>Nombre de victoire :</Col>
<Col className='leftRow'>{Player !== null ? Player.hardEnigmaStats.nbWins : "0"}</Col>
</Row>
<Row>
<Col sm={10}>Ratio V/D :</Col>
<Col className='leftRow'>{Player !== null ? Player.hardEnigmaStats.ratio.toFixed(2) + "%" : "00.0%"}</Col>
</Row>
<Row>
<Col sm={10}>Meilleur temps :</Col>
<Col className='leftRow'>{Player !== null ? Player.hardEnigmaStats.bestTime : "0"}</Col>
</Row>
<Row>
<Col sm={10}>Moyenne de temps :</Col>
<Col className='leftRow'>{Player !== null ? Player.hardEnigmaStats.avgTime.toFixed(2) : "0"}</Col>
</Row>
<hr/>
<Row>Stats en ligne :</Row>
<Row>
<Col sm={10}>Partie jouée :</Col>
<Col className='leftRow'>{Player !== null ? Player.onlineStats.nbGames : "0"}</Col>
</Row>
<Row>
<Col sm={10}>Nombre de victoire :</Col>
<Col className='leftRow'>{Player !== null ? Player.onlineStats.nbWins : "0"}</Col>
</Row>
<Row>
<Col sm={10}>Ratio V/D :</Col>
<Col className='leftRow'>{Player !== null ? Player.onlineStats.ratio.toFixed(2) + "%" : "0"}</Col>
</Row>
</Container>
</Tab>
<Tab eventKey="daily" title="Daily"
style={{display:"flex", flexDirection:'column', alignItems:'center'}}>
<img src={trophy}
height='100'
width='100'
alt="Person2"/>
<Container fluid>
<Row>
<Col sm={8}>Partie Jouées :</Col>
<Col className='leftRow'>10</Col>
</Row>
<Row>
<Col sm={8}>Partie gagnées :</Col>
<Col className='leftRow'>2</Col>
</Row>
<Row>
<Col sm={8}>Pions posés :</Col>
<Col className='leftRow'>2</Col>
</Row>
<hr/>
<Row>
<Col sm={8}>Partie solo :</Col>
<Col className='leftRow'>21</Col>
</Row>
<Row>
<Col sm={8}>Nombre de coups moyen :</Col>
<Col className='leftRow'>19</Col>
</Row>
</Container>
</Tab>
<Tab eventKey="weekly" title="Weekly">
<img src={trophy}
height='100'
width='100'
alt="Person2"/>
</Tab>
</Tabs>
<ButtonImgNav dest='/' img={share}/>
</div>
//</div>
<Tabs
activeKey={activeTab}
onSelect={(key:any) => {
setActiveTab(key);
// Forcer une mise à jour du carousel
setCarouselKey((prevKey) => prevKey + 1);
}}
id="ScoreBoard"
className="tabsStats justify-content-around">
<Tab eventKey="perso" title="Vos Stats" disabled={!Player.pseudo.startsWith("Guest_") ? false : true}>
<Tab.Content className={`tabsStats ${activeTab !== 'perso' ? 'hidden' : ''}`}>
<Carousel adaptiveHeight wrapAround slidesToShow={1} cellSpacing={10} key={carouselKey}>
<div className="stats">
<h5>Mastermind</h5>
<hr />
<p>Parties Jouées: {Player.mastermindStats.nbGames}</p>
<p>Best-Score: {Player.mastermindStats.bestScore}</p>
<p>Moyenne d'essai: {Player.mastermindStats.avgNbTry.toFixed(2)}</p>
</div>
<div className="stats">
<h5>Enigme facile</h5>
<hr />
<p>Parties Jouées: {Player.easyEnigmaStats.nbGames}</p>
<p>Nombre de victoires: {Player.easyEnigmaStats.nbWins}</p>
<p>Ratio V/D: {Player.easyEnigmaStats.ratio.toFixed(2) + "%"}</p>
<p>Meilleur temps: {Player.easyEnigmaStats.bestTime + "s"}</p>
<p>Moyenne de temps: {Player.easyEnigmaStats.avgTime.toFixed(2) + "s"}</p>
</div>
<div className="stats">
<h5>Enigme moyenne</h5>
<hr />
<p>Parties Jouées: {Player.mediumEnigmaStats.nbGames}</p>
<p>Best-Score: {Player.mediumEnigmaStats.bestScore}</p>
<p>Moyenne d'essai: {Player.mediumEnigmaStats.avgNbTry.toFixed(2)}</p>
</div>
<div className="stats">
<h5>Enigme difficile</h5>
<hr />
<p>Parties Jouées: {Player.hardEnigmaStats.nbGames}</p>
<p>Nombre de victoires: {Player.hardEnigmaStats.nbWins}</p>
<p>Ratio V/D: {Player.hardEnigmaStats.ratio.toFixed(2) + "%"}</p>
<p>Meilleur temps: {Player.hardEnigmaStats.bestTime + "s"}</p>
<p>Moyenne de temps: {Player.hardEnigmaStats.avgTime.toFixed(2) + "s"}</p>
</div>
<div className="stats">
<h5>En ligne</h5>
<hr />
<p>Parties Jouées: {Player.onlineStats.nbGames}</p>
<p>Nombre de victoires: {Player.onlineStats.nbWins}</p>
<p>Ratio V/D: {Player.onlineStats.ratio.toFixed(2) + "s"}</p>
</div>
</Carousel>
</Tab.Content>
</Tab>
<Tab eventKey="daily" title="Daily">
<Tab.Content className={`tabsStats ${activeTab !== 'daily' ? 'hidden' : ''}`}>
<Carousel adaptiveHeight wrapAround slidesToShow={1} cellSpacing={10} key={carouselKey}>
<div className="stats">
<h5>Mastermind</h5>
<hr />
{dailyMastermindStats !== null ? (dailyMastermindStats.tab.length !== 0 ? dailyMastermindStats.tab.map((stats: any, index: number) => (
<>
<Row>
<Col>
<p>{index+1}.{stats.pseudo}</p>
</Col>
<Col>
<p>{stats.score + " essai(s)"}</p>
</Col>
</Row>
</>
)) : (
<p className='text-warning'>Nothing for the moment</p>
)) : (
<p className='text-warning'>Nothing for the moment</p>
)}
</div>
<div className="stats">
<h5>Enigme facile</h5>
<hr />
{dailyEasyEnigmaStats !== null ? (dailyEasyEnigmaStats.tab.length !== 0 ? dailyEasyEnigmaStats.tab.map((stats: any, index: number) => (
<>
<Row>
<Col>
<p>{index+1}.{stats.pseudo}</p>
</Col>
<Col>
<p>{stats.time + "s"}</p>
</Col>
</Row>
</>
)) : (
<p className='text-warning'>Nothing for the moment</p>
)) : (
<p className='text-warning'>Nothing for the moment</p>
)}
</div>
<div className="stats">
<h5>Enigme moyenne</h5>
<hr />
{dailyMediumEnigmaStats !== null ? (dailyMediumEnigmaStats.tab.length !== 0 ? dailyMediumEnigmaStats.tab.map((stats: any, index: number) => (
<>
<Row>
<Col>
<p>{index+1}.{stats.pseudo}</p>
</Col>
<Col>
<p>{stats.time + "s"}</p>
</Col>
</Row>
</>
)) : (
<p className='text-warning'>Nothing for the moment</p>
)) : (
<p className='text-warning'>Nothing for the moment</p>
)}
</div>
<div className="stats">
<h5>Enigme difficile</h5>
<hr />
{dailyHardEnigmaStats !== null ? (dailyHardEnigmaStats.tab.length !== 0 ? dailyHardEnigmaStats.tab.map((stats: any, index: number) => (
<>
<Row>
<Col>
<p>{index+1}.{stats.pseudo}</p>
</Col>
<Col>
<p>{stats.time + "s"}</p>
</Col>
</Row>
</>
)) : (
<p className='text-warning'>Nothing for the moment</p>
)) : (
<p className='text-warning'>Nothing for the moment</p>
)}
</div>
<div className="stats">
<h5>En ligne</h5>
<hr />
{dailyOnlineStats !== null ? (dailyOnlineStats.tab.length !== 0 ? dailyOnlineStats.tab.map((stats: any, index: number) => (
<>
<Row>
<Col>
<p>{index+1}.{stats.pseudo}</p>
</Col>
<Col>
<p>{stats.wins + " victoires"}</p>
</Col>
</Row>
</>
)) : (
<p className='text-warning'>Nothing for the moment</p>
)) : (
<p className='text-warning'>Nothing for the moment</p>
)}
</div>
</Carousel>
</Tab.Content>
</Tab>
<Tab eventKey="weekly" title="Weekly">
<Tab.Content className={`tabsStats ${activeTab !== 'weekly' ? 'hidden' : ''}`}>
<Carousel adaptiveHeight wrapAround slidesToShow={1} cellSpacing={10} key={carouselKey}>
<div className="stats">
<h5>Mastermind</h5>
<hr />
{weeklyMastermindStats !== null ? (weeklyMastermindStats.tab.length !== 0 ? weeklyMastermindStats.tab.map((stats: any, index: number) => (
<>
<Row>
<Col>
<p>{index+1}.{stats.pseudo}</p>
</Col>
<Col>
<p>{stats.score + " essai(s)"}</p>
</Col>
</Row>
</>
)) : (
<p className='text-warning'>Nothing for the moment</p>
)) : (
<p className='text-warning'>Nothing for the moment</p>
)}
</div>
<div className="stats">
<h5>Enigme facile</h5>
<hr />
{weeklyEasyEnigmaStats !== null ? (weeklyEasyEnigmaStats.tab.length !== 0 ? weeklyEasyEnigmaStats.tab.map((stats: any, index: number) => (
<>
<Row>
<Col>
<p>{index+1}.{stats.pseudo}</p>
</Col>
<Col>
<p>{stats.time + "s"}</p>
</Col>
</Row>
</>
)) : (
<p className='text-warning'>Nothing for the moment</p>
)) : (
<p className='text-warning'>Nothing for the moment</p>
)}
</div>
<div className="stats">
<h5>Enigme moyenne</h5>
<hr />
{weeklyMediumEnigmaStats !== null ? (weeklyMediumEnigmaStats.tab.length !== 0 ? weeklyMediumEnigmaStats.tab.map((stats: any, index: number) => (
<>
<Row>
<Col>
<p>{index+1}.{stats.pseudo}</p>
</Col>
<Col>
<p>{stats.time + "s"}</p>
</Col>
</Row>
</>
)) : (
<p className='text-warning'>Nothing for the moment</p>
)) : (
<p className='text-warning'>Nothing for the moment</p>
)}
</div>
<div className="stats">
<h5>Enigme difficile</h5>
<hr />
{weeklyHardEnigmaStats !== null ? (weeklyHardEnigmaStats.tab.length !== 0 ? weeklyHardEnigmaStats.tab.map((stats: any, index: number) => (
<>
<Row>
<Col>
<p>{index+1}.{stats.pseudo}</p>
</Col>
<Col>
<p>{stats.time + "s"}</p>
</Col>
</Row>
</>
)) : (
<p className='text-warning'>Nothing for the moment</p>
)) : (
<p className='text-warning'>Nothing for the moment</p>
)}
</div>
<div className="stats">
<h5>En ligne</h5>
<hr />
{weeklyOnlineStats !== null ? (weeklyOnlineStats.tab.length !== 0 ? weeklyOnlineStats.tab.map((stats: any, index: number) => (
<>
<Row>
<Col>
<p>{index+1}.{stats.pseudo}</p>
</Col>
<Col>
<p>{stats.wins + " victoires"}</p>
</Col>
</Row>
</>
)) : (
<p className='text-warning'>Nothing for the moment</p>
)) : (
<p className='text-warning'>Nothing for the moment</p>
)}
</div>
</Carousel>
</Tab.Content>
</Tab>
</Tabs>
);
}

@ -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) => {

@ -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}) {
<section id="composants-du-jeu">
<h2><FormattedMessage id="info.pions"/> :</h2>
<h4>
<FormattedMessage id="info.sommaire"/>
</h4>
<h6><FormattedMessage id="info.composant.text"/></h6>
<h4><FormattedMessage id="info.sommaire"/></h4>
<h6><FormattedMessage id="info.composant.text"/></h6>
<ul>
<p>
<li><h5 className='h5title'><FormattedMessage id="info.composant.carre.title"/> : 🟪🟦🟩🟨🟥🟫</h5></li>
@ -73,7 +91,6 @@ function InfoPage({locale, changeLocale}) {
<li><h5 className='h5title'><FormattedMessage id="info.composant.rond.title"/> : 🟣🔵🟢🟡🔴🟤</h5></li>
<FormattedMessage id="info.composant.rond"/>
</p>
</ul>
<hr/>
<h4>
<FormattedMessage id="info.car_perso"/>
@ -122,6 +139,7 @@ function InfoPage({locale, changeLocale}) {
</ul>
<FormattedMessage id="info.composant.sport.bis"/>
</p>
</ul>
</section>
<hr/>
<section id="objectif-du-jeu">
@ -270,7 +288,6 @@ function InfoPage({locale, changeLocale}) {
<FormattedMessage id="info.indice-possible.voisin"/>
</h4>
<IndiceList instance={EdgesIndice} lang={locale}/>
<IndiceList instance={NbEdgesIndice} lang={locale}/>
<hr/>
</section>
</div>

@ -4,14 +4,14 @@ 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<string | null>(null);
const {login} = useAuth();
const [showConfirmation, setShowConfirmation] = useState(false);
const handleSubmit = async (event: React.FormEvent) => {
@ -80,7 +80,7 @@ const SignIn = () => {
</button>
</div>
<p className="forgot-password text-right">
<a href="#">Mot de passe</a> oublié ?
<Link to={`${basePath}/signup`}>Pas encore inscrit ?</Link>
</p>
</form>

@ -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 (
<div className="MainContainer">
<div className="NewleftContainer">
{/* Menu de boutons */}
<div className="leftContainer">
{/* Boutons pour jouer */}
<div className='NewbuttonGroupVertical'>
<button onClick={launchMastermind} className="ButtonNav" style={{backgroundColor: theme.colors.primary, borderColor: theme.colors.secondary}}> Jouer seul </button>
<button ref={target} onClick={launchEngimeJour} className="ButtonNav" style={{backgroundColor: theme.colors.primary, borderColor: theme.colors.secondary}}> Résoudre une énigme</button>
<Overlay show={showOverlay} target={target.current} placement="bottom" rootClose={true} rootCloseEvent='click'>
{({ placement, arrowProps, show: _show, popper, ...props }) => (
@ -233,7 +228,7 @@ function NewPlay() {
<button onClick={launchTuto} className="ButtonNav" style={{backgroundColor: theme.colors.primary, borderColor: theme.colors.secondary}}> Tutoriel </button>
{/* <button onClick= {() => navigate("/join")} className="ButtonNav" style={{backgroundColor: theme.colors.primary, borderColor: theme.colors.secondary}}> Rejoindre </button> */}
{/* {goBackRoom != -1 && <button onClick={goBack} className="ButtonNav" style={{backgroundColor: theme.colors.primary, borderColor: theme.colors.secondary}}>Retourner à la partie</button>} */}
<button onClick={goBack} className="ButtonNavRejoin" style={{ visibility:returnVisibility}}>Retourner à la partie</button>
<button onClick={goBack} className="ButtonNavRejoin" style={{ display:returnVisibility}}>Retourner à la partie</button>
</div>
@ -241,20 +236,10 @@ function NewPlay() {
<div style={{border:'solid 1px lightgray', borderRadius:'15px', marginTop:'20px'}}>
<Lobbies/>
</div>
</div>
<div className='NewrightContainer'>
<div style={{ border:'solid 2px lightgray', borderRadius:'15px', display:'flex', justifyContent:'center', alignItems:'center', flexDirection:'column', padding:'20px', margin:'20px 0px'}}>
<h2>
{user && user.pseudo}
</h2>
<img src={user?.profilePicture}
height='150'
width='150'
alt="Person"
/>
</div>
{user && (<ScoreBoard Player={user}/>)}
<div className='rightContainer'>
{user && <ScoreBoard Player={user}/>}
</div>
</div>
);

@ -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;
font-weight: 500;
}

@ -1,6 +1,5 @@
.mainContainer{
display: flex;
/* flex-direction: column; */
justify-content: center;
align-items: center;
margin: 50px;

@ -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 = () => {
</Modal>
</>
</div>
</div>
{/* Bouton de déconnexion */}
<div className='logout'>
<Button variant="warning" onClick={handleLogout}>Déconnexion</Button>
</div>
</div>
</>

@ -9,7 +9,6 @@ import {basePath} from "../AdressSetup"
const SignUp = () => {
const navigate = useNavigate();
const [error, setError] = useState<string | null>(null);
const [showConfirmation, setShowConfirmation] = useState(false);

@ -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;

@ -165,7 +165,6 @@ class SessionService {
throw error;
}
}
}
export default SessionService;

@ -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==

Loading…
Cancel
Save