delete all console log, hide join when pass
This commit is contained in:
parent
49f3626948
commit
00a8c9567f
@ -6,7 +6,7 @@
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/06/17 01:00:00 by apommier #+# #+# */
|
||||
/* Updated: 2023/06/28 16:50:11 by apommier ### ########.fr */
|
||||
/* Updated: 2023/06/28 17:43:13 by apommier ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -50,7 +50,6 @@ export class AppController {
|
||||
@Post('/logout')
|
||||
async logout(@Request() req, @Body() data: any) {
|
||||
const user = await this.userService.findOne(req.user.username)
|
||||
// return await this.userService.refuseInvite(user, data.username);
|
||||
if(!user)
|
||||
return ;
|
||||
if (user.sessionNumber === 1)
|
||||
@ -304,7 +303,6 @@ export class AppController {
|
||||
return ;
|
||||
if (user.sessionNumber > 0)
|
||||
user.sessionNumber--;
|
||||
console.log("seesion number=", user.sessionNumber)
|
||||
if (!user.sessionNumber)
|
||||
user.status = 0;
|
||||
await this.userService.save(user);
|
||||
@ -423,15 +421,12 @@ export class AppController {
|
||||
text: data.text,
|
||||
id: null,
|
||||
}
|
||||
console.log(data);
|
||||
return await this.chatService.createMessage(message, req.user.username);
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Post('/member')
|
||||
async getMember(@Body() data: any) {
|
||||
console.log(data);
|
||||
console.log(`get member= ${data.convId}`);
|
||||
return await this.chatService.findConv(data.convId);
|
||||
}
|
||||
|
||||
@ -450,14 +445,12 @@ export class AppController {
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Post('/password')
|
||||
async setPassword(@Body() data: any) {
|
||||
// console.log("PASSSSSSSSSSSSSSSSSSSSSSSSSSs= ", data.password);
|
||||
return await this.chatService.setPassword(data.convId, data.password)
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Post('/verifyPassword')
|
||||
async verifyPassword(@Request() req, @Body() data: any) {
|
||||
// const user = await this.userService.findOne(req.user.username);
|
||||
return await this.chatService.verifyPassword(data.convId, data.password, req.user.username)
|
||||
}
|
||||
|
||||
@ -494,7 +487,6 @@ export class AppController {
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Post('/isAdmin')
|
||||
async isAdmin(@Request() req, @Body() data: any) {
|
||||
console.log("isdamin= ", req.user.username, " id=", data.convId)
|
||||
return await this.chatService.isAdmin(data.convId, req.user.username)
|
||||
}
|
||||
|
||||
|
||||
@ -21,12 +21,7 @@ export class AuthService {
|
||||
}
|
||||
|
||||
async login(user: User) {
|
||||
// const myJSON = JSON.stringify(user);
|
||||
// console.log(`in login all user= ${myJSON}`)
|
||||
console.log(`in login user= ${user.username}`)
|
||||
const payload = { username: user.username, sub: user.userId };
|
||||
console.log(`in login payload name= ${payload.username}`)
|
||||
console.log(`in login payload sub= ${payload.sub}`)
|
||||
return {
|
||||
access_token: this.jwtService.sign(payload),
|
||||
};
|
||||
|
||||
@ -14,8 +14,6 @@ export class JwtStrategy extends PassportStrategy(Strategy) {
|
||||
}
|
||||
|
||||
async validate(payload: any) {
|
||||
console.log("in validate function")
|
||||
console.log(`userid= ${payload.sub} nickname= ${payload.username}`)
|
||||
return { userId: payload.sub, username: payload.username };
|
||||
}
|
||||
}
|
||||
@ -55,7 +55,6 @@ export class loginClass {
|
||||
otp_base32: null,
|
||||
children: null,
|
||||
status: 1,
|
||||
// doubleAuth: 0,
|
||||
otp_enabled: false,
|
||||
otp_verified: false,
|
||||
friendRequest: null,
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/06/17 01:00:25 by apommier #+# #+# */
|
||||
/* Updated: 2023/06/26 10:17:36 by apommier ### ########.fr */
|
||||
/* Updated: 2023/06/28 17:43:35 by apommier ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -153,13 +153,11 @@ async isAdmin(convId: number, username: string) {
|
||||
conv.admin = conv.admin || [];
|
||||
if (conv.admin.find(item => item === username))
|
||||
return (1);
|
||||
console.log("nope");
|
||||
return (0);
|
||||
}
|
||||
|
||||
async setPrivate(convId: number, bool: boolean) {
|
||||
const conv = await this.findConv(convId);
|
||||
console.log("bool= ", bool);
|
||||
conv.private = bool;
|
||||
this.save(conv);
|
||||
}
|
||||
|
||||
@ -3,10 +3,10 @@
|
||||
/* ::: :::::::: */
|
||||
/* config.service.ts :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: sadjigui <sadjigui@student.42.fr> +#+ +:+ +#+ */
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/04/09 14:53:49 by apommier #+# #+# */
|
||||
/* Updated: 2023/06/24 15:09:20 by sadjigui ### ########.fr */
|
||||
/* Updated: 2023/06/28 17:41:26 by apommier ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -20,8 +20,6 @@ export const getTypeOrmConfig = (): TypeOrmModuleOptions => ({
|
||||
password: process.env.POSTGRES_PASSWORD || 'postgres',
|
||||
database: process.env.POSTGRES_DATABASE || 'postgres',
|
||||
entities: ["dist/**/*.entity.js"],
|
||||
// entities: [join(__dirname, '**', '*.entity.{ts,js}')]
|
||||
// entities: ['**/*.entity{.ts,.js}'], //basic
|
||||
migrationsTableName: 'migration',
|
||||
migrations: ['src/migration/*.ts'],
|
||||
ssl: process.env.MODE !== 'DEV',
|
||||
|
||||
@ -4,7 +4,6 @@ import * as session from 'express-session';
|
||||
import * as dotenv from 'dotenv';
|
||||
|
||||
dotenv.config();
|
||||
console.log(process.env);
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule, {
|
||||
|
||||
@ -1,19 +1,6 @@
|
||||
// item.entity.ts
|
||||
// import { BaseEntity } from './base.entity';
|
||||
|
||||
// @Column({ type: 'varchar', length: 300 , nullable: true})
|
||||
// name: string;
|
||||
|
||||
// @Column({ type: 'varchar', length: 300 , nullable: true})
|
||||
// description: string;
|
||||
|
||||
|
||||
import { Entity, Column, PrimaryGeneratedColumn } from 'typeorm';
|
||||
import { ManyToOne, OneToMany } from 'typeorm';
|
||||
|
||||
|
||||
|
||||
|
||||
@Entity({ name: 'User' })
|
||||
export class User {
|
||||
|
||||
@ -56,7 +43,7 @@ export class User {
|
||||
@Column({ default: 0 })
|
||||
rank: number;
|
||||
|
||||
@Column({ default: 0 }) //0 = offline | 1 = connected | 2 = in game
|
||||
@Column({ default: 0 })
|
||||
status: number;
|
||||
|
||||
@Column({ default: 0 })
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/06/17 01:00:07 by apommier #+# #+# */
|
||||
/* Updated: 2023/06/26 07:52:08 by apommier ### ########.fr */
|
||||
/* Updated: 2023/06/28 17:43:46 by apommier ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -59,7 +59,6 @@ export class UsersService {
|
||||
const user = await this.findOne(username)
|
||||
let friendsTab = user.friends || [];
|
||||
const friends = await this.userRepository.query("SELECT * FROM \"User\" WHERE username = ANY ($1);", [friendsTab]);
|
||||
console.log(friends)
|
||||
return (friends)
|
||||
}
|
||||
|
||||
@ -80,9 +79,7 @@ export class UsersService {
|
||||
async getInvite(username: string) {
|
||||
const user = await this.findOne(username)
|
||||
let friendsTab = user.friendRequest
|
||||
console.log(friendsTab)
|
||||
const friends = await this.userRepository.query("SELECT * FROM \"User\" WHERE username = ANY ($1);", [friendsTab]);
|
||||
console.log(friends)
|
||||
return (friends)
|
||||
}
|
||||
|
||||
|
||||
@ -76,8 +76,6 @@ banUser(client: any, payload: any): void {
|
||||
}
|
||||
const bannedClients = this.clientsNames.get(payload.username);
|
||||
bannedClients.forEach(client => {
|
||||
console.log("Banning client:", client);
|
||||
console.log("clietn socket=", this.clients[client])
|
||||
this.clients[client].emit('ban', payload);
|
||||
});
|
||||
}
|
||||
@ -106,8 +104,6 @@ muteUser(client: any, payload: any): void {
|
||||
{
|
||||
if (targetClient && targetClient !== client.id)
|
||||
this.clients[targetClient].emit('message', payload)
|
||||
else
|
||||
console.log("not sending");
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@ -6,7 +6,6 @@ import * as socketio from 'socket.io';
|
||||
import * as dotenv from 'dotenv';
|
||||
|
||||
dotenv.config();
|
||||
console.log(process.env);
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule, {
|
||||
|
||||
@ -4,7 +4,6 @@ import * as socketio from 'socket.io';
|
||||
import * as dotenv from 'dotenv';
|
||||
|
||||
dotenv.config();
|
||||
console.log(process.env);
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule, {
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/06/19 15:18:38 by apommier #+# #+# */
|
||||
/* Updated: 2023/06/26 07:04:47 by apommier ### ########.fr */
|
||||
/* Updated: 2023/06/28 17:46:12 by apommier ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -69,7 +69,7 @@ export class PongGateway implements OnGatewayInit, OnGatewayConnection, OnGatewa
|
||||
|
||||
@SubscribeMessage('pong:disconnect')
|
||||
disconnectClient(client: Socket, payload: any): void {
|
||||
console.log("disconnect forced client= ", client.id)
|
||||
console.log("Forced disconnect client= ", client.id)
|
||||
|
||||
for (const key in this.clients) {
|
||||
if (this.clients.hasOwnProperty(key) && this.clients[key] === client)
|
||||
@ -184,8 +184,6 @@ addPrivateParty(client: Socket, payload: any): void {
|
||||
@SubscribeMessage('pong:power')
|
||||
sendPower(client: Socket, payload: any): void
|
||||
{
|
||||
console.log(`from: ${client.id}`);
|
||||
|
||||
const game = this.games.get(payload.gameId);
|
||||
const playersIds = game.map(socket => socket.id);
|
||||
if (playersIds[0] === payload.id)
|
||||
@ -197,8 +195,6 @@ addPrivateParty(client: Socket, payload: any): void {
|
||||
@SubscribeMessage('pong:message')
|
||||
handleMessage(client: Socket, payload: any): void
|
||||
{
|
||||
console.log(`from: ${client.id}`);
|
||||
|
||||
const game = this.games.get(payload.gameId);
|
||||
const playersIds = game.map(socket => socket.id);
|
||||
if (playersIds[0] === payload.id)
|
||||
@ -249,7 +245,6 @@ addPrivateParty(client: Socket, payload: any): void {
|
||||
{
|
||||
const game = this.games.get(payload.gameId);
|
||||
const playersIds = game.map(socket => socket.id);
|
||||
console.log(`id of 0= ${playersIds[0]}`);
|
||||
|
||||
if (playersIds[0] === payload.id)
|
||||
{
|
||||
@ -266,7 +261,6 @@ addPrivateParty(client: Socket, payload: any): void {
|
||||
{
|
||||
const game = this.games.get(payload.gameId);
|
||||
const playersIds = game.map(socket => socket.id);
|
||||
console.log(`id of 0 mypoint= ${playersIds[0]}`);
|
||||
|
||||
if (playersIds[0] === payload.id)
|
||||
this.clients[playersIds[1]].emit('pong:hisPoint', payload);
|
||||
@ -279,7 +273,7 @@ addPrivateParty(client: Socket, payload: any): void {
|
||||
{
|
||||
const game = this.games.get(payload.gameId);
|
||||
const playersIds = game.map(socket => socket.id);
|
||||
console.log(`name of client= ${payload.name}`);
|
||||
|
||||
if (playersIds[0] === payload.id)
|
||||
{
|
||||
this.clients[playersIds[1]].emit('pong:name', payload);
|
||||
|
||||
@ -5,7 +5,6 @@ REACT_APP_SOCKET_URL=paul-f5Ar4s4
|
||||
REACT_APP_API_SECRET=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
|
||||
REACT_APP_CLIENT_UID=u-s4t2ud-2bd3c5d4f41e776f2e3d5d699d2a8421f6d0c0468ec882516d9ca89b0c211789
|
||||
|
||||
|
||||
# REACT_APP_BASE_URL=92.143.191.152
|
||||
# REACT_APP_BASE_URL=192.168.1.19
|
||||
REACT_APP_INTRA_URL="https://api.intra.42.fr/oauth/authorize?client_id=u-s4t2ud-2bd3c5d4f41e776f2e3d5d699d2a8421f6d0c0468ec882516d9ca89b0c211789&redirect_uri=http%3A%2F%2Fpaul-f5Ar4s4%3A8080%2Fapi%2Fauth%2Flogin&response_type=code"
|
||||
|
||||
@ -22,19 +22,7 @@ import api from "../script/axiosApi.tsx"
|
||||
|
||||
|
||||
function AnimatedRoute() {
|
||||
useEffect(() => {
|
||||
// const handleBeforeUnload = async (event: { preventDefault: () => void; returnValue: string; }) => {
|
||||
// console.log("git ")
|
||||
// if (!localStorage.getItem('token'))
|
||||
// return;
|
||||
// try {
|
||||
// await api.post("/quit");
|
||||
// // navigator.sendBeacon("http://" + process.env.REACT_APP_BASE_URL + "/api/quit", {username: user.username})
|
||||
// } catch (err) {
|
||||
// console.log(err);
|
||||
// }
|
||||
// };
|
||||
|
||||
useEffect(() => {
|
||||
const handleLoad = async () => {
|
||||
if (!localStorage.getItem('token'))
|
||||
return;
|
||||
@ -52,14 +40,7 @@ function AnimatedRoute() {
|
||||
return;
|
||||
await api.post("/quit");
|
||||
});
|
||||
// window.addEventListener("unload", async (event) => {
|
||||
// await api.post("/quit");
|
||||
// });
|
||||
|
||||
|
||||
return () => {
|
||||
// window.removeEventListener('beforeunload', handleBeforeUnload);
|
||||
};
|
||||
return () => {};
|
||||
}, []);
|
||||
|
||||
const location = useLocation();
|
||||
|
||||
@ -1,11 +0,0 @@
|
||||
import React from 'react';
|
||||
|
||||
function Footer() {
|
||||
return (
|
||||
<footer className="footer">
|
||||
<p>© 2023 Paris France</p>
|
||||
</footer>
|
||||
);
|
||||
}
|
||||
|
||||
export default Footer;
|
||||
@ -6,17 +6,14 @@
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/06/09 08:49:24 by apommier #+# #+# */
|
||||
/* Updated: 2023/06/23 17:16:40 by apommier ### ########.fr */
|
||||
/* Updated: 2023/06/28 17:39:43 by apommier ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
// import React from "react"
|
||||
import React, { useState, useEffect, useRef } from "react";
|
||||
// import {Rank} from '../../DataBase/DataRank.js'
|
||||
import DefaultPicture from '../../assets/profile.jpg'
|
||||
import api from '../../script/axiosApi.tsx';
|
||||
import {Matchlog, User} from "../../../interfaces.tsx"
|
||||
// import { Match } from "@testing-library/react";
|
||||
import {User} from "../../../interfaces.tsx"
|
||||
|
||||
interface RankProps {
|
||||
user: User
|
||||
|
||||
@ -75,9 +75,8 @@ const Modal = ({handleClose}: ModalProps) => {
|
||||
return;
|
||||
try {
|
||||
const ret = await api.post("/verifyPassword", {convId: channel, password: PassWord})
|
||||
if (ret)
|
||||
console.log("ici ret password", ret);
|
||||
// window.location.reload();
|
||||
if (ret.data)
|
||||
window.location.reload();
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
@ -100,7 +99,7 @@ const Modal = ({handleClose}: ModalProps) => {
|
||||
const joinChannel = async () => {
|
||||
try {
|
||||
await api.post("/join", {convId: channel})
|
||||
// window.location.reload();
|
||||
window.location.reload();
|
||||
} catch(err) {
|
||||
console.log(err);
|
||||
}
|
||||
@ -183,12 +182,14 @@ const Modal = ({handleClose}: ModalProps) => {
|
||||
|
||||
{askPass ? (
|
||||
<input className="mdp" placeholder="password" type="password" onChange={(e) => setPassWord(e.target.value)} onKeyDown={handlePassword}/>
|
||||
):("") }
|
||||
):(
|
||||
<div className="div_submit">
|
||||
<Link to='#' className="submit" onClick={ joinChannel }>Join</Link>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="div_submit">
|
||||
<Link to='#' className="submit" onClick={ joinChannel }>Join</Link>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</motion.div>
|
||||
</Backdrop>
|
||||
|
||||
@ -30,7 +30,6 @@ const ModalEdit = () => {
|
||||
}
|
||||
|
||||
const handlePostNickname = async () => {
|
||||
console.log("nickname=", nickname)
|
||||
try {
|
||||
if (nickname.length > 3) {
|
||||
const ret = await api.post("/nickname", { nickname: nickname });
|
||||
|
||||
@ -4,7 +4,6 @@ import React, { useState, useEffect, useRef } from "react";
|
||||
import { useParams } from 'react-router-dom';
|
||||
import api from '../../script/axiosApi.tsx';
|
||||
|
||||
|
||||
function WinLoss() {
|
||||
|
||||
const [user, setUser] = useState<User>();
|
||||
@ -16,7 +15,6 @@ function WinLoss() {
|
||||
useEffect(()=> {
|
||||
const getUser = async ()=>{
|
||||
try{
|
||||
console.log("username win loss=", username)
|
||||
let tmpUser;
|
||||
let tmpHistory;
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/06/09 08:18:58 by apommier #+# #+# */
|
||||
/* Updated: 2023/06/23 17:12:07 by apommier ### ########.fr */
|
||||
/* Updated: 2023/06/28 17:46:36 by apommier ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -16,7 +16,6 @@ import DefaultPicture from '../../assets/profile.jpg'
|
||||
import styled from "styled-components";
|
||||
|
||||
import { RxCircle } from "react-icons/rx";
|
||||
import { CgFontSpacing } from "react-icons/cg";
|
||||
import React from "react";
|
||||
import {User} from "../../../interfaces.tsx"
|
||||
|
||||
@ -34,16 +33,10 @@ const UserChat = styled.div `
|
||||
}
|
||||
`
|
||||
|
||||
const SideP = styled.p`
|
||||
font-size: 14px;
|
||||
color: lightgray;
|
||||
margin-left: 15px;
|
||||
`
|
||||
interface UserProps {
|
||||
currentUser: User
|
||||
}
|
||||
|
||||
// export default function Friend({currentUser})
|
||||
export default function Friend({currentUser}: UserProps)
|
||||
{
|
||||
const [profilePicture, setProfilePicture] = useState('');
|
||||
@ -51,10 +44,7 @@ export default function Friend({currentUser}: UserProps)
|
||||
useEffect(() => {
|
||||
const fetchProfilePicture = async () => {
|
||||
try {
|
||||
// const user = await api.get("/profile");
|
||||
const pic = await api.post("/getPicture", {username: currentUser.username})
|
||||
// console.log(`user naem profile pic222= ${currentUser.username}`)
|
||||
// console.log(` profile pic222= ${pic.data}`)
|
||||
setProfilePicture(pic.data);
|
||||
} catch (error) {
|
||||
console.error('Error fetching profile picture:', error);
|
||||
@ -67,8 +57,6 @@ export default function Friend({currentUser}: UserProps)
|
||||
{
|
||||
let status = friend.status
|
||||
let session =friend.sessionNumber
|
||||
console.log(`session= ${session}`)
|
||||
console.log(`status= ${status}`)
|
||||
let statusColor;
|
||||
|
||||
if (status === 0)
|
||||
@ -80,17 +68,8 @@ export default function Friend({currentUser}: UserProps)
|
||||
return statusColor;
|
||||
}
|
||||
|
||||
const handleSpectate = (user: User) => {
|
||||
//socket connection and add to party with one with username
|
||||
console.log(`spectate hehe`)
|
||||
console.log(`user= ${user}`)
|
||||
};
|
||||
|
||||
const handleButtonClick = (user: User) => {
|
||||
let path = `http://` + process.env.REACT_APP_BASE_URL + `/profile/${user.username}`;
|
||||
console.log("path= ", path)
|
||||
// history(path, { replace: true });
|
||||
// window.location.replace(path);
|
||||
window.history.pushState({}, '', path);
|
||||
window.location.reload();
|
||||
};
|
||||
@ -111,9 +90,3 @@ export default function Friend({currentUser}: UserProps)
|
||||
</UserChat>
|
||||
)
|
||||
}
|
||||
// spectate visible
|
||||
// {getStatus(currentUser) !== 'blue' ? (
|
||||
// <></>
|
||||
// ) : (
|
||||
// <button className="friendRequest" onClick={() => handleSpectate(currentUser)} >Spectate</button>
|
||||
// )}
|
||||
|
||||
@ -21,12 +21,6 @@ const UserChat = styled.div `
|
||||
}
|
||||
`
|
||||
|
||||
const SideP = styled.p`
|
||||
font-size: 14px;
|
||||
color: lightgray;
|
||||
margin-left: 15px;
|
||||
`
|
||||
|
||||
interface UserProps {
|
||||
currentUser: User
|
||||
}
|
||||
@ -36,19 +30,13 @@ export default function Friend({currentUser}: UserProps)
|
||||
const [profilePicture, setProfilePicture] = useState('');
|
||||
const [request, setRequest] = useState<User>(); //user who invite
|
||||
const [clickEvent, setClickEvent] = useState(false);
|
||||
// const [user, setUser] = useState(null);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchProfilePicture = async () => {
|
||||
try {
|
||||
// const user = await api.get("/profile");\
|
||||
// const tmpUser = await api.get("/profile")
|
||||
const pic = await api.post("/getPicture", {username: currentUser.username})
|
||||
const tmpRequest = await api.post("/user", {username: currentUser.username})
|
||||
// setUser(tmpUser.data);
|
||||
setRequest(tmpRequest.data);
|
||||
// console.log(`user naem profile pic222= ${currentUser.username}`)
|
||||
// console.log(` profile pic222= ${pic.data}`)
|
||||
setProfilePicture(pic.data);
|
||||
} catch (error) {
|
||||
console.error('Error fetching profile picture:', error);
|
||||
@ -60,8 +48,6 @@ export default function Friend({currentUser}: UserProps)
|
||||
|
||||
const handleButtonClick = (user: User) => {
|
||||
let path = `http://` + process.env.REACT_APP_BASE_URL + `/profile/${user.username}`;
|
||||
// history(path, { replace: true });
|
||||
// window.location.replace(path);
|
||||
window.history.pushState({}, '', path);
|
||||
window.location.reload();
|
||||
};
|
||||
@ -73,8 +59,7 @@ export default function Friend({currentUser}: UserProps)
|
||||
} catch(err) {
|
||||
console.log(err);
|
||||
}
|
||||
console.log("accept")
|
||||
console.log(`request = ${request}`)
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
const Refuse = async (request: User) => {
|
||||
@ -84,13 +69,11 @@ export default function Friend({currentUser}: UserProps)
|
||||
} catch(err) {
|
||||
console.log(err);
|
||||
}
|
||||
console.log("refuse")
|
||||
console.log(`request = ${request}`)
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
// Vérifier si le contenu doit être caché
|
||||
if (clickEvent) {
|
||||
return null; // Rendre null pour ne pas afficher le contenu
|
||||
return (<></>);
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import DefaultPicture from '../../assets/profile.jpg'
|
||||
import api from '../../script/axiosApi.tsx';
|
||||
import React, { useState, useEffect, useRef } from "react";
|
||||
import React, { useState, useEffect} from "react";
|
||||
import styled from "styled-components";
|
||||
|
||||
|
||||
@ -8,14 +7,8 @@ import Friend from './Friend.tsx';
|
||||
import FriendRequest from './FriendRequest.tsx';
|
||||
|
||||
import {IoMdPeople} from 'react-icons/io'
|
||||
import { ImBlocked } from 'react-icons/im';
|
||||
import { MdOutlineGroupAdd } from 'react-icons/md';
|
||||
import {User} from "../../../interfaces.tsx"
|
||||
|
||||
// import React from "react";
|
||||
|
||||
import { useNavigate } from "react-router-dom";
|
||||
|
||||
|
||||
|
||||
|
||||
@ -52,8 +45,6 @@ function Social (){
|
||||
setProfilePicture(pic.data);
|
||||
setUser(tmpUser.data);
|
||||
setFriends(tmpFriends.data);
|
||||
// return tmpUser;
|
||||
console.log(`user= ${tmpUser.data.username}`);
|
||||
setIsLoading(false)
|
||||
|
||||
}
|
||||
@ -65,30 +56,9 @@ function Social (){
|
||||
|
||||
}, [])
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// const { status } = this.props;
|
||||
// let statusColor = '';
|
||||
// // let statusIcon = RxCircle;
|
||||
// let status = 0
|
||||
|
||||
// if (status === 0) {
|
||||
// // statusIcon = faCircle;
|
||||
// statusColor = 'green';
|
||||
// } else if (status === 1) {
|
||||
// // statusIcon = faCircle;
|
||||
// statusColor = 'red';
|
||||
// } else if (status === 2) {
|
||||
// // statusIcon = faCircle;
|
||||
// statusColor = 'blue';
|
||||
// }
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className='navbarSocial'>
|
||||
{/* <img src={DefaultPic} alt="profile" className="pic"/> */}
|
||||
<IoMdPeople className="catchat"/>
|
||||
<span>
|
||||
{isLoading || !user ? (
|
||||
@ -100,8 +70,6 @@ function Social (){
|
||||
|
||||
</div>
|
||||
|
||||
{/* map with fiend request */}
|
||||
|
||||
{invite.map(c=> (
|
||||
<FriendRequest currentUser={c}/>
|
||||
))}
|
||||
|
||||
@ -44,7 +44,6 @@ function Field()
|
||||
useEffect(() => {
|
||||
const queryParams = queryString.parse(window.location.search);
|
||||
|
||||
console.log("launch canva hehe")
|
||||
let Modifiers = 0;
|
||||
let info: GameProps;
|
||||
|
||||
@ -66,19 +65,16 @@ function Field()
|
||||
}
|
||||
if (queryParams.username)
|
||||
{
|
||||
console.log("user= ", queryParams.username)
|
||||
info = {
|
||||
privateParty: true,
|
||||
username: queryParams.username as string,
|
||||
gameId: queryParams.gameId as unknown as number
|
||||
}
|
||||
console.log("info of param vefore canvas=", info)
|
||||
}
|
||||
|
||||
const cleanup = DrawCanvas(Modifiers, info);
|
||||
|
||||
return () => {
|
||||
console.log("Cleanup");
|
||||
if (cleanup)
|
||||
cleanup();
|
||||
};
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/06/09 08:19:04 by apommier #+# #+# */
|
||||
/* Updated: 2023/06/26 11:31:57 by apommier ### ########.fr */
|
||||
/* Updated: 2023/06/28 17:47:35 by apommier ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -56,16 +56,13 @@ function Profile () {
|
||||
|
||||
useEffect(()=> {
|
||||
const getUser = async ()=>{
|
||||
console.log(`username= ${username}`)
|
||||
let pic;
|
||||
try{
|
||||
console.log("before request")
|
||||
const me = await api.get("/profile")
|
||||
if (!username)
|
||||
{
|
||||
setMine(true);
|
||||
setUser(me.data);
|
||||
console.log(`mine= true = ${mine}`)
|
||||
pic = await api.post("/getPicture", {username: me.data.username}) //good one?
|
||||
}
|
||||
else
|
||||
|
||||
@ -82,7 +82,7 @@ function QrCode () {
|
||||
window.location.reload();
|
||||
}
|
||||
else
|
||||
console.log("bad code")
|
||||
console.log("Bad code")
|
||||
}
|
||||
catch(err){
|
||||
console.log(err)
|
||||
|
||||
@ -108,7 +108,6 @@ socket.on('pong:win', async () => {
|
||||
});
|
||||
|
||||
socket.on('pong:privateId', async (data) => {
|
||||
console.log("private id = ", data)
|
||||
try{
|
||||
await api.post("/partyInvite", {username: gameParam.username, gameId: data});
|
||||
} catch(err) {
|
||||
@ -376,11 +375,8 @@ socket.on('pong:hisPoint', (data) => {
|
||||
const stopDrawCanvas = async () => {
|
||||
running = false;
|
||||
|
||||
console.log("stopDrawCanvas 1")
|
||||
|
||||
if (gameParam.privateParty && !gameId) //delete invite
|
||||
{
|
||||
console.log("stopDrawCanvas2")
|
||||
try{
|
||||
await api.post('/status', {status: 1});
|
||||
await api.post("deleteInvite", {username: gameParam.username})
|
||||
@ -585,7 +581,6 @@ async function draw(timestamp: number)
|
||||
else if (event.code === "KeyW")
|
||||
{
|
||||
let date = new Date();
|
||||
console.log("last time =", date.getTime() - lastPower)
|
||||
if (date.getTime() - lastPower < 15000)//10000 + 5000
|
||||
return ;
|
||||
if (!superpowerModifier)
|
||||
|
||||
@ -3,14 +3,9 @@ import axios from 'axios';
|
||||
|
||||
function getToken() {
|
||||
const token = localStorage.getItem('token');
|
||||
if (typeof token === 'string') {
|
||||
console.log("is a string !!!")
|
||||
}
|
||||
return token;
|
||||
}
|
||||
|
||||
console.log(`getToken = ${getToken()}`)
|
||||
console.log(`Bearer ${localStorage.getItem("token")}`)
|
||||
let api = axios.create({
|
||||
baseURL: 'http://' + process.env.REACT_APP_BASE_URL + '/api',
|
||||
headers: {
|
||||
|
||||
@ -14,7 +14,6 @@ function SuccessToken() {
|
||||
|
||||
useEffect(() => {
|
||||
if (!data) {
|
||||
console.log("No data");
|
||||
return ;
|
||||
}
|
||||
|
||||
@ -59,7 +58,7 @@ function SuccessToken() {
|
||||
window.location.replace("http://" + process.env.REACT_APP_BASE_URL + "/pong");
|
||||
}
|
||||
else
|
||||
console.log("bad code")
|
||||
console.log("Bad code")
|
||||
}
|
||||
catch(err){
|
||||
console.log(err)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user