aboutsummaryrefslogtreecommitdiff
path: root/frontend
diff options
context:
space:
mode:
authorArda Serdar Pektezol <1669855+pektezol@users.noreply.github.com>2024-08-20 20:31:02 +0300
committerGitHub <noreply@github.com>2024-08-20 20:31:02 +0300
commit119f5f1b5acb370e835e2166456d2a6043ca5a6e (patch)
treeb00ccfbf5c38fcb1769de7d268e1747687ae30ec /frontend
parentfix: homepage api call spam (#195) (diff)
downloadlphub-119f5f1b5acb370e835e2166456d2a6043ca5a6e.tar.gz
lphub-119f5f1b5acb370e835e2166456d2a6043ca5a6e.tar.bz2
lphub-119f5f1b5acb370e835e2166456d2a6043ca5a6e.zip
fix: revert to static homepage (#195)
Co-authored-by: Wolfboy248 <121288977+Wolfboy248@users.noreply.github.com>
Diffstat (limited to 'frontend')
-rw-r--r--frontend/src/components/pages/home.js88
1 files changed, 44 insertions, 44 deletions
diff --git a/frontend/src/components/pages/home.js b/frontend/src/components/pages/home.js
index c2376f2..0a46bec 100644
--- a/frontend/src/components/pages/home.js
+++ b/frontend/src/components/pages/home.js
@@ -7,67 +7,67 @@ import Record from '../record';
7export default function Homepage({ token }) { 7export default function Homepage({ token }) {
8 const [profile, setProfile] = useState(null); 8 const [profile, setProfile] = useState(null);
9 9
10 useEffect(() => { 10// useEffect(() => {
11 11
12 if (!token) { 12// if (!token) {
13 return; 13// return;
14 } 14// }
15 15
16 async function home() { 16// async function home() {
17 17
18 const profileResponse = await fetch(`https://lp.ardapektezol.com/api/v1/profile`, { 18// const profileResponse = await fetch(`https://lp.ardapektezol.com/api/v1/profile`, {
19 headers: { 19// headers: {
20 Authorization: token 20// Authorization: token
21 } 21// }
22 }) 22// })
23 23
24 const profileData = await profileResponse.json(); 24// const profileData = await profileResponse.json();
25 25
26 setProfile(profileData); 26// setProfile(profileData);
27 27
28 const gamesResponse = await fetch("https://lp.ardapektezol.com/api/v1/games", { 28// const gamesResponse = await fetch("https://lp.ardapektezol.com/api/v1/games", {
29 headers: { 29// headers: {
30 Authorization: token 30// Authorization: token
31 } 31// }
32 }); 32// });
33 33
34 const gamesData = await gamesResponse.json(); 34// const gamesData = await gamesResponse.json();
35 35
36 const recommendedMapImg = document.querySelector("#recommendedMapImg"); 36// const recommendedMapImg = document.querySelector("#recommendedMapImg");
37 37
38 recommendedMapImg.style.backgroundImage = `url(${gamesData.data[0].image})` 38// recommendedMapImg.style.backgroundImage = `url(${gamesData.data[0].image})`
39 39
40 const column1 = document.querySelector("#column1"); 40// const column1 = document.querySelector("#column1");
41 const column2 = document.querySelector("#column2"); 41// const column2 = document.querySelector("#column2");
42 42
43 column2.style.height = column1.clientHeight + "px"; 43// column2.style.height = column1.clientHeight + "px";
44 44
45 const panels = document.querySelectorAll(".homepage-panel"); 45// const panels = document.querySelectorAll(".homepage-panel");
46 panels.forEach(e => { 46// panels.forEach(e => {
47 // this is cuz react is silly 47// // this is cuz react is silly
48 if (e.innerHTML.includes('<div class="homepage-panel-title-div">')) { 48// if (e.innerHTML.includes('<div class="homepage-panel-title-div">')) {
49 return 49// return
50 } 50// }
51 const title = e.getAttribute("title"); 51// const title = e.getAttribute("title");
52 52
53 const titleDiv = document.createElement("div"); 53// const titleDiv = document.createElement("div");
54 const titleSpan = document.createElement("span"); 54// const titleSpan = document.createElement("span");
55 55
56 titleDiv.classList.add("homepage-panel-title-div") 56// titleDiv.classList.add("homepage-panel-title-div")
57 57
58 titleSpan.innerText = title 58// titleSpan.innerText = title
59 59
60 titleDiv.appendChild(titleSpan) 60// titleDiv.appendChild(titleSpan)
61 e.insertBefore(titleDiv, e.firstChild) 61// e.insertBefore(titleDiv, e.firstChild)
62 }); 62// });
63 } 63// }
64 try { 64// try {
65 home(); 65// home();
66 } catch (e) { 66// } catch (e) {
67 console.log("error while setting up home page:", e); 67// console.log("error while setting up home page:", e);
68 } 68// }
69 69
70}, [token]); 70// }, [token]);
71 71
72const newsList = [ 72const newsList = [
73 { 73 {