aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/pages
diff options
context:
space:
mode:
authorArda Serdar Pektezol <1669855+pektezol@users.noreply.github.com>2024-09-09 19:29:42 +0300
committerArda Serdar Pektezol <1669855+pektezol@users.noreply.github.com>2024-09-09 19:29:42 +0300
commit89560a61bc6e41d86acaea596762eda2da38fe50 (patch)
tree1cf4b7c73c17f045d3f4837b480ddf7a61230a94 /frontend/src/pages
parentrefactor: rankings page (diff)
downloadlphub-89560a61bc6e41d86acaea596762eda2da38fe50.tar.gz
lphub-89560a61bc6e41d86acaea596762eda2da38fe50.tar.bz2
lphub-89560a61bc6e41d86acaea596762eda2da38fe50.zip
refactor: upload run form, lots of random shit
Diffstat (limited to 'frontend/src/pages')
-rw-r--r--frontend/src/pages/About.tsx36
-rw-r--r--frontend/src/pages/Games.tsx15
-rw-r--r--frontend/src/pages/Homepage.tsx1
-rw-r--r--frontend/src/pages/Maplist.tsx11
-rw-r--r--frontend/src/pages/Maps.tsx33
5 files changed, 72 insertions, 24 deletions
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 @@
1import React from 'react';
2import ReactMarkdown from 'react-markdown';
3
4import '../css/About.css';
5
6const About: React.FC = () => {
7
8 const [aboutText, setAboutText] = React.useState<string>("");
9
10 React.useEffect(() => {
11 const fetchReadme = async () => {
12 try {
13 const response = await fetch(
14 'https://raw.githubusercontent.com/pektezol/leastportalshub/main/README.md'
15 );
16 if (!response.ok) {
17 throw new Error('Failed to fetch README');
18 }
19 const readmeText = await response.text();
20 setAboutText(readmeText);
21 } catch (error) {
22 console.error('Error fetching README:', error);
23 }
24 };
25 fetchReadme();
26 }, []);
27
28
29 return (
30 <div id="about">
31 <ReactMarkdown>{aboutText}</ReactMarkdown>
32 </div>
33 );
34};
35
36export 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';
2 2
3import GameEntry from '../components/GameEntry'; 3import GameEntry from '../components/GameEntry';
4import { Game } from '../types/Game'; 4import { Game } from '../types/Game';
5import { API } from '../api/Api';
6import "../css/Maps.css" 5import "../css/Maps.css"
7 6
8const Games: React.FC = () => { 7interface GamesProps {
9 const [games, setGames] = React.useState<Game[]>([]); 8 games: Game[];
9}
10 10
11 const _fetch_games = async () => { 11const Games: React.FC<GamesProps> = ({ games }) => {
12 const games = await API.get_games();
13 setGames(games);
14 };
15 12
16 const _page_load = () => { 13 const _page_load = () => {
17 const loaders = document.querySelectorAll(".loader"); 14 const loaders = document.querySelectorAll(".loader");
@@ -21,7 +18,9 @@ const Games: React.FC = () => {
21 } 18 }
22 19
23 React.useEffect(() => { 20 React.useEffect(() => {
24 _fetch_games(); 21 document.querySelectorAll(".games-page-item-body").forEach((game, index) => {
22 game.innerHTML = "";
23 });
25 _page_load(); 24 _page_load();
26 }, []); 25 }, []);
27 26
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 = () => {
6 return ( 6 return (
7 <main> 7 <main>
8 <section> 8 <section>
9 <p/>
9 <h1><img src={PortalIcon} alt="lphub"/>Welcome to Least Portals Hub!</h1> 10 <h1><img src={PortalIcon} alt="lphub"/>Welcome to Least Portals Hub!</h1>
10 <p>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.</p> 11 <p>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.</p>
11 <p>The website should feel intuitive to navigate around. For any type of feedback, reach us at LPHUB Discord server.</p> 12 <p>The website should feel intuitive to navigate around. For any type of feedback, reach us at LPHUB Discord server.</p>
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 = () => {
73 setNumChapters(games_chapters.chapters.length); 73 setNumChapters(games_chapters.chapters.length);
74 } 74 }
75 75
76 const _fetch_maps = async () => {
77 const maps = await API.get_games_maps(gameId.toString());
78 setLoad(true);
79 }
80
81 _fetch_game(); 76 _fetch_game();
82 _fetch_game_chapters(); 77 _fetch_game_chapters();
83 _fetch_maps(); 78 setLoad(true);
84 }, []); 79 }, []);
85 80
86 useEffect(() => { 81 useEffect(() => {
@@ -97,7 +92,7 @@ const Maplist: React.FC = () => {
97 <Link to="/games"> 92 <Link to="/games">
98 <button className="nav-button" style={{ borderRadius: "20px" }}> 93 <button className="nav-button" style={{ borderRadius: "20px" }}>
99 <i className="triangle"></i> 94 <i className="triangle"></i>
100 <span>Games list</span> 95 <span>Games List</span>
101 </button> 96 </button>
102 </Link> 97 </Link>
103 </section> 98 </section>
@@ -162,7 +157,7 @@ const Maplist: React.FC = () => {
162 </div> 157 </div>
163 </div> 158 </div>
164 <div className="difficulty-bar"> 159 <div className="difficulty-bar">
165 <span>Difficulty:</span> 160 {/* <span>Difficulty:</span> */}
166 <div className={map.difficulty == 0 ? "one" : map.difficulty == 1 ? "two" : map.difficulty == 2 ? "three" : map.difficulty == 3 ? "four" : map.difficulty == 4 ? "five" : "one"}> 161 <div className={map.difficulty == 0 ? "one" : map.difficulty == 1 ? "two" : map.difficulty == 2 ? "three" : map.difficulty == 3 ? "four" : map.difficulty == 4 ? "five" : "one"}>
167 <div className="difficulty-point"></div> 162 <div className="difficulty-point"></div>
168 <div className="difficulty-point"></div> 163 <div className="difficulty-point"></div>
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';
7import Discussions from '../components/Discussions'; 7import Discussions from '../components/Discussions';
8import ModMenu from '../components/ModMenu'; 8import ModMenu from '../components/ModMenu';
9import { MapDiscussions, MapLeaderboard, MapSummary } from '../types/Map'; 9import { MapDiscussions, MapLeaderboard, MapSummary } from '../types/Map';
10import { UserProfile } from '../types/Profile';
10import { API } from '../api/Api'; 11import { API } from '../api/Api';
11import "../css/Maps.css"; 12import "../css/Maps.css";
13import Loading from '../components/Loading';
12 14
13interface MapProps { 15interface MapProps {
16 profile?: UserProfile;
14 isModerator: boolean; 17 isModerator: boolean;
18 onUploadRun: (mapID: number) => void;
15}; 19};
16 20
17const Maps: React.FC<MapProps> = ({ isModerator }) => { 21const Maps: React.FC<MapProps> = ({ profile, isModerator, onUploadRun }) => {
18 22
19 const [selectedRun, setSelectedRun] = React.useState<number>(0); 23 const [selectedRun, setSelectedRun] = React.useState<number>(0);
20 24
21 const [mapSummaryData, setMapSummaryData] = React.useState<MapSummary | undefined>(undefined); 25 const [mapSummaryData, setMapSummaryData] = React.useState<MapSummary | undefined>(undefined);
22 const [mapLeaderboardData, setMapLeaderboardData] = React.useState<MapLeaderboard | undefined>(undefined); 26 const [mapLeaderboardData, setMapLeaderboardData] = React.useState<MapLeaderboard | undefined>(undefined);
23 const [mapDiscussionsData, setMapDiscussionsData] = React.useState<MapDiscussions | undefined>(undefined) 27 const [mapDiscussionsData, setMapDiscussionsData] = React.useState<MapDiscussions | undefined>(undefined);
24
25 28
26 const [navState, setNavState] = React.useState<number>(0); 29 const [navState, setNavState] = React.useState<number>(0);
27 30
@@ -51,8 +54,23 @@ const Maps: React.FC<MapProps> = ({ isModerator }) => {
51 }, []); 54 }, []);
52 55
53 if (!mapSummaryData) { 56 if (!mapSummaryData) {
57 // loading placeholder
54 return ( 58 return (
55 <></> 59 <main>
60 <section id='section1' className='summary1'>
61 <div>
62 <Link to="/games"><button className='nav-button' style={{ borderRadius: "20px 20px 20px 20px" }}><i className='triangle'></i><span>Games List</span></button></Link>
63 </div>
64 </section>
65
66 <section id='section2' className='summary1'>
67 <button className='nav-button'><img src={PortalIcon} alt="" /><span>Summary</span></button>
68 <button className='nav-button'><img src={FlagIcon} alt="" /><span>Leaderboards</span></button>
69 <button className='nav-button'><img src={ChatIcon} alt="" /><span>Discussions</span></button>
70 </section>
71
72 <Loading />
73 </main>
56 ); 74 );
57 } 75 }
58 76
@@ -66,12 +84,11 @@ const Maps: React.FC<MapProps> = ({ isModerator }) => {
66 <main> 84 <main>
67 <section id='section1' className='summary1'> 85 <section id='section1' className='summary1'>
68 <div> 86 <div>
69 <Link to="/games"><button className='nav-button' style={{ borderRadius: "20px 0px 0px 20px" }}><i className='triangle'></i><span>Games list</span></button></Link> 87 <Link to="/games"><button className='nav-button' style={{ borderRadius: "20px 0px 0px 20px" }}><i className='triangle'></i><span>Games List</span></button></Link>
70 <Link to={`/games/${!mapSummaryData.map.is_coop ? "1" : "2"}?chapter=${mapSummaryData.map.chapter_name}`}><button className='nav-button' style={{ borderRadius: "0px 20px 20px 0px", marginLeft: "2px" }}><i className='triangle'></i><span>{mapSummaryData.map.chapter_name}</span></button></Link> 88 <Link to={`/games/${!mapSummaryData.map.is_coop ? "1" : "2"}?chapter=${mapSummaryData.map.chapter_name.split(" ")[1]}`}><button className='nav-button' style={{ borderRadius: "0px 20px 20px 0px", marginLeft: "2px" }}><i className='triangle'></i><span>{mapSummaryData.map.chapter_name}</span></button></Link>
71 <br /><span><b>{mapSummaryData.map.map_name}</b></span> 89 <br /><span><b>{mapSummaryData.map.map_name}</b></span>
90 {profile && <button onClick={() => onUploadRun(mapSummaryData.map.id)}>Submit a Run</button>}
72 </div> 91 </div>
73
74
75 </section> 92 </section>
76 93
77 <section id='section2' className='summary1'> 94 <section id='section2' className='summary1'>