/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* Rank.jsx :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/06/09 08:49:24 by apommier #+# #+# */ /* Updated: 2023/06/09 08:55:22 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'; function Rank({user, index}){ const [profilePicture, setProfilePicture] = useState(''); useEffect(() => { const fetchProfilePicture = async () => { try { // const user = await api.get("/profile"); const pic = await api.post("/getPicture", {username: user.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); } }; fetchProfilePicture(); }) return (

{index + 1}

{user.rank}: {user.nickname} {profilePicture ? ( ) : ( Default Profile Picture )} {/* */}

{user.opponent}

) } export default Rank