diff options
| author | Wolfboy248 <121288977+Wolfboy248@users.noreply.github.com> | 2024-07-11 19:22:00 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-11 20:22:00 +0300 |
| commit | 4bdb77287866c47f5b61d6472b3ff9cc4020f35e (patch) | |
| tree | a8aac6098d991e5ae607dd7264f7bf2631d84e99 /frontend/src/components | |
| parent | docs: add wolfboy248 onto project team (#179) (diff) | |
| download | lphub-4bdb77287866c47f5b61d6472b3ff9cc4020f35e.tar.gz lphub-4bdb77287866c47f5b61d6472b3ff9cc4020f35e.tar.bz2 lphub-4bdb77287866c47f5b61d6472b3ff9cc4020f35e.zip | |
fix: about page crash, update packages (#181)
Diffstat (limited to 'frontend/src/components')
| -rw-r--r-- | frontend/src/components/login.js | 6 | ||||
| -rw-r--r-- | frontend/src/components/main.css | 2 | ||||
| -rw-r--r-- | frontend/src/components/pages/games.js | 4 | ||||
| -rw-r--r-- | frontend/src/components/pages/maplist.js | 11 | ||||
| -rw-r--r-- | frontend/src/components/record.js | 7 | ||||
| -rw-r--r-- | frontend/src/components/sidebar.js | 5 |
6 files changed, 25 insertions, 10 deletions
diff --git a/frontend/src/components/login.js b/frontend/src/components/login.js index 2b735cb..f86ad44 100644 --- a/frontend/src/components/login.js +++ b/frontend/src/components/login.js | |||
| @@ -23,7 +23,11 @@ const [isLoggedIn, setIsLoggedIn] = React.useState(false); | |||
| 23 | React.useEffect(() => { | 23 | React.useEffect(() => { |
| 24 | fetch(`https://lp.ardapektezol.com/api/v1/token`) | 24 | fetch(`https://lp.ardapektezol.com/api/v1/token`) |
| 25 | .then(r => r.json()) | 25 | .then(r => r.json()) |
| 26 | .then(d => setToken(d.data.token)) | 26 | .then(d => { |
| 27 | if (d.data != null) { | ||
| 28 | setToken(d.data.token) | ||
| 29 | } | ||
| 30 | }) | ||
| 27 | }, []); | 31 | }, []); |
| 28 | 32 | ||
| 29 | 33 | ||
diff --git a/frontend/src/components/main.css b/frontend/src/components/main.css index 9e9be86..48e6379 100644 --- a/frontend/src/components/main.css +++ b/frontend/src/components/main.css | |||
| @@ -10,7 +10,7 @@ main { | |||
| 10 | 10 | ||
| 11 | padding-right: 30px; | 11 | padding-right: 30px; |
| 12 | 12 | ||
| 13 | /* font-size: 40px; */ | 13 | font-size: 40px; |
| 14 | font-family: BarlowSemiCondensed-Regular; | 14 | font-family: BarlowSemiCondensed-Regular; |
| 15 | color: #cdcfdf; | 15 | color: #cdcfdf; |
| 16 | 16 | ||
diff --git a/frontend/src/components/pages/games.js b/frontend/src/components/pages/games.js index 8c27151..75b5e44 100644 --- a/frontend/src/components/pages/games.js +++ b/frontend/src/components/pages/games.js | |||
| @@ -10,6 +10,10 @@ export default function Games(prop) { | |||
| 10 | const location = useLocation(); | 10 | const location = useLocation(); |
| 11 | 11 | ||
| 12 | useEffect(() => { | 12 | useEffect(() => { |
| 13 | document.querySelectorAll(".games-page-item-body").forEach((game, index) => { | ||
| 14 | game.innerHTML = ""; | ||
| 15 | }) | ||
| 16 | |||
| 13 | const fetchGames = async () => { | 17 | const fetchGames = async () => { |
| 14 | try { | 18 | try { |
| 15 | const response = await fetch("https://lp.ardapektezol.com/api/v1/games", { | 19 | const response = await fetch("https://lp.ardapektezol.com/api/v1/games", { |
diff --git a/frontend/src/components/pages/maplist.js b/frontend/src/components/pages/maplist.js index dca76d6..f4041a2 100644 --- a/frontend/src/components/pages/maplist.js +++ b/frontend/src/components/pages/maplist.js | |||
| @@ -98,6 +98,9 @@ export default function Maplist(prop) { | |||
| 98 | const data = await response.json(); | 98 | const data = await response.json(); |
| 99 | let categoriesArr = data.data[gameID - 1].category_portals; | 99 | let categoriesArr = data.data[gameID - 1].category_portals; |
| 100 | 100 | ||
| 101 | if (document.querySelector(".maplist-maps") == null) { | ||
| 102 | return; | ||
| 103 | } | ||
| 101 | const gameNav = document.querySelector(".game-nav"); | 104 | const gameNav = document.querySelector(".game-nav"); |
| 102 | gameNav.innerHTML = ""; | 105 | gameNav.innerHTML = ""; |
| 103 | categoriesArr.forEach((category) => { | 106 | categoriesArr.forEach((category) => { |
| @@ -147,7 +150,6 @@ export default function Maplist(prop) { | |||
| 147 | } | 150 | } |
| 148 | 151 | ||
| 149 | async function changePage(page) { | 152 | async function changePage(page) { |
| 150 | |||
| 151 | const pageNumbers = document.querySelector("#pageNumbers"); | 153 | const pageNumbers = document.querySelector("#pageNumbers"); |
| 152 | 154 | ||
| 153 | pageNumbers.innerText = `${currentPage - minPage + 1}/${maxPage - minPage + 1}`; | 155 | pageNumbers.innerText = `${currentPage - minPage + 1}/${maxPage - minPage + 1}`; |
| @@ -174,6 +176,9 @@ export default function Maplist(prop) { | |||
| 174 | const chapterNumber = chapterNumber1.toString().padStart(2, "0"); | 176 | const chapterNumber = chapterNumber1.toString().padStart(2, "0"); |
| 175 | const chapterTitle = name.split(" - ")[1]; | 177 | const chapterTitle = name.split(" - ")[1]; |
| 176 | 178 | ||
| 179 | if (document.querySelector(".maplist-maps") == null) { | ||
| 180 | return; | ||
| 181 | } | ||
| 177 | const chapterNumberElement = document.querySelector(".chapter-num") | 182 | const chapterNumberElement = document.querySelector(".chapter-num") |
| 178 | const chapterTitleElement = document.querySelector(".chapter-name") | 183 | const chapterTitleElement = document.querySelector(".chapter-name") |
| 179 | chapterNumberElement.innerText = chapterName + " " + chapterNumber; | 184 | chapterNumberElement.innerText = chapterName + " " + chapterNumber; |
| @@ -623,7 +628,7 @@ export default function Maplist(prop) { | |||
| 623 | } | 628 | } |
| 624 | dataPoint.style.animationDelay = delay + "s" | 629 | dataPoint.style.animationDelay = delay + "s" |
| 625 | 630 | ||
| 626 | let isHoveringOverData = false; | 631 | let isHoveringOverData = true; |
| 627 | let isDataActive = false; | 632 | let isDataActive = false; |
| 628 | document.querySelector("#dataPointInfo").style.left = item.x + "px"; | 633 | document.querySelector("#dataPointInfo").style.left = item.x + "px"; |
| 629 | document.querySelector("#dataPointInfo").style.bottom = (point_height * item.record -3) + "px"; | 634 | document.querySelector("#dataPointInfo").style.bottom = (point_height * item.record -3) + "px"; |
| @@ -671,6 +676,8 @@ export default function Maplist(prop) { | |||
| 671 | }) | 676 | }) |
| 672 | document.querySelector(".chart").addEventListener("mouseleave", () => { | 677 | document.querySelector(".chart").addEventListener("mouseleave", () => { |
| 673 | isDataActive = false | 678 | isDataActive = false |
| 679 | // fuck you | ||
| 680 | isHoveringOverData = true; | ||
| 674 | dataPoint.classList.remove("data-point-active") | 681 | dataPoint.classList.remove("data-point-active") |
| 675 | document.querySelector("#dataPointInfo").style.opacity = "0"; | 682 | document.querySelector("#dataPointInfo").style.opacity = "0"; |
| 676 | document.querySelector("#dataPointInfo").style.zIndex = "0"; | 683 | document.querySelector("#dataPointInfo").style.zIndex = "0"; |
diff --git a/frontend/src/components/record.js b/frontend/src/components/record.js index a01109c..80e084d 100644 --- a/frontend/src/components/record.js +++ b/frontend/src/components/record.js | |||
| @@ -8,16 +8,15 @@ export default function Record({ name, place, portals, time, date }) { | |||
| 8 | const [record, setRecord] = useState(null); | 8 | const [record, setRecord] = useState(null); |
| 9 | const location = useLocation(); | 9 | const location = useLocation(); |
| 10 | 10 | ||
| 11 | useEffect(() => { | 11 | // useEffect(() => { |
| 12 | console.log(name, place, portals, time, date); | 12 | // console.log(name, place, portals, time, date); |
| 13 | }) | 13 | // }) |
| 14 | 14 | ||
| 15 | function timeSince() { | 15 | function timeSince() { |
| 16 | const now = new Date(); | 16 | const now = new Date(); |
| 17 | const dateNew = new Date(date); | 17 | const dateNew = new Date(date); |
| 18 | 18 | ||
| 19 | const secondsPast = Math.floor((now - dateNew) / 1000); | 19 | const secondsPast = Math.floor((now - dateNew) / 1000); |
| 20 | console.log('Seconds past:', secondsPast); | ||
| 21 | 20 | ||
| 22 | if (secondsPast < 60) { | 21 | if (secondsPast < 60) { |
| 23 | return `${secondsPast} seconds ago`; | 22 | return `${secondsPast} seconds ago`; |
diff --git a/frontend/src/components/sidebar.js b/frontend/src/components/sidebar.js index 6777867..08e9c6e 100644 --- a/frontend/src/components/sidebar.js +++ b/frontend/src/components/sidebar.js | |||
| @@ -46,6 +46,7 @@ const [sidebar, setSidebar] = React.useState(); | |||
| 46 | // Clicked buttons | 46 | // Clicked buttons |
| 47 | function SidebarClick(x){ | 47 | function SidebarClick(x){ |
| 48 | const btn = document.querySelectorAll("button.sidebar-button"); | 48 | const btn = document.querySelectorAll("button.sidebar-button"); |
| 49 | console.log(x) | ||
| 49 | 50 | ||
| 50 | if(sidebar===1){setSidebar(0);SidebarHide()} | 51 | if(sidebar===1){setSidebar(0);SidebarHide()} |
| 51 | 52 | ||
| @@ -104,8 +105,8 @@ React.useEffect(()=>{ | |||
| 104 | if(location.pathname.includes("leaderboards")){SidebarClick(4)} | 105 | if(location.pathname.includes("leaderboards")){SidebarClick(4)} |
| 105 | if(location.pathname.includes("scorelog")){SidebarClick(5)} | 106 | if(location.pathname.includes("scorelog")){SidebarClick(5)} |
| 106 | if(location.pathname.includes("profile")){SidebarClick(6)} | 107 | if(location.pathname.includes("profile")){SidebarClick(6)} |
| 107 | if(location.pathname.includes("rules")){SidebarClick(9)} | 108 | if(location.pathname.includes("rules")){SidebarClick(8)} |
| 108 | if(location.pathname.includes("about")){SidebarClick(10)} | 109 | if(location.pathname.includes("about")){SidebarClick(9)} |
| 109 | 110 | ||
| 110 | // eslint-disable-next-line react-hooks/exhaustive-deps | 111 | // eslint-disable-next-line react-hooks/exhaustive-deps |
| 111 | }, [location.pathname]) | 112 | }, [location.pathname]) |