diff options
| author | Nidboj132 <28981031+Nidboj132@users.noreply.github.com> | 2023-11-05 20:27:51 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-05 20:27:51 +0100 |
| commit | eeab67611f16cfce112ac2779bb324d089a7c2fa (patch) | |
| tree | 7fe7766607cb4f92f20a85dab9332ff2396ee0fa /frontend/src/components/sidebar.js | |
| parent | fix is_disabled ambiguity (#124) (diff) | |
| download | lphub-eeab67611f16cfce112ac2779bb324d089a7c2fa.tar.gz lphub-eeab67611f16cfce112ac2779bb324d089a7c2fa.tar.bz2 lphub-eeab67611f16cfce112ac2779bb324d089a7c2fa.zip | |
feat: profile (#54)
Former-commit-id: be6cd428190c05b2fa99e36c32765cc0fd4044e8
Diffstat (limited to 'frontend/src/components/sidebar.js')
| -rw-r--r-- | frontend/src/components/sidebar.js | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/frontend/src/components/sidebar.js b/frontend/src/components/sidebar.js index d9b8012..e587c3c 100644 --- a/frontend/src/components/sidebar.js +++ b/frontend/src/components/sidebar.js | |||
| @@ -17,6 +17,17 @@ import Login from "./login.js" | |||
| 17 | 17 | ||
| 18 | export default function Sidebar(prop) { | 18 | export default function Sidebar(prop) { |
| 19 | const {token,setToken} = prop | 19 | const {token,setToken} = prop |
| 20 | const [profile, setProfile] = React.useState(null); | ||
| 21 | React.useEffect(() => { | ||
| 22 | fetch(`https://lp.ardapektezol.com/api/v1/profile`,{ | ||
| 23 | headers: { | ||
| 24 | 'Content-Type': 'application/json', | ||
| 25 | Authorization: token | ||
| 26 | }}) | ||
| 27 | .then(r => r.json()) | ||
| 28 | .then(d => setProfile(d.data)) | ||
| 29 | }, [token]); | ||
| 30 | |||
| 20 | 31 | ||
| 21 | // Locks search button for 300ms before it can be clicked again, prevents spam | 32 | // Locks search button for 300ms before it can be clicked again, prevents spam |
| 22 | const [isLocked, setIsLocked] = React.useState(false); | 33 | const [isLocked, setIsLocked] = React.useState(false); |
| @@ -147,7 +158,7 @@ return ( | |||
| 147 | <div id='sidebar-bottomlist'> | 158 | <div id='sidebar-bottomlist'> |
| 148 | <span></span> | 159 | <span></span> |
| 149 | 160 | ||
| 150 | <Login token={token} setToken={setToken}/> | 161 | <Login setToken={setToken} profile={profile} setProfile={setProfile}/> |
| 151 | 162 | ||
| 152 | <Link to="/rules" tabIndex={-1}> | 163 | <Link to="/rules" tabIndex={-1}> |
| 153 | <button className='sidebar-button'><img src={img8} alt="" /><span>Leaderboard Rules</span></button> | 164 | <button className='sidebar-button'><img src={img8} alt="" /><span>Leaderboard Rules</span></button> |
| @@ -172,11 +183,13 @@ return ( | |||
| 172 | )):""} | 183 | )):""} |
| 173 | {searchData!==null?searchData.players.map((q,index)=> | 184 | {searchData!==null?searchData.players.map((q,index)=> |
| 174 | ( | 185 | ( |
| 175 | <Link className='search-player' key={index}> | 186 | <Link to={ |
| 187 | q.steam_id===profile.steam_id?`/profile`: | ||
| 188 | `/users/${q.steam_id}` | ||
| 189 | } className='search-player' key={index}> | ||
| 176 | <img src={q.avatar_link} alt='pfp'></img> | 190 | <img src={q.avatar_link} alt='pfp'></img> |
| 177 | <span style={{fontSize:`${36 - q.user_name.length * 0.8}px`}}>{q.user_name}</span> | 191 | <span style={{fontSize:`${36 - q.user_name.length * 0.8}px`}}>{q.user_name}</span> |
| 178 | </Link> | 192 | </Link> |
| 179 | |||
| 180 | )):""} | 193 | )):""} |
| 181 | 194 | ||
| 182 | </div> | 195 | </div> |