diff options
Diffstat (limited to '')
| -rw-r--r-- | frontend/src/components/sidebar.js | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/frontend/src/components/sidebar.js b/frontend/src/components/sidebar.js index 77800bd..d9b8012 100644 --- a/frontend/src/components/sidebar.js +++ b/frontend/src/components/sidebar.js | |||
| @@ -91,9 +91,17 @@ React.useEffect(()=>{ | |||
| 91 | if(location.pathname.includes("rules")){SidebarClick(9)} | 91 | if(location.pathname.includes("rules")){SidebarClick(9)} |
| 92 | if(location.pathname.includes("about")){SidebarClick(10)} | 92 | if(location.pathname.includes("about")){SidebarClick(10)} |
| 93 | 93 | ||
| 94 | // console.log(location.pathname) | ||
| 95 | // eslint-disable-next-line react-hooks/exhaustive-deps | 94 | // eslint-disable-next-line react-hooks/exhaustive-deps |
| 96 | }, [location]) | 95 | }, [location.pathname]) |
| 96 | |||
| 97 | const [search,setSearch] = React.useState(null) | ||
| 98 | const [searchData,setSearchData] = React.useState(null) | ||
| 99 | React.useEffect(()=>{ | ||
| 100 | fetch(`https://lp.ardapektezol.com/api/v1/search?q=${search}`) | ||
| 101 | .then(r=>r.json()) | ||
| 102 | .then(d=>setSearchData(d.data)) | ||
| 103 | |||
| 104 | }, [search]) | ||
| 97 | 105 | ||
| 98 | 106 | ||
| 99 | return ( | 107 | return ( |
| @@ -151,7 +159,27 @@ return ( | |||
| 151 | </div> | 159 | </div> |
| 152 | </div> | 160 | </div> |
| 153 | <div> | 161 | <div> |
| 154 | <input type="text" id='searchbar' placeholder='Search for map or a player...'/> | 162 | <input type="text" id='searchbar' placeholder='Search for map or a player...' onChange={()=>setSearch(document.querySelector("#searchbar").value)}/> |
| 163 | |||
| 164 | <div id='search-data'> | ||
| 165 | |||
| 166 | {searchData!==null?searchData.maps.map((q,index)=>( | ||
| 167 | <Link to={`/maps/${q.id}`} className='search-map' key={index}> | ||
| 168 | <span>{q.game}</span> | ||
| 169 | <span>{q.chapter}</span> | ||
| 170 | <span>{q.map}</span> | ||
| 171 | </Link> | ||
| 172 | )):""} | ||
| 173 | {searchData!==null?searchData.players.map((q,index)=> | ||
| 174 | ( | ||
| 175 | <Link className='search-player' key={index}> | ||
| 176 | <img src={q.avatar_link} alt='pfp'></img> | ||
| 177 | <span style={{fontSize:`${36 - q.user_name.length * 0.8}px`}}>{q.user_name}</span> | ||
| 178 | </Link> | ||
| 179 | |||
| 180 | )):""} | ||
| 181 | |||
| 182 | </div> | ||
| 155 | </div> | 183 | </div> |
| 156 | </div> | 184 | </div> |
| 157 | ) | 185 | ) |