|
|
@ -7,43 +7,41 @@ import './Profile.css'
|
|
|
|
import SessionService from '../services/SessionService';
|
|
|
|
import SessionService from '../services/SessionService';
|
|
|
|
import { PlayerProps } from '../types/Player';
|
|
|
|
import { PlayerProps } from '../types/Player';
|
|
|
|
import { update } from 'lodash';
|
|
|
|
import { update } from 'lodash';
|
|
|
|
|
|
|
|
import Human from '../model/Human';
|
|
|
|
|
|
|
|
|
|
|
|
//@ts-ignore
|
|
|
|
//@ts-ignore
|
|
|
|
const Profile = () => {
|
|
|
|
const Profile = () => {
|
|
|
|
|
|
|
|
|
|
|
|
//let player;
|
|
|
|
//let player;
|
|
|
|
const [player, setPlayer] = useState<PlayerProps | null>(null);
|
|
|
|
const [player, setPlayer] = useState<Human>(new Human("null", "nullHuman"));
|
|
|
|
//! useeffect pour l'instant, il faudra voir pour changer la facons de prendre une session
|
|
|
|
//! useeffect pour l'instant, il faudra voir pour changer la facons de prendre une session
|
|
|
|
useEffect(() => {
|
|
|
|
useEffect(() => {
|
|
|
|
const fetchUserInformation = async () => {
|
|
|
|
const fetchUserInformation = async () => {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const sessionData = await SessionService.getSession();
|
|
|
|
const sessionData = await SessionService.getSession();
|
|
|
|
if (sessionData.user) {
|
|
|
|
if (sessionData.user) {
|
|
|
|
const updatedPlayer: PlayerProps = {
|
|
|
|
const updatedPlayer: Human = {
|
|
|
|
pseudo: sessionData.user.pseudo,
|
|
|
|
name: sessionData.user.pseudo,
|
|
|
|
profilePicture: sessionData.user.profilePicture,
|
|
|
|
pdp: sessionData.user.profilePicture,
|
|
|
|
soloStats: {
|
|
|
|
toJson: function (): { type: string; id: string; name: string; } {
|
|
|
|
nbGames: sessionData.user.soloStats.nbGames,
|
|
|
|
throw new Error('Function not implemented.');
|
|
|
|
bestScore: sessionData.user.soloStats.bestScore,
|
|
|
|
},
|
|
|
|
avgNbTry: sessionData.user.soloStats.avgNbTry,
|
|
|
|
id: ''
|
|
|
|
},
|
|
|
|
|
|
|
|
onlineStats: {
|
|
|
|
|
|
|
|
nbGames: sessionData.user.onlineStats.nbGames,
|
|
|
|
|
|
|
|
nbWins: sessionData.user.onlineStats.nbWins,
|
|
|
|
|
|
|
|
ratio: sessionData.user.onlineStats.ratio,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
setPlayer(updatedPlayer);
|
|
|
|
setPlayer(updatedPlayer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (error) {
|
|
|
|
} catch (error) {
|
|
|
|
console.error(error);
|
|
|
|
console.error(error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}})
|
|
|
|
}
|
|
|
|
|
|
|
|
fetchUserInformation();
|
|
|
|
|
|
|
|
}, []
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<div className='mainContainer'>
|
|
|
|
<div className='mainContainer'>
|
|
|
|
<ProfilePDP player={player}/>
|
|
|
|
<ProfilePDP player={player}/>
|
|
|
|
<h1> {player?.pseudo} </h1>
|
|
|
|
<h1> {player.name} </h1>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
);
|
|
|
|
};
|
|
|
|
};
|
|
|
|