aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/components/sidebar.js
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/components/sidebar.js')
-rw-r--r--frontend/src/components/sidebar.js19
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
18export default function Sidebar(prop) { 18export default function Sidebar(prop) {
19const {token,setToken} = prop 19const {token,setToken} = prop
20const [profile, setProfile] = React.useState(null);
21React.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
22const [isLocked, setIsLocked] = React.useState(false); 33const [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&nbsp;Rules</span></button> 164 <button className='sidebar-button'><img src={img8} alt="" /><span>Leaderboard&nbsp;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>