log color to fix
This commit is contained in:
parent
8ebeabb386
commit
49d73b92d3
@ -455,6 +455,8 @@ export class AppController {
|
|||||||
user.sessionNumber-- ;
|
user.sessionNumber-- ;
|
||||||
if (!user.sessionNumber)
|
if (!user.sessionNumber)
|
||||||
user.status = 0;
|
user.status = 0;
|
||||||
|
console.log("quit sessionNUmber :",user.sessionNumber);
|
||||||
|
|
||||||
await this.userService.save(user);
|
await this.userService.save(user);
|
||||||
console.log("User quit");
|
console.log("User quit");
|
||||||
}
|
}
|
||||||
@ -465,6 +467,8 @@ export class AppController {
|
|||||||
|
|
||||||
const user = await this.userService.findOne(req.user.username);
|
const user = await this.userService.findOne(req.user.username);
|
||||||
user.sessionNumber++ ;
|
user.sessionNumber++ ;
|
||||||
|
console.log("addSession sessionNUmber :",user.sessionNumber);
|
||||||
|
|
||||||
await this.userService.save(user);
|
await this.userService.save(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -28,7 +28,7 @@ export class loginClass {
|
|||||||
code: code,
|
code: code,
|
||||||
redirect_uri: process.env.REDIRECT_URI || 'http://' + process.env.REACT_APP_BASE_URL + '/api/auth/login',
|
redirect_uri: process.env.REDIRECT_URI || 'http://' + process.env.REACT_APP_BASE_URL + '/api/auth/login',
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await axios.post('https://api.intra.42.fr/oauth/token', data);
|
const response = await axios.post('https://api.intra.42.fr/oauth/token', data);
|
||||||
token = response.data.access_token;
|
token = response.data.access_token;
|
||||||
@ -74,14 +74,14 @@ export class loginClass {
|
|||||||
friends: null,
|
friends: null,
|
||||||
blocked: null,
|
blocked: null,
|
||||||
photo: null,
|
photo: null,
|
||||||
sessionNumber: 0,
|
sessionNumber: 1,
|
||||||
};
|
};
|
||||||
await this.usersService.create(user);
|
await this.usersService.create(user);
|
||||||
}
|
}
|
||||||
// if (user.status !== 2 || user.status === 0) //super
|
// if (user.status !== 2) //super
|
||||||
// user.status = 1;
|
// user.status = 1;
|
||||||
// user.sessionNumber++;
|
// user.sessionNumber++;
|
||||||
// console.log(`in login42 user= ${user}`)
|
console.log(user.sessionNumber);
|
||||||
const myJSON = JSON.stringify(user);
|
const myJSON = JSON.stringify(user);
|
||||||
console.log(`in login42 user= ${myJSON}`)
|
console.log(`in login42 user= ${myJSON}`)
|
||||||
|
|
||||||
|
|||||||
@ -58,7 +58,7 @@ export class UsersService {
|
|||||||
|
|
||||||
async getFriends(username: string) {
|
async getFriends(username: string) {
|
||||||
const user = await this.findOne(username)
|
const user = await this.findOne(username)
|
||||||
let friendsTab = user.friends
|
let friendsTab = user.friends || []
|
||||||
console.log(friendsTab)
|
console.log(friendsTab)
|
||||||
// friendsTab = ['apommier', 'syd']
|
// friendsTab = ['apommier', 'syd']
|
||||||
const friends = await this.userRepository.query("SELECT * FROM \"User\" WHERE username = ANY ($1);", [friendsTab]);
|
const friends = await this.userRepository.query("SELECT * FROM \"User\" WHERE username = ANY ($1);", [friendsTab]);
|
||||||
|
|||||||
@ -16,6 +16,7 @@ export interface User {
|
|||||||
partyInvite: Record<string, string>[];
|
partyInvite: Record<string, string>[];
|
||||||
friends: string[];
|
friends: string[];
|
||||||
blocked: string[];
|
blocked: string[];
|
||||||
|
sessionNumber: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Conv {
|
export interface Conv {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import React, { useEffect } from "react";
|
import React, { useEffect } from "react";
|
||||||
import {Routes, Route, Navigate} from 'react-router-dom';
|
import { Routes, Route, Navigate } from 'react-router-dom';
|
||||||
import HomeLogin from "../pages/LoginButton.tsx";
|
import HomeLogin from "../pages/LoginButton.tsx";
|
||||||
|
|
||||||
import Home from "../pages/Home.tsx";
|
import Home from "../pages/Home.tsx";
|
||||||
@ -10,7 +10,7 @@ import Login42 from "../pages/Login42.tsx";
|
|||||||
import Messages from "../pages/Messages.tsx";
|
import Messages from "../pages/Messages.tsx";
|
||||||
import QrCode from '../pages/QrCode.tsx'
|
import QrCode from '../pages/QrCode.tsx'
|
||||||
import { useLocation } from "react-router-dom";
|
import { useLocation } from "react-router-dom";
|
||||||
import {AnimatePresence} from "framer-motion";
|
import { AnimatePresence } from "framer-motion";
|
||||||
|
|
||||||
import SuccessToken from '../script/tokenSuccess.tsx'
|
import SuccessToken from '../script/tokenSuccess.tsx'
|
||||||
|
|
||||||
@ -22,40 +22,59 @@ import Logout from "./Profile/Logout.tsx";
|
|||||||
import api from "../script/axiosApi.tsx"
|
import api from "../script/axiosApi.tsx"
|
||||||
|
|
||||||
|
|
||||||
function AnimatedRoute () {
|
function AnimatedRoute() {
|
||||||
// const location = useLocation();
|
// const location = useLocation();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleBeforeUnload = async (event: { preventDefault: () => void; returnValue: string; }) => {
|
const handleBeforeUnload = async (event: { preventDefault: () => void; returnValue: string; }) => {
|
||||||
if (!localStorage.getItem('token'))
|
if (!localStorage.getItem('token'))
|
||||||
return ;
|
return;
|
||||||
try {
|
try {
|
||||||
await api.post("/quit");
|
await api.post("/quit");
|
||||||
} catch(err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
window.addEventListener('beforeunload', handleBeforeUnload);
|
|
||||||
|
|
||||||
|
window.addEventListener('beforeunload', handleBeforeUnload);
|
||||||
return () => {
|
return () => {
|
||||||
window.removeEventListener('beforeunload', handleBeforeUnload);
|
window.removeEventListener('beforeunload', handleBeforeUnload);
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
|
||||||
|
const handleLoad = async () => {
|
||||||
|
console.log('Page loaded');
|
||||||
|
console.log("je suis a addSession");
|
||||||
|
if (!localStorage.getItem('token'))
|
||||||
|
return;
|
||||||
|
try {
|
||||||
|
await api.post("/addSession");
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
window.addEventListener('load', handleLoad);
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener('load', handleLoad);
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
if (!localStorage.getItem('token'))
|
if (!localStorage.getItem('token')) {
|
||||||
{
|
|
||||||
return (
|
return (
|
||||||
<AnimatePresence>
|
<AnimatePresence>
|
||||||
<Routes location={location} key={location.pathname}>
|
<Routes location={location} key={location.pathname}>
|
||||||
<Route path="/" element={<HomeLogin/>}/>
|
<Route path="/" element={<HomeLogin />} />
|
||||||
<Route path="/token" element={<SuccessToken />}/>
|
<Route path="/token" element={<SuccessToken />} />
|
||||||
|
|
||||||
{/* <Route path="/404" element={<HomeLogin/>} /> */}
|
{/* <Route path="/404" element={<HomeLogin/>} /> */}
|
||||||
{/* <Route path="*" element={<Navigate to="/404" />} /> */}
|
{/* <Route path="*" element={<Navigate to="/404" />} /> */}
|
||||||
</Routes>
|
</Routes>
|
||||||
</AnimatePresence>
|
</AnimatePresence>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,26 +83,26 @@ function AnimatedRoute () {
|
|||||||
<Routes location={location} key={location.pathname}>
|
<Routes location={location} key={location.pathname}>
|
||||||
|
|
||||||
{/* <Route path="/login" element={<HomeLogin/>}/> */}
|
{/* <Route path="/login" element={<HomeLogin/>}/> */}
|
||||||
<Route path="/" element={<Home/>}/>
|
<Route path="/" element={<Home />} />
|
||||||
<Route path="/profile" element={<Home/>}/>
|
<Route path="/profile" element={<Home />} />
|
||||||
<Route path="/profile/:username" element={<Home/>}/>
|
<Route path="/profile/:username" element={<Home />} />
|
||||||
<Route path="/qr" element={<QrCode/>}/>
|
<Route path="/qr" element={<QrCode />} />
|
||||||
|
|
||||||
<Route path="/2fa" element={<DoubleAuth/>}/>
|
<Route path="/2fa" element={<DoubleAuth />} />
|
||||||
<Route path="/Social" element={<Social/>}/>
|
<Route path="/Social" element={<Social />} />
|
||||||
|
|
||||||
<Route path="/token" element={<SuccessToken />}/>
|
<Route path="/token" element={<SuccessToken />} />
|
||||||
<Route path="/game" element={<PlayButton />}/>
|
<Route path="/game" element={<PlayButton />} />
|
||||||
<Route path="/pong" element={<Game />}/>
|
<Route path="/pong" element={<Game />} />
|
||||||
<Route path="/pong/play" element={<Field />}/>
|
<Route path="/pong/play" element={<Field />} />
|
||||||
{/* <Route path="/profile" element={<PlayButton />}/> */}
|
{/* <Route path="/profile" element={<PlayButton />}/> */}
|
||||||
|
|
||||||
<Route path="/login42" element={<Login42 />}/>
|
<Route path="/login42" element={<Login42 />} />
|
||||||
<Route path="/logout" element={<Logout />}/>
|
<Route path="/logout" element={<Logout />} />
|
||||||
<Route path="/messages" element={<Messages />}/>
|
<Route path="/messages" element={<Messages />} />
|
||||||
|
|
||||||
<Route path="/404" element={<PageNotFound />} />
|
<Route path="/404" element={<PageNotFound />} />
|
||||||
<Route path="*" element={<Navigate to="/404" />} />
|
<Route path="*" element={<Navigate to="/404" />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
</AnimatePresence>
|
</AnimatePresence>
|
||||||
)
|
)
|
||||||
|
|||||||
@ -79,11 +79,7 @@ const GameModal = ({ handleClose }: ModalGame) => {
|
|||||||
path += 'superpower=true&';
|
path += 'superpower=true&';
|
||||||
}
|
}
|
||||||
|
|
||||||
const obstacleCheckbox = document.querySelector<HTMLInputElement>('input[value="obstacle"]');
|
|
||||||
if (obstacleCheckbox && obstacleCheckbox.checked) {
|
|
||||||
path += 'obstacle=true&';
|
|
||||||
}
|
|
||||||
|
|
||||||
const speedCheckbox = document.querySelector<HTMLInputElement>('input[value="speed"]');
|
const speedCheckbox = document.querySelector<HTMLInputElement>('input[value="speed"]');
|
||||||
if (speedCheckbox && speedCheckbox.checked) {
|
if (speedCheckbox && speedCheckbox.checked) {
|
||||||
path += 'speed=true&';
|
path += 'speed=true&';
|
||||||
@ -132,10 +128,9 @@ const GameModal = ({ handleClose }: ModalGame) => {
|
|||||||
{/* <button onClick={handleButtonClick}>Draw on Canvas</button> */}
|
{/* <button onClick={handleButtonClick}>Draw on Canvas</button> */}
|
||||||
<div className='checkbox'>
|
<div className='checkbox'>
|
||||||
<p><input type="checkbox" value="superpower"/> Super Power </p>
|
<p><input type="checkbox" value="superpower"/> Super Power </p>
|
||||||
<p><input type="checkbox" value="obstacle"/> Obstacle </p>
|
|
||||||
<p><input type="checkbox" value="speed"/> Faster and Faster </p>
|
<p><input type="checkbox" value="speed"/> Faster and Faster </p>
|
||||||
</div>
|
</div>
|
||||||
<button className="submit" onClick={handleButtonClick} >Play</button>
|
<button className="playInvite" onClick={handleButtonClick} >Play</button>
|
||||||
{/* <button className="submit" onClick={handleClose}>Cancel</button> */}
|
{/* <button className="submit" onClick={handleClose}>Cancel</button> */}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -65,7 +65,9 @@ export default function Friend({currentUser}: UserProps)
|
|||||||
|
|
||||||
function getStatus(friend: User)
|
function getStatus(friend: User)
|
||||||
{
|
{
|
||||||
let status = friend.status
|
let status = friend.status
|
||||||
|
let session =friend.sessionNumber
|
||||||
|
console.log(`session= ${session}`)
|
||||||
console.log(`status= ${status}`)
|
console.log(`status= ${status}`)
|
||||||
let statusColor;
|
let statusColor;
|
||||||
|
|
||||||
|
|||||||
@ -94,7 +94,7 @@ export default function Friend({currentUser}: UserProps)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<UserChat>
|
<UserChat className="centermargin">
|
||||||
{profilePicture ? (
|
{profilePicture ? (
|
||||||
<img className="pic-user" src={`data:image/jpeg;base64,${profilePicture}`} />
|
<img className="pic-user" src={`data:image/jpeg;base64,${profilePicture}`} />
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@ -222,6 +222,16 @@ p {
|
|||||||
height: 25px;
|
height: 25px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.playInvite{
|
||||||
|
margin: 5%;
|
||||||
|
color: ghostwhite;
|
||||||
|
outline: 0;
|
||||||
|
border-radius: 100px;
|
||||||
|
padding: 3%;
|
||||||
|
background-image: linear-gradient(90deg, #5843e4, #5a0760);
|
||||||
|
width: 42%;
|
||||||
|
font-size: x-large;
|
||||||
|
}
|
||||||
.darkSubmit{
|
.darkSubmit{
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
color: white;
|
color: white;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user