diff --git a/cryptide_project/src/Components/ProfilePDP.tsx b/cryptide_project/src/Components/ProfilePDP.tsx
index 7b1774a..b681dd8 100644
--- a/cryptide_project/src/Components/ProfilePDP.tsx
+++ b/cryptide_project/src/Components/ProfilePDP.tsx
@@ -4,7 +4,7 @@ import dl from '../res/icon/download.png'
import defaultImg from '../res/img/Person.png'
//@ts-ignore
-const ProfilePDP = ({ player }) => {
+const ProfilePDP = ({ player}) => {
const [selectedFile, setSelectedFile] = useState(null);
// @ts-ignore
@@ -18,6 +18,12 @@ const ProfilePDP = ({ player }) => {
}
};
+ //! gitans ?
+ if (player.pdp == undefined){
+ player.pdp = defaultImg;
+ }
+
+ console.log("pdp joueur " + player.pdp)
return (
{selectedFile ? (
diff --git a/cryptide_project/src/Pages/Profile.tsx b/cryptide_project/src/Pages/Profile.tsx
index 712b710..5d7342a 100644
--- a/cryptide_project/src/Pages/Profile.tsx
+++ b/cryptide_project/src/Pages/Profile.tsx
@@ -7,43 +7,41 @@ import './Profile.css'
import SessionService from '../services/SessionService';
import { PlayerProps } from '../types/Player';
import { update } from 'lodash';
+import Human from '../model/Human';
//@ts-ignore
const Profile = () => {
//let player;
- const [player, setPlayer] = useState
(null);
+ const [player, setPlayer] = useState(new Human("null", "nullHuman"));
//! useeffect pour l'instant, il faudra voir pour changer la facons de prendre une session
useEffect(() => {
const fetchUserInformation = async () => {
try {
const sessionData = await SessionService.getSession();
if (sessionData.user) {
- const updatedPlayer: PlayerProps = {
- pseudo: sessionData.user.pseudo,
- profilePicture: sessionData.user.profilePicture,
- soloStats: {
- nbGames: sessionData.user.soloStats.nbGames,
- bestScore: sessionData.user.soloStats.bestScore,
- avgNbTry: sessionData.user.soloStats.avgNbTry,
- },
- onlineStats: {
- nbGames: sessionData.user.onlineStats.nbGames,
- nbWins: sessionData.user.onlineStats.nbWins,
- ratio: sessionData.user.onlineStats.ratio,
- },
+ const updatedPlayer: Human = {
+ name: sessionData.user.pseudo,
+ pdp: sessionData.user.profilePicture,
+ toJson: function (): { type: string; id: string; name: string; } {
+ throw new Error('Function not implemented.');
+ },
+ id: ''
};
setPlayer(updatedPlayer);
}
} catch (error) {
console.error(error);
}
- }})
+ }
+ fetchUserInformation();
+ }, []
+ )
return (
- {player?.pseudo}
+ {player.name}
);
};
diff --git a/cryptide_project/src/model/Human.tsx b/cryptide_project/src/model/Human.tsx
index 5c50dc9..f8aba5d 100644
--- a/cryptide_project/src/model/Human.tsx
+++ b/cryptide_project/src/model/Human.tsx
@@ -1,9 +1,13 @@
import Player from "./Player";
+import defaultImg from '../res/img/Person.png'
class Human extends Player{
+ public pdp: string;
+
constructor(id: string, name: string){
super(id, name)
+ this.pdp = defaultImg;
}
toJson() {
diff --git a/cryptide_project/src/model/Player.ts b/cryptide_project/src/model/Player.ts
index b367bcd..fa095b9 100644
--- a/cryptide_project/src/model/Player.ts
+++ b/cryptide_project/src/model/Player.ts
@@ -1,14 +1,13 @@
-import defaultImg from '../res/img/Person.png'
abstract class Player{
public id: string
public name: string;
- public pdp: string;
+
constructor(id: string, name: string){
this.id=id
this.name=name
- this.pdp = defaultImg;
+
}
abstract toJson(): any