je sais plus

This commit is contained in:
Alexandre POMMIER 2023-06-26 12:02:50 +02:00
parent ad10c23528
commit 790e9e5897
4 changed files with 11 additions and 10 deletions

View File

@ -129,7 +129,6 @@ const Modal = ({handleClose}: ModalProps) => {
members: selectedOptions, members: selectedOptions,
} }
try{ try{
// test
await api.post("/conv", data); await api.post("/conv", data);
handleClose(); handleClose();
window.location.reload(); window.location.reload();

View File

@ -16,6 +16,7 @@ function Field()
useEffect(() => { useEffect(() => {
const queryParams = queryString.parse(window.location.search); const queryParams = queryString.parse(window.location.search);
console.log("launch canva hehe")
let Modifiers = 0; let Modifiers = 0;
let info: GameProps; let info: GameProps;
@ -37,16 +38,19 @@ function Field()
} }
if (queryParams.username) if (queryParams.username)
{ {
info = { console.log("user= ", queryParams.username)
privateParty: true, info = {
username: queryParams.username as string, privateParty: true,
gameId: queryParams.gameId as unknown as number 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); const cleanup = DrawCanvas(Modifiers, info);
return () => { return () => {
console.log("Cleanup");
if (cleanup) if (cleanup)
cleanup(); cleanup();
}; };

View File

@ -10,7 +10,6 @@ interface GameProps {
function DrawCanvas(option: number, gameParam: GameProps) { function DrawCanvas(option: number, gameParam: GameProps) {
useEffect(() => { useEffect(() => {
const handleBeforeUnload = async (event: { preventDefault: () => void; returnValue: string; }) => { const handleBeforeUnload = async (event: { preventDefault: () => void; returnValue: string; }) => {
try { try {
@ -19,13 +18,13 @@ function DrawCanvas(option: number, gameParam: GameProps) {
console.log(err); console.log(err);
} }
}; };
window.addEventListener('beforeunload', handleBeforeUnload); window.addEventListener('beforeunload', handleBeforeUnload);
return () => { return () => {
window.removeEventListener('beforeunload', handleBeforeUnload); window.removeEventListener('beforeunload', handleBeforeUnload);
}; };
}, []); }, []);
console.log(`option= ${option}`); console.log(`option= ${option}`);
const superpowerModifier = option & 1; // Retrieves the superpower modifier const superpowerModifier = option & 1; // Retrieves the superpower modifier
const obstacleModifier = (option >> 1) & 1; // Retrieves the obstacle modifier const obstacleModifier = (option >> 1) & 1; // Retrieves the obstacle modifier

View File

@ -1,11 +1,10 @@
import { useLocation } from 'react-router-dom'; import { useLocation } from 'react-router-dom';
import { useState, useEffect } from 'react' import { useState, useEffect } from 'react'
import queryString from 'query-string'; import queryString from 'query-string';
import api from "./axiosApi.tsx";
import axios from 'axios'; import axios from 'axios';
import React from 'react'; import React from 'react';
import {Matchlog, User} from "../../interfaces.tsx" import {User} from "../../interfaces.tsx"
function SuccessToken() { function SuccessToken() {
const location = useLocation(); const location = useLocation();