From 89560a61bc6e41d86acaea596762eda2da38fe50 Mon Sep 17 00:00:00 2001 From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> Date: Mon, 9 Sep 2024 19:29:42 +0300 Subject: refactor: upload run form, lots of random shit --- frontend/src/pages/About.tsx | 36 ++++++++++++++++++++++++++++++++++++ frontend/src/pages/Games.tsx | 15 +++++++-------- frontend/src/pages/Homepage.tsx | 1 + frontend/src/pages/Maplist.tsx | 11 +++-------- frontend/src/pages/Maps.tsx | 33 +++++++++++++++++++++++++-------- 5 files changed, 72 insertions(+), 24 deletions(-) create mode 100644 frontend/src/pages/About.tsx (limited to 'frontend/src/pages') diff --git a/frontend/src/pages/About.tsx b/frontend/src/pages/About.tsx new file mode 100644 index 0000000..886808b --- /dev/null +++ b/frontend/src/pages/About.tsx @@ -0,0 +1,36 @@ +import React from 'react'; +import ReactMarkdown from 'react-markdown'; + +import '../css/About.css'; + +const About: React.FC = () => { + + const [aboutText, setAboutText] = React.useState(""); + + React.useEffect(() => { + const fetchReadme = async () => { + try { + const response = await fetch( + 'https://raw.githubusercontent.com/pektezol/leastportalshub/main/README.md' + ); + if (!response.ok) { + throw new Error('Failed to fetch README'); + } + const readmeText = await response.text(); + setAboutText(readmeText); + } catch (error) { + console.error('Error fetching README:', error); + } + }; + fetchReadme(); + }, []); + + + return ( +
+ {aboutText} +
+ ); +}; + +export default About; diff --git a/frontend/src/pages/Games.tsx b/frontend/src/pages/Games.tsx index eb7177f..ea136c2 100644 --- a/frontend/src/pages/Games.tsx +++ b/frontend/src/pages/Games.tsx @@ -2,16 +2,13 @@ import React from 'react'; import GameEntry from '../components/GameEntry'; import { Game } from '../types/Game'; -import { API } from '../api/Api'; import "../css/Maps.css" -const Games: React.FC = () => { - const [games, setGames] = React.useState([]); +interface GamesProps { + games: Game[]; +} - const _fetch_games = async () => { - const games = await API.get_games(); - setGames(games); - }; +const Games: React.FC = ({ games }) => { const _page_load = () => { const loaders = document.querySelectorAll(".loader"); @@ -21,7 +18,9 @@ const Games: React.FC = () => { } React.useEffect(() => { - _fetch_games(); + document.querySelectorAll(".games-page-item-body").forEach((game, index) => { + game.innerHTML = ""; + }); _page_load(); }, []); diff --git a/frontend/src/pages/Homepage.tsx b/frontend/src/pages/Homepage.tsx index 62a8f1c..d4f3095 100644 --- a/frontend/src/pages/Homepage.tsx +++ b/frontend/src/pages/Homepage.tsx @@ -6,6 +6,7 @@ const Homepage: React.FC = () => { return (
+

lphubWelcome to Least Portals Hub!

At the moment, LPHUB is in beta state. This means that the site has only the core functionalities enabled for providing both collaborative information and competitive leaderboards.

The website should feel intuitive to navigate around. For any type of feedback, reach us at LPHUB Discord server.

diff --git a/frontend/src/pages/Maplist.tsx b/frontend/src/pages/Maplist.tsx index 3bc5f74..5d0c852 100644 --- a/frontend/src/pages/Maplist.tsx +++ b/frontend/src/pages/Maplist.tsx @@ -73,14 +73,9 @@ const Maplist: React.FC = () => { setNumChapters(games_chapters.chapters.length); } - const _fetch_maps = async () => { - const maps = await API.get_games_maps(gameId.toString()); - setLoad(true); - } - _fetch_game(); _fetch_game_chapters(); - _fetch_maps(); + setLoad(true); }, []); useEffect(() => { @@ -97,7 +92,7 @@ const Maplist: React.FC = () => {
@@ -162,7 +157,7 @@ const Maplist: React.FC = () => {
- Difficulty: + {/* Difficulty: */}
diff --git a/frontend/src/pages/Maps.tsx b/frontend/src/pages/Maps.tsx index 707d865..5548650 100644 --- a/frontend/src/pages/Maps.tsx +++ b/frontend/src/pages/Maps.tsx @@ -7,21 +7,24 @@ import Leaderboards from '../components/Leaderboards'; import Discussions from '../components/Discussions'; import ModMenu from '../components/ModMenu'; import { MapDiscussions, MapLeaderboard, MapSummary } from '../types/Map'; +import { UserProfile } from '../types/Profile'; import { API } from '../api/Api'; import "../css/Maps.css"; +import Loading from '../components/Loading'; interface MapProps { + profile?: UserProfile; isModerator: boolean; + onUploadRun: (mapID: number) => void; }; -const Maps: React.FC = ({ isModerator }) => { +const Maps: React.FC = ({ profile, isModerator, onUploadRun }) => { const [selectedRun, setSelectedRun] = React.useState(0); const [mapSummaryData, setMapSummaryData] = React.useState(undefined); const [mapLeaderboardData, setMapLeaderboardData] = React.useState(undefined); - const [mapDiscussionsData, setMapDiscussionsData] = React.useState(undefined) - + const [mapDiscussionsData, setMapDiscussionsData] = React.useState(undefined); const [navState, setNavState] = React.useState(0); @@ -51,8 +54,23 @@ const Maps: React.FC = ({ isModerator }) => { }, []); if (!mapSummaryData) { + // loading placeholder return ( - <> +
+
+
+ +
+
+ +
+ + + +
+ + +
); } @@ -66,12 +84,11 @@ const Maps: React.FC = ({ isModerator }) => {
- - + +
{mapSummaryData.map.map_name} + {profile && }
- -
-- cgit v1.2.3