From 4bdb77287866c47f5b61d6472b3ff9cc4020f35e Mon Sep 17 00:00:00 2001 From: Wolfboy248 <121288977+Wolfboy248@users.noreply.github.com> Date: Thu, 11 Jul 2024 19:22:00 +0200 Subject: fix: about page crash, update packages (#181) --- frontend/src/components/login.js | 6 +++++- frontend/src/components/main.css | 2 +- frontend/src/components/pages/games.js | 4 ++++ frontend/src/components/pages/maplist.js | 11 +++++++++-- frontend/src/components/record.js | 7 +++---- frontend/src/components/sidebar.js | 5 +++-- 6 files changed, 25 insertions(+), 10 deletions(-) (limited to 'frontend/src') 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); React.useEffect(() => { fetch(`https://lp.ardapektezol.com/api/v1/token`) .then(r => r.json()) - .then(d => setToken(d.data.token)) + .then(d => { + if (d.data != null) { + setToken(d.data.token) + } + }) }, []); 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 { padding-right: 30px; - /* font-size: 40px; */ + font-size: 40px; font-family: BarlowSemiCondensed-Regular; color: #cdcfdf; 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) { const location = useLocation(); useEffect(() => { + document.querySelectorAll(".games-page-item-body").forEach((game, index) => { + game.innerHTML = ""; + }) + const fetchGames = async () => { try { 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) { const data = await response.json(); let categoriesArr = data.data[gameID - 1].category_portals; + if (document.querySelector(".maplist-maps") == null) { + return; + } const gameNav = document.querySelector(".game-nav"); gameNav.innerHTML = ""; categoriesArr.forEach((category) => { @@ -147,7 +150,6 @@ export default function Maplist(prop) { } async function changePage(page) { - const pageNumbers = document.querySelector("#pageNumbers"); pageNumbers.innerText = `${currentPage - minPage + 1}/${maxPage - minPage + 1}`; @@ -174,6 +176,9 @@ export default function Maplist(prop) { const chapterNumber = chapterNumber1.toString().padStart(2, "0"); const chapterTitle = name.split(" - ")[1]; + if (document.querySelector(".maplist-maps") == null) { + return; + } const chapterNumberElement = document.querySelector(".chapter-num") const chapterTitleElement = document.querySelector(".chapter-name") chapterNumberElement.innerText = chapterName + " " + chapterNumber; @@ -623,7 +628,7 @@ export default function Maplist(prop) { } dataPoint.style.animationDelay = delay + "s" - let isHoveringOverData = false; + let isHoveringOverData = true; let isDataActive = false; document.querySelector("#dataPointInfo").style.left = item.x + "px"; document.querySelector("#dataPointInfo").style.bottom = (point_height * item.record -3) + "px"; @@ -671,6 +676,8 @@ export default function Maplist(prop) { }) document.querySelector(".chart").addEventListener("mouseleave", () => { isDataActive = false + // fuck you + isHoveringOverData = true; dataPoint.classList.remove("data-point-active") document.querySelector("#dataPointInfo").style.opacity = "0"; 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 }) { const [record, setRecord] = useState(null); const location = useLocation(); - useEffect(() => { - console.log(name, place, portals, time, date); - }) + // useEffect(() => { + // console.log(name, place, portals, time, date); + // }) function timeSince() { const now = new Date(); const dateNew = new Date(date); const secondsPast = Math.floor((now - dateNew) / 1000); - console.log('Seconds past:', secondsPast); if (secondsPast < 60) { 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(); // Clicked buttons function SidebarClick(x){ const btn = document.querySelectorAll("button.sidebar-button"); +console.log(x) if(sidebar===1){setSidebar(0);SidebarHide()} @@ -104,8 +105,8 @@ React.useEffect(()=>{ if(location.pathname.includes("leaderboards")){SidebarClick(4)} if(location.pathname.includes("scorelog")){SidebarClick(5)} if(location.pathname.includes("profile")){SidebarClick(6)} - if(location.pathname.includes("rules")){SidebarClick(9)} - if(location.pathname.includes("about")){SidebarClick(10)} + if(location.pathname.includes("rules")){SidebarClick(8)} + if(location.pathname.includes("about")){SidebarClick(9)} // eslint-disable-next-line react-hooks/exhaustive-deps }, [location.pathname]) -- cgit v1.2.3