diff options
Diffstat (limited to 'frontend/src/components')
| -rw-r--r-- | frontend/src/components/ConfirmDialog.tsx | 4 | ||||
| -rw-r--r-- | frontend/src/components/Discussions.tsx | 54 | ||||
| -rw-r--r-- | frontend/src/components/GameCategory.tsx | 10 | ||||
| -rw-r--r-- | frontend/src/components/GameEntry.tsx | 12 | ||||
| -rw-r--r-- | frontend/src/components/Leaderboards.tsx | 68 | ||||
| -rw-r--r-- | frontend/src/components/Login.tsx | 16 | ||||
| -rw-r--r-- | frontend/src/components/MapEntry.tsx | 4 | ||||
| -rw-r--r-- | frontend/src/components/MessageDialog.tsx | 4 | ||||
| -rw-r--r-- | frontend/src/components/MessageDialogLoad.tsx | 6 | ||||
| -rw-r--r-- | frontend/src/components/ModMenu.tsx | 96 | ||||
| -rw-r--r-- | frontend/src/components/RankingEntry.tsx | 8 | ||||
| -rw-r--r-- | frontend/src/components/Sidebar.tsx | 100 | ||||
| -rw-r--r-- | frontend/src/components/Summary.tsx | 68 | ||||
| -rw-r--r-- | frontend/src/components/UploadRunDialog.tsx | 108 |
14 files changed, 279 insertions, 279 deletions
diff --git a/frontend/src/components/ConfirmDialog.tsx b/frontend/src/components/ConfirmDialog.tsx index 925118d..c89d9ea 100644 --- a/frontend/src/components/ConfirmDialog.tsx +++ b/frontend/src/components/ConfirmDialog.tsx | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | import React from 'react'; | 1 | import React from "react"; |
| 2 | 2 | ||
| 3 | import '@css/Dialog.css'; | 3 | import "@css/Dialog.css"; |
| 4 | 4 | ||
| 5 | interface ConfirmDialogProps { | 5 | interface ConfirmDialogProps { |
| 6 | title: string; | 6 | title: string; |
diff --git a/frontend/src/components/Discussions.tsx b/frontend/src/components/Discussions.tsx index 994cd8e..7aa8901 100644 --- a/frontend/src/components/Discussions.tsx +++ b/frontend/src/components/Discussions.tsx | |||
| @@ -1,16 +1,16 @@ | |||
| 1 | import React from 'react'; | 1 | import React from "react"; |
| 2 | 2 | ||
| 3 | import { | 3 | import { |
| 4 | MapDiscussion, | 4 | MapDiscussion, |
| 5 | MapDiscussions, | 5 | MapDiscussions, |
| 6 | MapDiscussionsDetail, | 6 | MapDiscussionsDetail, |
| 7 | } from '@customTypes/Map'; | 7 | } from "@customTypes/Map"; |
| 8 | import { MapDiscussionContent } from '@customTypes/Content'; | 8 | import { MapDiscussionContent } from "@customTypes/Content"; |
| 9 | import { time_ago } from '@utils/Time'; | 9 | import { time_ago } from "@utils/Time"; |
| 10 | import { API } from '@api/Api'; | 10 | import { API } from "@api/Api"; |
| 11 | import '@css/Maps.css'; | 11 | import "@css/Maps.css"; |
| 12 | import { Link } from 'react-router-dom'; | 12 | import { Link } from "react-router-dom"; |
| 13 | import useConfirm from '@hooks/UseConfirm'; | 13 | import useConfirm from "@hooks/UseConfirm"; |
| 14 | 14 | ||
| 15 | interface DiscussionsProps { | 15 | interface DiscussionsProps { |
| 16 | token?: string; | 16 | token?: string; |
| @@ -32,17 +32,17 @@ const Discussions: React.FC<DiscussionsProps> = ({ | |||
| 32 | const [discussionThread, setDiscussionThread] = React.useState< | 32 | const [discussionThread, setDiscussionThread] = React.useState< |
| 33 | MapDiscussion | undefined | 33 | MapDiscussion | undefined |
| 34 | >(undefined); | 34 | >(undefined); |
| 35 | const [discussionSearch, setDiscussionSearch] = React.useState<string>(''); | 35 | const [discussionSearch, setDiscussionSearch] = React.useState<string>(""); |
| 36 | 36 | ||
| 37 | const [createDiscussion, setCreateDiscussion] = | 37 | const [createDiscussion, setCreateDiscussion] = |
| 38 | React.useState<boolean>(false); | 38 | React.useState<boolean>(false); |
| 39 | const [createDiscussionContent, setCreateDiscussionContent] = | 39 | const [createDiscussionContent, setCreateDiscussionContent] = |
| 40 | React.useState<MapDiscussionContent>({ | 40 | React.useState<MapDiscussionContent>({ |
| 41 | title: '', | 41 | title: "", |
| 42 | content: '', | 42 | content: "", |
| 43 | }); | 43 | }); |
| 44 | const [createDiscussionCommentContent, setCreateDiscussionCommentContent] = | 44 | const [createDiscussionCommentContent, setCreateDiscussionCommentContent] = |
| 45 | React.useState<string>(''); | 45 | React.useState<string>(""); |
| 46 | 46 | ||
| 47 | const _open_map_discussion = async (discussion_id: number) => { | 47 | const _open_map_discussion = async (discussion_id: number) => { |
| 48 | const mapDiscussion = await API.get_map_discussion(mapID, discussion_id); | 48 | const mapDiscussion = await API.get_map_discussion(mapID, discussion_id); |
| @@ -72,7 +72,7 @@ const Discussions: React.FC<DiscussionsProps> = ({ | |||
| 72 | const _delete_map_discussion = async (discussion: MapDiscussionsDetail) => { | 72 | const _delete_map_discussion = async (discussion: MapDiscussionsDetail) => { |
| 73 | if ( | 73 | if ( |
| 74 | await confirm( | 74 | await confirm( |
| 75 | 'Delete Map Discussion', | 75 | "Delete Map Discussion", |
| 76 | `Are you sure you want to remove post: ${discussion.title}?` | 76 | `Are you sure you want to remove post: ${discussion.title}?` |
| 77 | ) | 77 | ) |
| 78 | ) { | 78 | ) { |
| @@ -90,7 +90,7 @@ const Discussions: React.FC<DiscussionsProps> = ({ | |||
| 90 | <input | 90 | <input |
| 91 | type="text" | 91 | type="text" |
| 92 | value={discussionSearch} | 92 | value={discussionSearch} |
| 93 | placeholder={'Search for posts...'} | 93 | placeholder={"Search for posts..."} |
| 94 | onChange={e => setDiscussionSearch(e.target.value)} | 94 | onChange={e => setDiscussionSearch(e.target.value)} |
| 95 | /> | 95 | /> |
| 96 | <div> | 96 | <div> |
| @@ -104,7 +104,7 @@ const Discussions: React.FC<DiscussionsProps> = ({ | |||
| 104 | <div id="discussion-create"> | 104 | <div id="discussion-create"> |
| 105 | <span>Create Post</span> | 105 | <span>Create Post</span> |
| 106 | <button onClick={() => setCreateDiscussion(false)}>X</button> | 106 | <button onClick={() => setCreateDiscussion(false)}>X</button> |
| 107 | <div style={{ gridColumn: '1 / span 2' }}> | 107 | <div style={{ gridColumn: "1 / span 2" }}> |
| 108 | <input | 108 | <input |
| 109 | id="discussion-create-title" | 109 | id="discussion-create-title" |
| 110 | placeholder="Title..." | 110 | placeholder="Title..." |
| @@ -126,7 +126,7 @@ const Discussions: React.FC<DiscussionsProps> = ({ | |||
| 126 | } | 126 | } |
| 127 | /> | 127 | /> |
| 128 | </div> | 128 | </div> |
| 129 | <div style={{ placeItems: 'end', gridColumn: '1 / span 2' }}> | 129 | <div style={{ placeItems: "end", gridColumn: "1 / span 2" }}> |
| 130 | <button | 130 | <button |
| 131 | id="discussion-create-button" | 131 | id="discussion-create-button" |
| 132 | onClick={() => _create_map_discussion()} | 132 | onClick={() => _create_map_discussion()} |
| @@ -157,8 +157,8 @@ const Discussions: React.FC<DiscussionsProps> = ({ | |||
| 157 | {time_ago( | 157 | {time_ago( |
| 158 | new Date( | 158 | new Date( |
| 159 | discussionThread.discussion.created_at | 159 | discussionThread.discussion.created_at |
| 160 | .replace('T', ' ') | 160 | .replace("T", " ") |
| 161 | .replace('Z', '') | 161 | .replace("Z", "") |
| 162 | ) | 162 | ) |
| 163 | )} | 163 | )} |
| 164 | </span> | 164 | </span> |
| @@ -180,7 +180,7 @@ const Discussions: React.FC<DiscussionsProps> = ({ | |||
| 180 | <span> | 180 | <span> |
| 181 | {time_ago( | 181 | {time_ago( |
| 182 | new Date( | 182 | new Date( |
| 183 | e.date.replace('T', ' ').replace('Z', '') | 183 | e.date.replace("T", " ").replace("Z", "") |
| 184 | ) | 184 | ) |
| 185 | )} | 185 | )} |
| 186 | </span> | 186 | </span> |
| @@ -188,15 +188,15 @@ const Discussions: React.FC<DiscussionsProps> = ({ | |||
| 188 | </div> | 188 | </div> |
| 189 | </> | 189 | </> |
| 190 | )) | 190 | )) |
| 191 | : ''} | 191 | : ""} |
| 192 | </div> | 192 | </div> |
| 193 | <div id="discussion-send"> | 193 | <div id="discussion-send"> |
| 194 | <input | 194 | <input |
| 195 | type="text" | 195 | type="text" |
| 196 | value={createDiscussionCommentContent} | 196 | value={createDiscussionCommentContent} |
| 197 | placeholder={'Message'} | 197 | placeholder={"Message"} |
| 198 | onKeyDown={e => | 198 | onKeyDown={e => |
| 199 | e.key === 'Enter' && | 199 | e.key === "Enter" && |
| 200 | _create_map_discussion_comment(discussionThread.discussion.id) | 200 | _create_map_discussion_comment(discussionThread.discussion.id) |
| 201 | } | 201 | } |
| 202 | onChange={e => | 202 | onChange={e => |
| @@ -206,11 +206,11 @@ const Discussions: React.FC<DiscussionsProps> = ({ | |||
| 206 | <div> | 206 | <div> |
| 207 | <button | 207 | <button |
| 208 | onClick={() => { | 208 | onClick={() => { |
| 209 | if (createDiscussionCommentContent !== '') { | 209 | if (createDiscussionCommentContent !== "") { |
| 210 | _create_map_discussion_comment( | 210 | _create_map_discussion_comment( |
| 211 | discussionThread.discussion.id | 211 | discussionThread.discussion.id |
| 212 | ); | 212 | ); |
| 213 | setCreateDiscussionCommentContent(''); | 213 | setCreateDiscussionCommentContent(""); |
| 214 | } | 214 | } |
| 215 | }} | 215 | }} |
| 216 | > | 216 | > |
| @@ -248,10 +248,10 @@ const Discussions: React.FC<DiscussionsProps> = ({ | |||
| 248 | <b>{e.creator.user_name}:</b> {e.content} | 248 | <b>{e.creator.user_name}:</b> {e.content} |
| 249 | </span> | 249 | </span> |
| 250 | <span> | 250 | <span> |
| 251 | Last Updated:{' '} | 251 | Last Updated:{" "} |
| 252 | {time_ago( | 252 | {time_ago( |
| 253 | new Date( | 253 | new Date( |
| 254 | e.updated_at.replace('T', ' ').replace('Z', '') | 254 | e.updated_at.replace("T", " ").replace("Z", "") |
| 255 | ) | 255 | ) |
| 256 | )} | 256 | )} |
| 257 | </span> | 257 | </span> |
| @@ -260,7 +260,7 @@ const Discussions: React.FC<DiscussionsProps> = ({ | |||
| 260 | ))} | 260 | ))} |
| 261 | </> | 261 | </> |
| 262 | ) : ( | 262 | ) : ( |
| 263 | <span style={{ textAlign: 'center', display: 'block' }}> | 263 | <span style={{ textAlign: "center", display: "block" }}> |
| 264 | No Discussions... | 264 | No Discussions... |
| 265 | </span> | 265 | </span> |
| 266 | ) | 266 | ) |
diff --git a/frontend/src/components/GameCategory.tsx b/frontend/src/components/GameCategory.tsx index b13be48..2bb6d42 100644 --- a/frontend/src/components/GameCategory.tsx +++ b/frontend/src/components/GameCategory.tsx | |||
| @@ -1,8 +1,8 @@ | |||
| 1 | import React from 'react'; | 1 | import React from "react"; |
| 2 | import { Link } from 'react-router-dom'; | 2 | import { Link } from "react-router-dom"; |
| 3 | 3 | ||
| 4 | import { Game, GameCategoryPortals } from '@customTypes/Game'; | 4 | import { Game, GameCategoryPortals } from "@customTypes/Game"; |
| 5 | import '@css/Games.css'; | 5 | import "@css/Games.css"; |
| 6 | 6 | ||
| 7 | interface GameCategoryProps { | 7 | interface GameCategoryProps { |
| 8 | game: Game; | 8 | game: Game; |
| @@ -13,7 +13,7 @@ const GameCategory: React.FC<GameCategoryProps> = ({ cat, game }) => { | |||
| 13 | return ( | 13 | return ( |
| 14 | <Link | 14 | <Link |
| 15 | className="games-page-item-body-item" | 15 | className="games-page-item-body-item" |
| 16 | to={'/games/' + game.id + '?cat=' + cat.category.id} | 16 | to={"/games/" + game.id + "?cat=" + cat.category.id} |
| 17 | > | 17 | > |
| 18 | <div> | 18 | <div> |
| 19 | <span className="games-page-item-body-item-title"> | 19 | <span className="games-page-item-body-item-title"> |
diff --git a/frontend/src/components/GameEntry.tsx b/frontend/src/components/GameEntry.tsx index b58bbdd..04c3483 100644 --- a/frontend/src/components/GameEntry.tsx +++ b/frontend/src/components/GameEntry.tsx | |||
| @@ -1,10 +1,10 @@ | |||
| 1 | import React from 'react'; | 1 | import React from "react"; |
| 2 | import { Link } from 'react-router-dom'; | 2 | import { Link } from "react-router-dom"; |
| 3 | 3 | ||
| 4 | import { Game, GameCategoryPortals } from '@customTypes/Game'; | 4 | import { Game, GameCategoryPortals } from "@customTypes/Game"; |
| 5 | import '@css/Games.css'; | 5 | import "@css/Games.css"; |
| 6 | 6 | ||
| 7 | import GameCategory from '@components/GameCategory'; | 7 | import GameCategory from "@components/GameCategory"; |
| 8 | 8 | ||
| 9 | interface GameEntryProps { | 9 | interface GameEntryProps { |
| 10 | game: Game; | 10 | game: Game; |
| @@ -18,7 +18,7 @@ const GameEntry: React.FC<GameEntryProps> = ({ game }) => { | |||
| 18 | }, [game.category_portals]); | 18 | }, [game.category_portals]); |
| 19 | 19 | ||
| 20 | return ( | 20 | return ( |
| 21 | <Link to={'/games/' + game.id}> | 21 | <Link to={"/games/" + game.id}> |
| 22 | <div className="games-page-item"> | 22 | <div className="games-page-item"> |
| 23 | <div className="games-page-item-header"> | 23 | <div className="games-page-item-header"> |
| 24 | <div | 24 | <div |
diff --git a/frontend/src/components/Leaderboards.tsx b/frontend/src/components/Leaderboards.tsx index 801f331..b388aba 100644 --- a/frontend/src/components/Leaderboards.tsx +++ b/frontend/src/components/Leaderboards.tsx | |||
| @@ -1,12 +1,12 @@ | |||
| 1 | import React, { useCallback } from 'react'; | 1 | import React, { useCallback } from "react"; |
| 2 | import { Link, useNavigate } from 'react-router-dom'; | 2 | import { Link, useNavigate } from "react-router-dom"; |
| 3 | 3 | ||
| 4 | import { DownloadIcon, ThreedotIcon } from '@images/Images'; | 4 | import { DownloadIcon, ThreedotIcon } from "@images/Images"; |
| 5 | import { MapLeaderboard } from '@customTypes/Map'; | 5 | import { MapLeaderboard } from "@customTypes/Map"; |
| 6 | import { ticks_to_time, time_ago } from '@utils/Time'; | 6 | import { ticks_to_time, time_ago } from "@utils/Time"; |
| 7 | import { API } from '@api/Api'; | 7 | import { API } from "@api/Api"; |
| 8 | import useMessage from '@hooks/UseMessage'; | 8 | import useMessage from "@hooks/UseMessage"; |
| 9 | import '@css/Maps.css'; | 9 | import "@css/Maps.css"; |
| 10 | 10 | ||
| 11 | interface LeaderboardsProps { | 11 | interface LeaderboardsProps { |
| 12 | mapID: string; | 12 | mapID: string; |
| @@ -35,7 +35,7 @@ const Leaderboards: React.FC<LeaderboardsProps> = ({ mapID }) => { | |||
| 35 | if (!data) { | 35 | if (!data) { |
| 36 | return ( | 36 | return ( |
| 37 | <section id="section6" className="summary2"> | 37 | <section id="section6" className="summary2"> |
| 38 | <h1 style={{ textAlign: 'center' }}> | 38 | <h1 style={{ textAlign: "center" }}> |
| 39 | Map is not available for competitive boards. | 39 | Map is not available for competitive boards. |
| 40 | </h1> | 40 | </h1> |
| 41 | </section> | 41 | </section> |
| @@ -45,7 +45,7 @@ const Leaderboards: React.FC<LeaderboardsProps> = ({ mapID }) => { | |||
| 45 | if (data.records.length === 0) { | 45 | if (data.records.length === 0) { |
| 46 | return ( | 46 | return ( |
| 47 | <section id="section6" className="summary2"> | 47 | <section id="section6" className="summary2"> |
| 48 | <h1 style={{ textAlign: 'center' }}>No records found.</h1> | 48 | <h1 style={{ textAlign: "center" }}>No records found.</h1> |
| 49 | </section> | 49 | </section> |
| 50 | ); | 50 | ); |
| 51 | } | 51 | } |
| @@ -58,8 +58,8 @@ const Leaderboards: React.FC<LeaderboardsProps> = ({ mapID }) => { | |||
| 58 | id="leaderboard-top" | 58 | id="leaderboard-top" |
| 59 | style={ | 59 | style={ |
| 60 | data.map.is_coop | 60 | data.map.is_coop |
| 61 | ? { gridTemplateColumns: '7.5% 40% 7.5% 15% 15% 15%' } | 61 | ? { gridTemplateColumns: "7.5% 40% 7.5% 15% 15% 15%" } |
| 62 | : { gridTemplateColumns: '7.5% 30% 10% 20% 17.5% 15%' } | 62 | : { gridTemplateColumns: "7.5% 30% 10% 20% 17.5% 15%" } |
| 63 | } | 63 | } |
| 64 | > | 64 | > |
| 65 | <span>Place</span> | 65 | <span>Place</span> |
| @@ -87,8 +87,8 @@ const Leaderboards: React.FC<LeaderboardsProps> = ({ mapID }) => { | |||
| 87 | > | 87 | > |
| 88 | <i | 88 | <i |
| 89 | className="triangle" | 89 | className="triangle" |
| 90 | style={{ position: 'relative', left: '-5px' }} | 90 | style={{ position: "relative", left: "-5px" }} |
| 91 | ></i>{' '} | 91 | ></i>{" "} |
| 92 | </button> | 92 | </button> |
| 93 | <span> | 93 | <span> |
| 94 | {data.pagination.current_page}/{data.pagination.total_pages} | 94 | {data.pagination.current_page}/{data.pagination.total_pages} |
| @@ -103,11 +103,11 @@ const Leaderboards: React.FC<LeaderboardsProps> = ({ mapID }) => { | |||
| 103 | <i | 103 | <i |
| 104 | className="triangle" | 104 | className="triangle" |
| 105 | style={{ | 105 | style={{ |
| 106 | position: 'relative', | 106 | position: "relative", |
| 107 | left: '5px', | 107 | left: "5px", |
| 108 | transform: 'rotate(180deg)', | 108 | transform: "rotate(180deg)", |
| 109 | }} | 109 | }} |
| 110 | ></i>{' '} | 110 | ></i>{" "} |
| 111 | </button> | 111 | </button> |
| 112 | </div> | 112 | </div> |
| 113 | </div> | 113 | </div> |
| @@ -120,33 +120,33 @@ const Leaderboards: React.FC<LeaderboardsProps> = ({ mapID }) => { | |||
| 120 | key={index} | 120 | key={index} |
| 121 | style={ | 121 | style={ |
| 122 | data.map.is_coop | 122 | data.map.is_coop |
| 123 | ? { gridTemplateColumns: '3% 4.5% 40% 4% 3.5% 15% 15% 14.5%' } | 123 | ? { gridTemplateColumns: "3% 4.5% 40% 4% 3.5% 15% 15% 14.5%" } |
| 124 | : { gridTemplateColumns: '3% 4.5% 30% 4% 6% 20% 17% 15%' } | 124 | : { gridTemplateColumns: "3% 4.5% 30% 4% 6% 20% 17% 15%" } |
| 125 | } | 125 | } |
| 126 | > | 126 | > |
| 127 | <span>{r.placement}</span> | 127 | <span>{r.placement}</span> |
| 128 | <span> </span> | 128 | <span> </span> |
| 129 | {r.kind === 'multiplayer' ? ( | 129 | {r.kind === "multiplayer" ? ( |
| 130 | <div> | 130 | <div> |
| 131 | <Link to={`/users/${r.host.steam_id}`}> | 131 | <Link to={`/users/${r.host.steam_id}`}> |
| 132 | <span> | 132 | <span> |
| 133 | <img src={r.host.avatar_link} alt="" /> {' '} | 133 | <img src={r.host.avatar_link} alt="" /> {" "} |
| 134 | {r.host.user_name} | 134 | {r.host.user_name} |
| 135 | </span> | 135 | </span> |
| 136 | </Link> | 136 | </Link> |
| 137 | <Link to={`/users/${r.partner.steam_id}`}> | 137 | <Link to={`/users/${r.partner.steam_id}`}> |
| 138 | <span> | 138 | <span> |
| 139 | <img src={r.partner.avatar_link} alt="" /> {' '} | 139 | <img src={r.partner.avatar_link} alt="" /> {" "} |
| 140 | {r.partner.user_name} | 140 | {r.partner.user_name} |
| 141 | </span> | 141 | </span> |
| 142 | </Link> | 142 | </Link> |
| 143 | </div> | 143 | </div> |
| 144 | ) : ( | 144 | ) : ( |
| 145 | r.kind === 'singleplayer' && ( | 145 | r.kind === "singleplayer" && ( |
| 146 | <div> | 146 | <div> |
| 147 | <Link to={`/users/${r.user.steam_id}`}> | 147 | <Link to={`/users/${r.user.steam_id}`}> |
| 148 | <span> | 148 | <span> |
| 149 | <img src={r.user.avatar_link} alt="" /> {' '} | 149 | <img src={r.user.avatar_link} alt="" /> {" "} |
| 150 | {r.user.user_name} | 150 | {r.user.user_name} |
| 151 | </span> | 151 | </span> |
| 152 | </Link> | 152 | </Link> |
| @@ -158,25 +158,25 @@ const Leaderboards: React.FC<LeaderboardsProps> = ({ mapID }) => { | |||
| 158 | <span> </span> | 158 | <span> </span> |
| 159 | <span | 159 | <span |
| 160 | className="hover-popup" | 160 | className="hover-popup" |
| 161 | popup-text={r.score_time + ' ticks'} | 161 | popup-text={r.score_time + " ticks"} |
| 162 | > | 162 | > |
| 163 | {ticks_to_time(r.score_time)} | 163 | {ticks_to_time(r.score_time)} |
| 164 | </span> | 164 | </span> |
| 165 | <span | 165 | <span |
| 166 | className="hover-popup" | 166 | className="hover-popup" |
| 167 | popup-text={r.record_date.replace('T', ' ').split('.')[0]} | 167 | popup-text={r.record_date.replace("T", " ").split(".")[0]} |
| 168 | > | 168 | > |
| 169 | {time_ago( | 169 | {time_ago( |
| 170 | new Date(r.record_date.replace('T', ' ').replace('Z', '')) | 170 | new Date(r.record_date.replace("T", " ").replace("Z", "")) |
| 171 | )} | 171 | )} |
| 172 | </span> | 172 | </span> |
| 173 | 173 | ||
| 174 | {r.kind === 'multiplayer' ? ( | 174 | {r.kind === "multiplayer" ? ( |
| 175 | <span> | 175 | <span> |
| 176 | <button | 176 | <button |
| 177 | onClick={() => { | 177 | onClick={() => { |
| 178 | message( | 178 | message( |
| 179 | 'Demo Information', | 179 | "Demo Information", |
| 180 | `Host Demo ID: ${r.host_demo_id} \nParnter Demo ID: ${r.partner_demo_id}` | 180 | `Host Demo ID: ${r.host_demo_id} \nParnter Demo ID: ${r.partner_demo_id}` |
| 181 | ); | 181 | ); |
| 182 | }} | 182 | }} |
| @@ -193,7 +193,7 @@ const Leaderboards: React.FC<LeaderboardsProps> = ({ mapID }) => { | |||
| 193 | alt="download" | 193 | alt="download" |
| 194 | style={{ | 194 | style={{ |
| 195 | filter: | 195 | filter: |
| 196 | 'hue-rotate(160deg) contrast(60%) saturate(1000%)', | 196 | "hue-rotate(160deg) contrast(60%) saturate(1000%)", |
| 197 | }} | 197 | }} |
| 198 | /> | 198 | /> |
| 199 | </button> | 199 | </button> |
| @@ -207,17 +207,17 @@ const Leaderboards: React.FC<LeaderboardsProps> = ({ mapID }) => { | |||
| 207 | alt="download" | 207 | alt="download" |
| 208 | style={{ | 208 | style={{ |
| 209 | filter: | 209 | filter: |
| 210 | 'hue-rotate(300deg) contrast(60%) saturate(1000%)', | 210 | "hue-rotate(300deg) contrast(60%) saturate(1000%)", |
| 211 | }} | 211 | }} |
| 212 | /> | 212 | /> |
| 213 | </button> | 213 | </button> |
| 214 | </span> | 214 | </span> |
| 215 | ) : ( | 215 | ) : ( |
| 216 | r.kind === 'singleplayer' && ( | 216 | r.kind === "singleplayer" && ( |
| 217 | <span> | 217 | <span> |
| 218 | <button | 218 | <button |
| 219 | onClick={() => { | 219 | onClick={() => { |
| 220 | message('Demo Information', `Demo ID: ${r.demo_id}`); | 220 | message("Demo Information", `Demo ID: ${r.demo_id}`); |
| 221 | }} | 221 | }} |
| 222 | > | 222 | > |
| 223 | <img src={ThreedotIcon} alt="demo_id" /> | 223 | <img src={ThreedotIcon} alt="demo_id" /> |
diff --git a/frontend/src/components/Login.tsx b/frontend/src/components/Login.tsx index 093e406..1858c48 100644 --- a/frontend/src/components/Login.tsx +++ b/frontend/src/components/Login.tsx | |||
| @@ -1,10 +1,10 @@ | |||
| 1 | import React from 'react'; | 1 | import React from "react"; |
| 2 | import { Link, useNavigate } from 'react-router-dom'; | 2 | import { Link, useNavigate } from "react-router-dom"; |
| 3 | 3 | ||
| 4 | import { ExitIcon, UserIcon, LoginIcon } from '@images/Images'; | 4 | import { ExitIcon, UserIcon, LoginIcon } from "@images/Images"; |
| 5 | import { UserProfile } from '@customTypes/Profile'; | 5 | import { UserProfile } from "@customTypes/Profile"; |
| 6 | import { API } from '@api/Api'; | 6 | import { API } from "@api/Api"; |
| 7 | import '@css/Login.css'; | 7 | import "@css/Login.css"; |
| 8 | 8 | ||
| 9 | interface LoginProps { | 9 | interface LoginProps { |
| 10 | setToken: React.Dispatch<React.SetStateAction<string | undefined>>; | 10 | setToken: React.Dispatch<React.SetStateAction<string | undefined>>; |
| @@ -16,14 +16,14 @@ const Login: React.FC<LoginProps> = ({ setToken, profile, setProfile }) => { | |||
| 16 | const navigate = useNavigate(); | 16 | const navigate = useNavigate(); |
| 17 | 17 | ||
| 18 | const _login = () => { | 18 | const _login = () => { |
| 19 | window.location.href = '/api/v1/login'; | 19 | window.location.href = "/api/v1/login"; |
| 20 | }; | 20 | }; |
| 21 | 21 | ||
| 22 | const _logout = () => { | 22 | const _logout = () => { |
| 23 | setProfile(undefined); | 23 | setProfile(undefined); |
| 24 | setToken(undefined); | 24 | setToken(undefined); |
| 25 | API.delete_token(); | 25 | API.delete_token(); |
| 26 | navigate('/'); | 26 | navigate("/"); |
| 27 | }; | 27 | }; |
| 28 | 28 | ||
| 29 | return ( | 29 | return ( |
diff --git a/frontend/src/components/MapEntry.tsx b/frontend/src/components/MapEntry.tsx index f1dee5b..985e806 100644 --- a/frontend/src/components/MapEntry.tsx +++ b/frontend/src/components/MapEntry.tsx | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | import React from 'react'; | 1 | import React from "react"; |
| 2 | import { Link } from 'react-router-dom'; | 2 | import { Link } from "react-router-dom"; |
| 3 | 3 | ||
| 4 | const MapEntry: React.FC = () => { | 4 | const MapEntry: React.FC = () => { |
| 5 | return <div></div>; | 5 | return <div></div>; |
diff --git a/frontend/src/components/MessageDialog.tsx b/frontend/src/components/MessageDialog.tsx index b739ebc..fcf4d8d 100644 --- a/frontend/src/components/MessageDialog.tsx +++ b/frontend/src/components/MessageDialog.tsx | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | import React from 'react'; | 1 | import React from "react"; |
| 2 | 2 | ||
| 3 | import '@css/Dialog.css'; | 3 | import "@css/Dialog.css"; |
| 4 | 4 | ||
| 5 | interface MessageDialogProps { | 5 | interface MessageDialogProps { |
| 6 | title: string; | 6 | title: string; |
diff --git a/frontend/src/components/MessageDialogLoad.tsx b/frontend/src/components/MessageDialogLoad.tsx index acea27d..64cdd29 100644 --- a/frontend/src/components/MessageDialogLoad.tsx +++ b/frontend/src/components/MessageDialogLoad.tsx | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | import React from 'react'; | 1 | import React from "react"; |
| 2 | 2 | ||
| 3 | import '@css/Dialog.css'; | 3 | import "@css/Dialog.css"; |
| 4 | 4 | ||
| 5 | interface MessageDialogLoadProps { | 5 | interface MessageDialogLoadProps { |
| 6 | title: string; | 6 | title: string; |
| @@ -18,7 +18,7 @@ const MessageDialogLoad: React.FC<MessageDialogLoadProps> = ({ | |||
| 18 | <span>{title}</span> | 18 | <span>{title}</span> |
| 19 | </div> | 19 | </div> |
| 20 | <div className="dialog-element dialog-description"> | 20 | <div className="dialog-element dialog-description"> |
| 21 | <div style={{ display: 'flex', justifyContent: 'center' }}> | 21 | <div style={{ display: "flex", justifyContent: "center" }}> |
| 22 | <span className="loader"></span> | 22 | <span className="loader"></span> |
| 23 | </div> | 23 | </div> |
| 24 | </div> | 24 | </div> |
diff --git a/frontend/src/components/ModMenu.tsx b/frontend/src/components/ModMenu.tsx index 140d6a3..618d1a7 100644 --- a/frontend/src/components/ModMenu.tsx +++ b/frontend/src/components/ModMenu.tsx | |||
| @@ -1,12 +1,12 @@ | |||
| 1 | import React from 'react'; | 1 | import React from "react"; |
| 2 | import ReactMarkdown from 'react-markdown'; | 2 | import ReactMarkdown from "react-markdown"; |
| 3 | import { useNavigate } from 'react-router-dom'; | 3 | import { useNavigate } from "react-router-dom"; |
| 4 | 4 | ||
| 5 | import { MapSummary } from '@customTypes/Map'; | 5 | import { MapSummary } from "@customTypes/Map"; |
| 6 | import { ModMenuContent } from '@customTypes/Content'; | 6 | import { ModMenuContent } from "@customTypes/Content"; |
| 7 | import { API } from '@api/Api'; | 7 | import { API } from "@api/Api"; |
| 8 | import '@css/ModMenu.css'; | 8 | import "@css/ModMenu.css"; |
| 9 | import useConfirm from '@hooks/UseConfirm'; | 9 | import useConfirm from "@hooks/UseConfirm"; |
| 10 | 10 | ||
| 11 | interface ModMenuProps { | 11 | interface ModMenuProps { |
| 12 | token?: string; | 12 | token?: string; |
| @@ -28,16 +28,16 @@ const ModMenu: React.FC<ModMenuProps> = ({ | |||
| 28 | 28 | ||
| 29 | const [routeContent, setRouteContent] = React.useState<ModMenuContent>({ | 29 | const [routeContent, setRouteContent] = React.useState<ModMenuContent>({ |
| 30 | id: 0, | 30 | id: 0, |
| 31 | name: '', | 31 | name: "", |
| 32 | score: 0, | 32 | score: 0, |
| 33 | date: '', | 33 | date: "", |
| 34 | showcase: '', | 34 | showcase: "", |
| 35 | description: 'No description available.', | 35 | description: "No description available.", |
| 36 | category_id: 1, | 36 | category_id: 1, |
| 37 | }); | 37 | }); |
| 38 | 38 | ||
| 39 | const [image, setImage] = React.useState<string>(''); | 39 | const [image, setImage] = React.useState<string>(""); |
| 40 | const [md, setMd] = React.useState<string>(''); | 40 | const [md, setMd] = React.useState<string>(""); |
| 41 | 41 | ||
| 42 | const navigate = useNavigate(); | 42 | const navigate = useNavigate(); |
| 43 | 43 | ||
| @@ -47,7 +47,7 @@ const ModMenu: React.FC<ModMenuProps> = ({ | |||
| 47 | return new Promise(resolve => { | 47 | return new Promise(resolve => { |
| 48 | reader.onload = () => { | 48 | reader.onload = () => { |
| 49 | const img = new Image(); | 49 | const img = new Image(); |
| 50 | if (typeof reader.result === 'string') { | 50 | if (typeof reader.result === "string") { |
| 51 | img.src = reader.result; | 51 | img.src = reader.result; |
| 52 | img.onload = () => { | 52 | img.onload = () => { |
| 53 | let { width, height } = img; | 53 | let { width, height } = img; |
| @@ -59,10 +59,10 @@ const ModMenu: React.FC<ModMenuProps> = ({ | |||
| 59 | width *= 320 / height; | 59 | width *= 320 / height; |
| 60 | height = 320; | 60 | height = 320; |
| 61 | } | 61 | } |
| 62 | const canvas = document.createElement('canvas'); | 62 | const canvas = document.createElement("canvas"); |
| 63 | canvas.width = width; | 63 | canvas.width = width; |
| 64 | canvas.height = height; | 64 | canvas.height = height; |
| 65 | canvas.getContext('2d')!.drawImage(img, 0, 0, width, height); | 65 | canvas.getContext("2d")!.drawImage(img, 0, 0, width, height); |
| 66 | resolve(canvas.toDataURL(file.type, 0.6)); | 66 | resolve(canvas.toDataURL(file.type, 0.6)); |
| 67 | }; | 67 | }; |
| 68 | } | 68 | } |
| @@ -73,8 +73,8 @@ const ModMenu: React.FC<ModMenuProps> = ({ | |||
| 73 | const _edit_map_summary_image = async () => { | 73 | const _edit_map_summary_image = async () => { |
| 74 | if ( | 74 | if ( |
| 75 | await confirm( | 75 | await confirm( |
| 76 | 'Edit Map Summary Image', | 76 | "Edit Map Summary Image", |
| 77 | 'Are you sure you want to submit this to the database?' | 77 | "Are you sure you want to submit this to the database?" |
| 78 | ) | 78 | ) |
| 79 | ) { | 79 | ) { |
| 80 | if (token) { | 80 | if (token) { |
| @@ -82,7 +82,7 @@ const ModMenu: React.FC<ModMenuProps> = ({ | |||
| 82 | if (success) { | 82 | if (success) { |
| 83 | navigate(0); | 83 | navigate(0); |
| 84 | } else { | 84 | } else { |
| 85 | alert('Error. Check logs.'); | 85 | alert("Error. Check logs."); |
| 86 | } | 86 | } |
| 87 | } | 87 | } |
| 88 | } | 88 | } |
| @@ -91,17 +91,17 @@ const ModMenu: React.FC<ModMenuProps> = ({ | |||
| 91 | const _edit_map_summary_route = async () => { | 91 | const _edit_map_summary_route = async () => { |
| 92 | if ( | 92 | if ( |
| 93 | await confirm( | 93 | await confirm( |
| 94 | 'Edit Map Summary Route', | 94 | "Edit Map Summary Route", |
| 95 | 'Are you sure you want to submit this to the database?' | 95 | "Are you sure you want to submit this to the database?" |
| 96 | ) | 96 | ) |
| 97 | ) { | 97 | ) { |
| 98 | if (token) { | 98 | if (token) { |
| 99 | routeContent.date += 'T00:00:00Z'; | 99 | routeContent.date += "T00:00:00Z"; |
| 100 | const success = await API.put_map_summary(token, mapID, routeContent); | 100 | const success = await API.put_map_summary(token, mapID, routeContent); |
| 101 | if (success) { | 101 | if (success) { |
| 102 | navigate(0); | 102 | navigate(0); |
| 103 | } else { | 103 | } else { |
| 104 | alert('Error. Check logs.'); | 104 | alert("Error. Check logs."); |
| 105 | } | 105 | } |
| 106 | } | 106 | } |
| 107 | } | 107 | } |
| @@ -110,17 +110,17 @@ const ModMenu: React.FC<ModMenuProps> = ({ | |||
| 110 | const _create_map_summary_route = async () => { | 110 | const _create_map_summary_route = async () => { |
| 111 | if ( | 111 | if ( |
| 112 | await confirm( | 112 | await confirm( |
| 113 | 'Create Map Summary Route', | 113 | "Create Map Summary Route", |
| 114 | 'Are you sure you want to submit this to the database?' | 114 | "Are you sure you want to submit this to the database?" |
| 115 | ) | 115 | ) |
| 116 | ) { | 116 | ) { |
| 117 | if (token) { | 117 | if (token) { |
| 118 | routeContent.date += 'T00:00:00Z'; | 118 | routeContent.date += "T00:00:00Z"; |
| 119 | const success = await API.post_map_summary(token, mapID, routeContent); | 119 | const success = await API.post_map_summary(token, mapID, routeContent); |
| 120 | if (success) { | 120 | if (success) { |
| 121 | navigate(0); | 121 | navigate(0); |
| 122 | } else { | 122 | } else { |
| 123 | alert('Error. Check logs.'); | 123 | alert("Error. Check logs."); |
| 124 | } | 124 | } |
| 125 | } | 125 | } |
| 126 | } | 126 | } |
| @@ -129,7 +129,7 @@ const ModMenu: React.FC<ModMenuProps> = ({ | |||
| 129 | const _delete_map_summary_route = async () => { | 129 | const _delete_map_summary_route = async () => { |
| 130 | if ( | 130 | if ( |
| 131 | await confirm( | 131 | await confirm( |
| 132 | 'Delete Map Summary Route', | 132 | "Delete Map Summary Route", |
| 133 | `Are you sure you want to submit this to the database?\n | 133 | `Are you sure you want to submit this to the database?\n |
| 134 | ${data.summary.routes[selectedRun].category.name}\n${data.summary.routes[selectedRun].history.score_count} portals\n${data.summary.routes[selectedRun].history.runner_name}` | 134 | ${data.summary.routes[selectedRun].category.name}\n${data.summary.routes[selectedRun].history.score_count} portals\n${data.summary.routes[selectedRun].history.runner_name}` |
| 135 | ) | 135 | ) |
| @@ -143,7 +143,7 @@ const ModMenu: React.FC<ModMenuProps> = ({ | |||
| 143 | if (success) { | 143 | if (success) { |
| 144 | navigate(0); | 144 | navigate(0); |
| 145 | } else { | 145 | } else { |
| 146 | alert('Error. Check logs.'); | 146 | alert("Error. Check logs."); |
| 147 | } | 147 | } |
| 148 | } | 148 | } |
| 149 | } | 149 | } |
| @@ -154,14 +154,14 @@ const ModMenu: React.FC<ModMenuProps> = ({ | |||
| 154 | // add route | 154 | // add route |
| 155 | setRouteContent({ | 155 | setRouteContent({ |
| 156 | id: 0, | 156 | id: 0, |
| 157 | name: '', | 157 | name: "", |
| 158 | score: 0, | 158 | score: 0, |
| 159 | date: '', | 159 | date: "", |
| 160 | showcase: '', | 160 | showcase: "", |
| 161 | description: 'No description available.', | 161 | description: "No description available.", |
| 162 | category_id: 1, | 162 | category_id: 1, |
| 163 | }); | 163 | }); |
| 164 | setMd('No description available.'); | 164 | setMd("No description available."); |
| 165 | } | 165 | } |
| 166 | if (menu === 2) { | 166 | if (menu === 2) { |
| 167 | // edit route | 167 | // edit route |
| @@ -169,7 +169,7 @@ const ModMenu: React.FC<ModMenuProps> = ({ | |||
| 169 | id: data.summary.routes[selectedRun].route_id, | 169 | id: data.summary.routes[selectedRun].route_id, |
| 170 | name: data.summary.routes[selectedRun].history.runner_name, | 170 | name: data.summary.routes[selectedRun].history.runner_name, |
| 171 | score: data.summary.routes[selectedRun].history.score_count, | 171 | score: data.summary.routes[selectedRun].history.score_count, |
| 172 | date: data.summary.routes[selectedRun].history.date.split('T')[0], | 172 | date: data.summary.routes[selectedRun].history.date.split("T")[0], |
| 173 | showcase: data.summary.routes[selectedRun].showcase, | 173 | showcase: data.summary.routes[selectedRun].showcase, |
| 174 | description: data.summary.routes[selectedRun].description, | 174 | description: data.summary.routes[selectedRun].description, |
| 175 | category_id: data.summary.routes[selectedRun].category.id, | 175 | category_id: data.summary.routes[selectedRun].category.id, |
| @@ -179,20 +179,20 @@ const ModMenu: React.FC<ModMenuProps> = ({ | |||
| 179 | }, [menu, data.summary.routes, selectedRun]); | 179 | }, [menu, data.summary.routes, selectedRun]); |
| 180 | 180 | ||
| 181 | React.useEffect(() => { | 181 | React.useEffect(() => { |
| 182 | const modview = document.querySelector('div#modview') as HTMLElement; | 182 | const modview = document.querySelector("div#modview") as HTMLElement; |
| 183 | if (modview) { | 183 | if (modview) { |
| 184 | showButton | 184 | showButton |
| 185 | ? (modview.style.transform = 'translateY(-68%)') | 185 | ? (modview.style.transform = "translateY(-68%)") |
| 186 | : (modview.style.transform = 'translateY(0%)'); | 186 | : (modview.style.transform = "translateY(0%)"); |
| 187 | } | 187 | } |
| 188 | 188 | ||
| 189 | const modview_block = document.querySelector( | 189 | const modview_block = document.querySelector( |
| 190 | '#modview_block' | 190 | "#modview_block" |
| 191 | ) as HTMLElement; | 191 | ) as HTMLElement; |
| 192 | if (modview_block) { | 192 | if (modview_block) { |
| 193 | showButton | 193 | showButton |
| 194 | ? (modview_block.style.display = 'none') | 194 | ? (modview_block.style.display = "none") |
| 195 | : (modview_block.style.display = 'block'); | 195 | : (modview_block.style.display = "block"); |
| 196 | } | 196 | } |
| 197 | }, [showButton]); | 197 | }, [showButton]); |
| 198 | 198 | ||
| @@ -322,7 +322,7 @@ const ModMenu: React.FC<ModMenuProps> = ({ | |||
| 322 | </div> | 322 | </div> |
| 323 | <div | 323 | <div |
| 324 | id="modview-route-description" | 324 | id="modview-route-description" |
| 325 | style={{ height: '180px', gridColumn: '1 / span 5' }} | 325 | style={{ height: "180px", gridColumn: "1 / span 5" }} |
| 326 | > | 326 | > |
| 327 | <span>Description:</span> | 327 | <span>Description:</span> |
| 328 | <textarea | 328 | <textarea |
| @@ -337,7 +337,7 @@ const ModMenu: React.FC<ModMenuProps> = ({ | |||
| 337 | /> | 337 | /> |
| 338 | </div> | 338 | </div> |
| 339 | <button | 339 | <button |
| 340 | style={{ gridColumn: '2 / span 3', height: '40px' }} | 340 | style={{ gridColumn: "2 / span 3", height: "40px" }} |
| 341 | onClick={_edit_map_summary_route} | 341 | onClick={_edit_map_summary_route} |
| 342 | > | 342 | > |
| 343 | Apply | 343 | Apply |
| @@ -391,8 +391,8 @@ const ModMenu: React.FC<ModMenuProps> = ({ | |||
| 391 | <option value="2" key="2"> | 391 | <option value="2" key="2"> |
| 392 | No SLA | 392 | No SLA |
| 393 | </option> | 393 | </option> |
| 394 | {data.map.game_name === 'Portal 2 - Cooperative' ? ( | 394 | {data.map.game_name === "Portal 2 - Cooperative" ? ( |
| 395 | '' | 395 | "" |
| 396 | ) : ( | 396 | ) : ( |
| 397 | <option value="3" key="3"> | 397 | <option value="3" key="3"> |
| 398 | Inbounds SLA | 398 | Inbounds SLA |
| @@ -457,7 +457,7 @@ const ModMenu: React.FC<ModMenuProps> = ({ | |||
| 457 | </div> | 457 | </div> |
| 458 | <div | 458 | <div |
| 459 | id="modview-route-description" | 459 | id="modview-route-description" |
| 460 | style={{ height: '180px', gridColumn: '1 / span 5' }} | 460 | style={{ height: "180px", gridColumn: "1 / span 5" }} |
| 461 | > | 461 | > |
| 462 | <span>Description:</span> | 462 | <span>Description:</span> |
| 463 | <textarea | 463 | <textarea |
| @@ -472,7 +472,7 @@ const ModMenu: React.FC<ModMenuProps> = ({ | |||
| 472 | /> | 472 | /> |
| 473 | </div> | 473 | </div> |
| 474 | <button | 474 | <button |
| 475 | style={{ gridColumn: '2 / span 3', height: '40px' }} | 475 | style={{ gridColumn: "2 / span 3", height: "40px" }} |
| 476 | onClick={_create_map_summary_route} | 476 | onClick={_create_map_summary_route} |
| 477 | > | 477 | > |
| 478 | Apply | 478 | Apply |
diff --git a/frontend/src/components/RankingEntry.tsx b/frontend/src/components/RankingEntry.tsx index f45ca35..f28eabf 100644 --- a/frontend/src/components/RankingEntry.tsx +++ b/frontend/src/components/RankingEntry.tsx | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | import React from 'react'; | 1 | import React from "react"; |
| 2 | import { Link } from 'react-router-dom'; | 2 | import { Link } from "react-router-dom"; |
| 3 | import { RankingType, SteamRankingType } from '@customTypes/Ranking'; | 3 | import { RankingType, SteamRankingType } from "@customTypes/Ranking"; |
| 4 | 4 | ||
| 5 | enum RankingCategories { | 5 | enum RankingCategories { |
| 6 | rankings_overall, | 6 | rankings_overall, |
| @@ -14,7 +14,7 @@ interface RankingEntryProps { | |||
| 14 | } | 14 | } |
| 15 | 15 | ||
| 16 | const RankingEntry: React.FC<RankingEntryProps> = prop => { | 16 | const RankingEntry: React.FC<RankingEntryProps> = prop => { |
| 17 | if ('placement' in prop.curRankingData) { | 17 | if ("placement" in prop.curRankingData) { |
| 18 | return ( | 18 | return ( |
| 19 | <div className="leaderboard-entry"> | 19 | <div className="leaderboard-entry"> |
| 20 | <span>{prop.curRankingData.placement}</span> | 20 | <span>{prop.curRankingData.placement}</span> |
diff --git a/frontend/src/components/Sidebar.tsx b/frontend/src/components/Sidebar.tsx index 8216cff..b55d56b 100644 --- a/frontend/src/components/Sidebar.tsx +++ b/frontend/src/components/Sidebar.tsx | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | import React, { useCallback } from 'react'; | 1 | import React, { useCallback } from "react"; |
| 2 | import { Link, useLocation } from 'react-router-dom'; | 2 | import { Link, useLocation } from "react-router-dom"; |
| 3 | 3 | ||
| 4 | import { | 4 | import { |
| 5 | BookIcon, | 5 | BookIcon, |
| @@ -10,12 +10,12 @@ import { | |||
| 10 | PortalIcon, | 10 | PortalIcon, |
| 11 | SearchIcon, | 11 | SearchIcon, |
| 12 | UploadIcon, | 12 | UploadIcon, |
| 13 | } from '@images/Images'; | 13 | } from "@images/Images"; |
| 14 | import Login from '@components/Login'; | 14 | import Login from "@components/Login"; |
| 15 | import { UserProfile } from '@customTypes/Profile'; | 15 | import { UserProfile } from "@customTypes/Profile"; |
| 16 | import { Search } from '@customTypes/Search'; | 16 | import { Search } from "@customTypes/Search"; |
| 17 | import { API } from '@api/Api'; | 17 | import { API } from "@api/Api"; |
| 18 | import '@css/Sidebar.css'; | 18 | import "@css/Sidebar.css"; |
| 19 | 19 | ||
| 20 | interface SidebarProps { | 20 | interface SidebarProps { |
| 21 | setToken: React.Dispatch<React.SetStateAction<string | undefined>>; | 21 | setToken: React.Dispatch<React.SetStateAction<string | undefined>>; |
| @@ -41,81 +41,81 @@ const Sidebar: React.FC<SidebarProps> = ({ | |||
| 41 | 41 | ||
| 42 | const _handle_sidebar_hide = useCallback(() => { | 42 | const _handle_sidebar_hide = useCallback(() => { |
| 43 | var btn = document.querySelectorAll( | 43 | var btn = document.querySelectorAll( |
| 44 | 'button.sidebar-button' | 44 | "button.sidebar-button" |
| 45 | ) as NodeListOf<HTMLElement>; | 45 | ) as NodeListOf<HTMLElement>; |
| 46 | const span = document.querySelectorAll( | 46 | const span = document.querySelectorAll( |
| 47 | 'button.sidebar-button>span' | 47 | "button.sidebar-button>span" |
| 48 | ) as NodeListOf<HTMLElement>; | 48 | ) as NodeListOf<HTMLElement>; |
| 49 | const side = document.querySelector('#sidebar-list') as HTMLElement; | 49 | const side = document.querySelector("#sidebar-list") as HTMLElement; |
| 50 | const searchbar = document.querySelector('#searchbar') as HTMLInputElement; | 50 | const searchbar = document.querySelector("#searchbar") as HTMLInputElement; |
| 51 | const uploadRunBtn = document.querySelector( | 51 | const uploadRunBtn = document.querySelector( |
| 52 | '#upload-run' | 52 | "#upload-run" |
| 53 | ) as HTMLInputElement; | 53 | ) as HTMLInputElement; |
| 54 | const uploadRunSpan = document.querySelector( | 54 | const uploadRunSpan = document.querySelector( |
| 55 | '#upload-run>span' | 55 | "#upload-run>span" |
| 56 | ) as HTMLInputElement; | 56 | ) as HTMLInputElement; |
| 57 | 57 | ||
| 58 | if (isSidebarOpen) { | 58 | if (isSidebarOpen) { |
| 59 | if (profile) { | 59 | if (profile) { |
| 60 | const login = document.querySelectorAll( | 60 | const login = document.querySelectorAll( |
| 61 | '.login>button' | 61 | ".login>button" |
| 62 | )[1] as HTMLElement; | 62 | )[1] as HTMLElement; |
| 63 | login.style.opacity = '1'; | 63 | login.style.opacity = "1"; |
| 64 | uploadRunBtn.style.width = '310px'; | 64 | uploadRunBtn.style.width = "310px"; |
| 65 | uploadRunBtn.style.padding = '0.4em 0 0 11px'; | 65 | uploadRunBtn.style.padding = "0.4em 0 0 11px"; |
| 66 | uploadRunSpan.style.opacity = '0'; | 66 | uploadRunSpan.style.opacity = "0"; |
| 67 | setTimeout(() => { | 67 | setTimeout(() => { |
| 68 | uploadRunSpan.style.opacity = '1'; | 68 | uploadRunSpan.style.opacity = "1"; |
| 69 | }, 100); | 69 | }, 100); |
| 70 | } | 70 | } |
| 71 | setSidebarOpen(false); | 71 | setSidebarOpen(false); |
| 72 | side.style.width = '320px'; | 72 | side.style.width = "320px"; |
| 73 | btn.forEach((e, i) => { | 73 | btn.forEach((e, i) => { |
| 74 | e.style.width = '310px'; | 74 | e.style.width = "310px"; |
| 75 | e.style.padding = '0.4em 0 0 11px'; | 75 | e.style.padding = "0.4em 0 0 11px"; |
| 76 | setTimeout(() => { | 76 | setTimeout(() => { |
| 77 | span[i].style.opacity = '1'; | 77 | span[i].style.opacity = "1"; |
| 78 | }, 100); | 78 | }, 100); |
| 79 | }); | 79 | }); |
| 80 | side.style.zIndex = '2'; | 80 | side.style.zIndex = "2"; |
| 81 | } else { | 81 | } else { |
| 82 | if (profile) { | 82 | if (profile) { |
| 83 | const login = document.querySelectorAll( | 83 | const login = document.querySelectorAll( |
| 84 | '.login>button' | 84 | ".login>button" |
| 85 | )[1] as HTMLElement; | 85 | )[1] as HTMLElement; |
| 86 | login.style.opacity = '0'; | 86 | login.style.opacity = "0"; |
| 87 | uploadRunBtn.style.width = '40px'; | 87 | uploadRunBtn.style.width = "40px"; |
| 88 | uploadRunBtn.style.padding = '0.4em 0 0 5px'; | 88 | uploadRunBtn.style.padding = "0.4em 0 0 5px"; |
| 89 | uploadRunSpan.style.opacity = '0'; | 89 | uploadRunSpan.style.opacity = "0"; |
| 90 | } | 90 | } |
| 91 | setSidebarOpen(true); | 91 | setSidebarOpen(true); |
| 92 | side.style.width = '40px'; | 92 | side.style.width = "40px"; |
| 93 | searchbar.focus(); | 93 | searchbar.focus(); |
| 94 | btn.forEach((e, i) => { | 94 | btn.forEach((e, i) => { |
| 95 | e.style.width = '40px'; | 95 | e.style.width = "40px"; |
| 96 | e.style.padding = '0.4em 0 0 5px'; | 96 | e.style.padding = "0.4em 0 0 5px"; |
| 97 | span[i].style.opacity = '0'; | 97 | span[i].style.opacity = "0"; |
| 98 | }); | 98 | }); |
| 99 | setTimeout(() => { | 99 | setTimeout(() => { |
| 100 | side.style.zIndex = '0'; | 100 | side.style.zIndex = "0"; |
| 101 | }, 300); | 101 | }, 300); |
| 102 | } | 102 | } |
| 103 | }, [isSidebarOpen, profile]); | 103 | }, [isSidebarOpen, profile]); |
| 104 | 104 | ||
| 105 | const handle_sidebar_click = useCallback( | 105 | const handle_sidebar_click = useCallback( |
| 106 | (clicked_sidebar_idx: number) => { | 106 | (clicked_sidebar_idx: number) => { |
| 107 | const btn = document.querySelectorAll('button.sidebar-button'); | 107 | const btn = document.querySelectorAll("button.sidebar-button"); |
| 108 | if (isSidebarOpen) { | 108 | if (isSidebarOpen) { |
| 109 | setSidebarOpen(false); | 109 | setSidebarOpen(false); |
| 110 | _handle_sidebar_hide(); | 110 | _handle_sidebar_hide(); |
| 111 | } | 111 | } |
| 112 | // clusterfuck | 112 | // clusterfuck |
| 113 | btn.forEach((e, i) => { | 113 | btn.forEach((e, i) => { |
| 114 | btn[i].classList.remove('sidebar-button-selected'); | 114 | btn[i].classList.remove("sidebar-button-selected"); |
| 115 | btn[i].classList.add('sidebar-button-deselected'); | 115 | btn[i].classList.add("sidebar-button-deselected"); |
| 116 | }); | 116 | }); |
| 117 | btn[clicked_sidebar_idx].classList.add('sidebar-button-selected'); | 117 | btn[clicked_sidebar_idx].classList.add("sidebar-button-selected"); |
| 118 | btn[clicked_sidebar_idx].classList.remove('sidebar-button-deselected'); | 118 | btn[clicked_sidebar_idx].classList.remove("sidebar-button-deselected"); |
| 119 | }, | 119 | }, |
| 120 | [isSidebarOpen, _handle_sidebar_hide] | 120 | [isSidebarOpen, _handle_sidebar_hide] |
| 121 | ); | 121 | ); |
| @@ -134,20 +134,20 @@ const Sidebar: React.FC<SidebarProps> = ({ | |||
| 134 | }; | 134 | }; |
| 135 | 135 | ||
| 136 | React.useEffect(() => { | 136 | React.useEffect(() => { |
| 137 | if (path === '/') { | 137 | if (path === "/") { |
| 138 | handle_sidebar_click(1); | 138 | handle_sidebar_click(1); |
| 139 | } else if (path.includes('games')) { | 139 | } else if (path.includes("games")) { |
| 140 | handle_sidebar_click(2); | 140 | handle_sidebar_click(2); |
| 141 | } else if (path.includes('rankings')) { | 141 | } else if (path.includes("rankings")) { |
| 142 | handle_sidebar_click(3); | 142 | handle_sidebar_click(3); |
| 143 | } | 143 | } |
| 144 | // else if (path.includes("news")) { handle_sidebar_click(4) } | 144 | // else if (path.includes("news")) { handle_sidebar_click(4) } |
| 145 | // else if (path.includes("scorelog")) { handle_sidebar_click(5) } | 145 | // else if (path.includes("scorelog")) { handle_sidebar_click(5) } |
| 146 | else if (path.includes('profile')) { | 146 | else if (path.includes("profile")) { |
| 147 | handle_sidebar_click(4); | 147 | handle_sidebar_click(4); |
| 148 | } else if (path.includes('rules')) { | 148 | } else if (path.includes("rules")) { |
| 149 | handle_sidebar_click(5); | 149 | handle_sidebar_click(5); |
| 150 | } else if (path.includes('about')) { | 150 | } else if (path.includes("about")) { |
| 151 | handle_sidebar_click(6); | 151 | handle_sidebar_click(6); |
| 152 | } | 152 | } |
| 153 | }, [path, handle_sidebar_click]); | 153 | }, [path, handle_sidebar_click]); |
| @@ -156,9 +156,9 @@ const Sidebar: React.FC<SidebarProps> = ({ | |||
| 156 | <div id="sidebar"> | 156 | <div id="sidebar"> |
| 157 | <Link to="/" tabIndex={-1}> | 157 | <Link to="/" tabIndex={-1}> |
| 158 | <div id="logo"> | 158 | <div id="logo"> |
| 159 | {' '} | 159 | {" "} |
| 160 | {/* logo */} | 160 | {/* logo */} |
| 161 | <img src={LogoIcon} alt="" height={'80px'} /> | 161 | <img src={LogoIcon} alt="" height={"80px"} /> |
| 162 | <div id="logo-text"> | 162 | <div id="logo-text"> |
| 163 | <span> | 163 | <span> |
| 164 | <b>PORTAL 2</b> | 164 | <b>PORTAL 2</b> |
| @@ -169,10 +169,10 @@ const Sidebar: React.FC<SidebarProps> = ({ | |||
| 169 | </div> | 169 | </div> |
| 170 | </Link> | 170 | </Link> |
| 171 | <div id="sidebar-list"> | 171 | <div id="sidebar-list"> |
| 172 | {' '} | 172 | {" "} |
| 173 | {/* List */} | 173 | {/* List */} |
| 174 | <div id="sidebar-toplist"> | 174 | <div id="sidebar-toplist"> |
| 175 | {' '} | 175 | {" "} |
| 176 | {/* Top */} | 176 | {/* Top */} |
| 177 | <button | 177 | <button |
| 178 | className="sidebar-button" | 178 | className="sidebar-button" |
diff --git a/frontend/src/components/Summary.tsx b/frontend/src/components/Summary.tsx index 9f39506..61e52d4 100644 --- a/frontend/src/components/Summary.tsx +++ b/frontend/src/components/Summary.tsx | |||
| @@ -1,8 +1,8 @@ | |||
| 1 | import React from 'react'; | 1 | import React from "react"; |
| 2 | import ReactMarkdown from 'react-markdown'; | 2 | import ReactMarkdown from "react-markdown"; |
| 3 | 3 | ||
| 4 | import { MapSummary } from '@customTypes/Map'; | 4 | import { MapSummary } from "@customTypes/Map"; |
| 5 | import '@css/Maps.css'; | 5 | import "@css/Maps.css"; |
| 6 | 6 | ||
| 7 | interface SummaryProps { | 7 | interface SummaryProps { |
| 8 | selectedRun: number; | 8 | selectedRun: number; |
| @@ -20,9 +20,9 @@ const Summary: React.FC<SummaryProps> = ({ | |||
| 20 | 20 | ||
| 21 | const _select_run = React.useCallback( | 21 | const _select_run = React.useCallback( |
| 22 | (idx: number, category_id: number) => { | 22 | (idx: number, category_id: number) => { |
| 23 | let r = document.querySelectorAll('button.record'); | 23 | let r = document.querySelectorAll("button.record"); |
| 24 | r.forEach(e => ((e as HTMLElement).style.backgroundColor = '#2b2e46')); | 24 | r.forEach(e => ((e as HTMLElement).style.backgroundColor = "#2b2e46")); |
| 25 | (r[idx] as HTMLElement).style.backgroundColor = '#161723'; | 25 | (r[idx] as HTMLElement).style.backgroundColor = "#161723"; |
| 26 | 26 | ||
| 27 | if (data && data.summary.routes.length !== 0) { | 27 | if (data && data.summary.routes.length !== 0) { |
| 28 | idx += data.summary.routes.filter( | 28 | idx += data.summary.routes.filter( |
| @@ -42,9 +42,9 @@ const Summary: React.FC<SummaryProps> = ({ | |||
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | const _category_change = React.useCallback(() => { | 44 | const _category_change = React.useCallback(() => { |
| 45 | const btn = document.querySelectorAll('#section3 #category span button'); | 45 | const btn = document.querySelectorAll("#section3 #category span button"); |
| 46 | btn.forEach(e => { | 46 | btn.forEach(e => { |
| 47 | (e as HTMLElement).style.backgroundColor = '#2b2e46'; | 47 | (e as HTMLElement).style.backgroundColor = "#2b2e46"; |
| 48 | }); | 48 | }); |
| 49 | // heavenly father forgive me for i have sinned. TODO: fix this bullshit with dynamic categories | 49 | // heavenly father forgive me for i have sinned. TODO: fix this bullshit with dynamic categories |
| 50 | const idx = | 50 | const idx = |
| @@ -53,18 +53,18 @@ const Summary: React.FC<SummaryProps> = ({ | |||
| 53 | : data.map.is_coop | 53 | : data.map.is_coop |
| 54 | ? selectedCategory - 3 | 54 | ? selectedCategory - 3 |
| 55 | : selectedCategory - 1; | 55 | : selectedCategory - 1; |
| 56 | (btn[idx] as HTMLElement).style.backgroundColor = '#202232'; | 56 | (btn[idx] as HTMLElement).style.backgroundColor = "#202232"; |
| 57 | }, [selectedCategory, data.map.is_coop]); | 57 | }, [selectedCategory, data.map.is_coop]); |
| 58 | 58 | ||
| 59 | const _history_change = React.useCallback(() => { | 59 | const _history_change = React.useCallback(() => { |
| 60 | const btn = document.querySelectorAll('#section3 #history span button'); | 60 | const btn = document.querySelectorAll("#section3 #history span button"); |
| 61 | btn.forEach(e => { | 61 | btn.forEach(e => { |
| 62 | (e as HTMLElement).style.backgroundColor = '#2b2e46'; | 62 | (e as HTMLElement).style.backgroundColor = "#2b2e46"; |
| 63 | }); | 63 | }); |
| 64 | (historySelected | 64 | (historySelected |
| 65 | ? (btn[1] as HTMLElement) | 65 | ? (btn[1] as HTMLElement) |
| 66 | : (btn[0] as HTMLElement) | 66 | : (btn[0] as HTMLElement) |
| 67 | ).style.backgroundColor = '#202232'; | 67 | ).style.backgroundColor = "#202232"; |
| 68 | }, [historySelected]); | 68 | }, [historySelected]); |
| 69 | 69 | ||
| 70 | React.useEffect(() => { | 70 | React.useEffect(() => { |
| @@ -85,7 +85,7 @@ const Summary: React.FC<SummaryProps> = ({ | |||
| 85 | <section id="section3" className="summary1"> | 85 | <section id="section3" className="summary1"> |
| 86 | <div | 86 | <div |
| 87 | id="category" | 87 | id="category" |
| 88 | style={data.map.image === '' ? { backgroundColor: '#202232' } : {}} | 88 | style={data.map.image === "" ? { backgroundColor: "#202232" } : {}} |
| 89 | > | 89 | > |
| 90 | <img src={data.map.image} alt="" id="category-image"></img> | 90 | <img src={data.map.image} alt="" id="category-image"></img> |
| 91 | <p> | 91 | <p> |
| @@ -97,7 +97,7 @@ const Summary: React.FC<SummaryProps> = ({ | |||
| 97 | : ` portals`} | 97 | : ` portals`} |
| 98 | </p> | 98 | </p> |
| 99 | {data.map.is_coop ? ( // TODO: make this part dynamic | 99 | {data.map.is_coop ? ( // TODO: make this part dynamic |
| 100 | <span style={{ gridTemplateColumns: '1fr 1fr 1fr' }}> | 100 | <span style={{ gridTemplateColumns: "1fr 1fr 1fr" }}> |
| 101 | <button onClick={() => setSelectedCategory(1)}>CM</button> | 101 | <button onClick={() => setSelectedCategory(1)}>CM</button> |
| 102 | <button onClick={() => setSelectedCategory(4)}>Any%</button> | 102 | <button onClick={() => setSelectedCategory(4)}>Any%</button> |
| 103 | <button onClick={() => setSelectedCategory(5)}> | 103 | <button onClick={() => setSelectedCategory(5)}> |
| @@ -105,7 +105,7 @@ const Summary: React.FC<SummaryProps> = ({ | |||
| 105 | </button> | 105 | </button> |
| 106 | </span> | 106 | </span> |
| 107 | ) : ( | 107 | ) : ( |
| 108 | <span style={{ gridTemplateColumns: '1fr 1fr 1fr 1fr' }}> | 108 | <span style={{ gridTemplateColumns: "1fr 1fr 1fr 1fr" }}> |
| 109 | <button onClick={() => setSelectedCategory(1)}>CM</button> | 109 | <button onClick={() => setSelectedCategory(1)}>CM</button> |
| 110 | <button onClick={() => setSelectedCategory(2)}>NoSLA</button> | 110 | <button onClick={() => setSelectedCategory(2)}>NoSLA</button> |
| 111 | <button onClick={() => setSelectedCategory(3)}> | 111 | <button onClick={() => setSelectedCategory(3)}> |
| @@ -117,7 +117,7 @@ const Summary: React.FC<SummaryProps> = ({ | |||
| 117 | </div> | 117 | </div> |
| 118 | 118 | ||
| 119 | <div id="history"> | 119 | <div id="history"> |
| 120 | <div style={{ display: historySelected ? 'none' : 'block' }}> | 120 | <div style={{ display: historySelected ? "none" : "block" }}> |
| 121 | {data.summary.routes.filter(e => e.category.id === selectedCategory) | 121 | {data.summary.routes.filter(e => e.category.id === selectedCategory) |
| 122 | .length === 0 ? ( | 122 | .length === 0 ? ( |
| 123 | <h5>There are no records for this map.</h5> | 123 | <h5>There are no records for this map.</h5> |
| @@ -142,8 +142,8 @@ const Summary: React.FC<SummaryProps> = ({ | |||
| 142 | > | 142 | > |
| 143 | <span> | 143 | <span> |
| 144 | {new Date(r.history.date).toLocaleDateString( | 144 | {new Date(r.history.date).toLocaleDateString( |
| 145 | 'en-US', | 145 | "en-US", |
| 146 | { month: 'long', day: 'numeric', year: 'numeric' } | 146 | { month: "long", day: "numeric", year: "numeric" } |
| 147 | )} | 147 | )} |
| 148 | </span> | 148 | </span> |
| 149 | <span>{r.history.score_count}</span> | 149 | <span>{r.history.score_count}</span> |
| @@ -155,7 +155,7 @@ const Summary: React.FC<SummaryProps> = ({ | |||
| 155 | )} | 155 | )} |
| 156 | </div> | 156 | </div> |
| 157 | 157 | ||
| 158 | <div style={{ display: historySelected ? 'block' : 'none' }}> | 158 | <div style={{ display: historySelected ? "block" : "none" }}> |
| 159 | {data.summary.routes.filter(e => e.category.id === selectedCategory) | 159 | {data.summary.routes.filter(e => e.category.id === selectedCategory) |
| 160 | .length === 0 ? ( | 160 | .length === 0 ? ( |
| 161 | <h5>There are no records for this map.</h5> | 161 | <h5>There are no records for this map.</h5> |
| @@ -178,25 +178,25 @@ const Summary: React.FC<SummaryProps> = ({ | |||
| 178 | <span>Difficulty</span> | 178 | <span>Difficulty</span> |
| 179 | {data.summary.routes[selectedRun].rating === 0 && <span>N/A</span>} | 179 | {data.summary.routes[selectedRun].rating === 0 && <span>N/A</span>} |
| 180 | {data.summary.routes[selectedRun].rating === 1 && ( | 180 | {data.summary.routes[selectedRun].rating === 1 && ( |
| 181 | <span style={{ color: 'lime' }}>Very easy</span> | 181 | <span style={{ color: "lime" }}>Very easy</span> |
| 182 | )} | 182 | )} |
| 183 | {data.summary.routes[selectedRun].rating === 2 && ( | 183 | {data.summary.routes[selectedRun].rating === 2 && ( |
| 184 | <span style={{ color: 'green' }}>Easy</span> | 184 | <span style={{ color: "green" }}>Easy</span> |
| 185 | )} | 185 | )} |
| 186 | {data.summary.routes[selectedRun].rating === 3 && ( | 186 | {data.summary.routes[selectedRun].rating === 3 && ( |
| 187 | <span style={{ color: 'yellow' }}>Medium</span> | 187 | <span style={{ color: "yellow" }}>Medium</span> |
| 188 | )} | 188 | )} |
| 189 | {data.summary.routes[selectedRun].rating === 4 && ( | 189 | {data.summary.routes[selectedRun].rating === 4 && ( |
| 190 | <span style={{ color: 'orange' }}>Hard</span> | 190 | <span style={{ color: "orange" }}>Hard</span> |
| 191 | )} | 191 | )} |
| 192 | {data.summary.routes[selectedRun].rating === 5 && ( | 192 | {data.summary.routes[selectedRun].rating === 5 && ( |
| 193 | <span style={{ color: 'red' }}>Very hard</span> | 193 | <span style={{ color: "red" }}>Very hard</span> |
| 194 | )} | 194 | )} |
| 195 | <div> | 195 | <div> |
| 196 | {data.summary.routes[selectedRun].rating === 1 ? ( | 196 | {data.summary.routes[selectedRun].rating === 1 ? ( |
| 197 | <div | 197 | <div |
| 198 | className="difficulty-rating" | 198 | className="difficulty-rating" |
| 199 | style={{ backgroundColor: 'lime' }} | 199 | style={{ backgroundColor: "lime" }} |
| 200 | ></div> | 200 | ></div> |
| 201 | ) : ( | 201 | ) : ( |
| 202 | <div className="difficulty-rating"></div> | 202 | <div className="difficulty-rating"></div> |
| @@ -204,7 +204,7 @@ const Summary: React.FC<SummaryProps> = ({ | |||
| 204 | {data.summary.routes[selectedRun].rating === 2 ? ( | 204 | {data.summary.routes[selectedRun].rating === 2 ? ( |
| 205 | <div | 205 | <div |
| 206 | className="difficulty-rating" | 206 | className="difficulty-rating" |
| 207 | style={{ backgroundColor: 'green' }} | 207 | style={{ backgroundColor: "green" }} |
| 208 | ></div> | 208 | ></div> |
| 209 | ) : ( | 209 | ) : ( |
| 210 | <div className="difficulty-rating"></div> | 210 | <div className="difficulty-rating"></div> |
| @@ -212,7 +212,7 @@ const Summary: React.FC<SummaryProps> = ({ | |||
| 212 | {data.summary.routes[selectedRun].rating === 3 ? ( | 212 | {data.summary.routes[selectedRun].rating === 3 ? ( |
| 213 | <div | 213 | <div |
| 214 | className="difficulty-rating" | 214 | className="difficulty-rating" |
| 215 | style={{ backgroundColor: 'yellow' }} | 215 | style={{ backgroundColor: "yellow" }} |
| 216 | ></div> | 216 | ></div> |
| 217 | ) : ( | 217 | ) : ( |
| 218 | <div className="difficulty-rating"></div> | 218 | <div className="difficulty-rating"></div> |
| @@ -220,7 +220,7 @@ const Summary: React.FC<SummaryProps> = ({ | |||
| 220 | {data.summary.routes[selectedRun].rating === 4 ? ( | 220 | {data.summary.routes[selectedRun].rating === 4 ? ( |
| 221 | <div | 221 | <div |
| 222 | className="difficulty-rating" | 222 | className="difficulty-rating" |
| 223 | style={{ backgroundColor: 'orange' }} | 223 | style={{ backgroundColor: "orange" }} |
| 224 | ></div> | 224 | ></div> |
| 225 | ) : ( | 225 | ) : ( |
| 226 | <div className="difficulty-rating"></div> | 226 | <div className="difficulty-rating"></div> |
| @@ -228,7 +228,7 @@ const Summary: React.FC<SummaryProps> = ({ | |||
| 228 | {data.summary.routes[selectedRun].rating === 5 ? ( | 228 | {data.summary.routes[selectedRun].rating === 5 ? ( |
| 229 | <div | 229 | <div |
| 230 | className="difficulty-rating" | 230 | className="difficulty-rating" |
| 231 | style={{ backgroundColor: 'red' }} | 231 | style={{ backgroundColor: "red" }} |
| 232 | ></div> | 232 | ></div> |
| 233 | ) : ( | 233 | ) : ( |
| 234 | <div className="difficulty-rating"></div> | 234 | <div className="difficulty-rating"></div> |
| @@ -243,18 +243,18 @@ const Summary: React.FC<SummaryProps> = ({ | |||
| 243 | 243 | ||
| 244 | <section id="section5" className="summary1"> | 244 | <section id="section5" className="summary1"> |
| 245 | <div id="description"> | 245 | <div id="description"> |
| 246 | {data.summary.routes[selectedRun].showcase !== '' ? ( | 246 | {data.summary.routes[selectedRun].showcase !== "" ? ( |
| 247 | <iframe | 247 | <iframe |
| 248 | title="Showcase video" | 248 | title="Showcase video" |
| 249 | src={ | 249 | src={ |
| 250 | 'https://www.youtube.com/embed/' + | 250 | "https://www.youtube.com/embed/" + |
| 251 | _get_youtube_id(data.summary.routes[selectedRun].showcase) | 251 | _get_youtube_id(data.summary.routes[selectedRun].showcase) |
| 252 | } | 252 | } |
| 253 | > | 253 | > |
| 254 | {' '} | 254 | {" "} |
| 255 | </iframe> | 255 | </iframe> |
| 256 | ) : ( | 256 | ) : ( |
| 257 | '' | 257 | "" |
| 258 | )} | 258 | )} |
| 259 | <h3>Route Description</h3> | 259 | <h3>Route Description</h3> |
| 260 | <span id="description-text"> | 260 | <span id="description-text"> |
diff --git a/frontend/src/components/UploadRunDialog.tsx b/frontend/src/components/UploadRunDialog.tsx index 5bad80f..d5eabcd 100644 --- a/frontend/src/components/UploadRunDialog.tsx +++ b/frontend/src/components/UploadRunDialog.tsx | |||
| @@ -1,15 +1,15 @@ | |||
| 1 | import React from 'react'; | 1 | import React from "react"; |
| 2 | import { UploadRunContent } from '@customTypes/Content'; | 2 | import { UploadRunContent } from "@customTypes/Content"; |
| 3 | import { ScoreboardTempUpdate, SourceDemoParser, NetMessages } from '@nekz/sdp'; | 3 | import { ScoreboardTempUpdate, SourceDemoParser, NetMessages } from "@nekz/sdp"; |
| 4 | 4 | ||
| 5 | import '@css/UploadRunDialog.css'; | 5 | import "@css/UploadRunDialog.css"; |
| 6 | import { Game } from '@customTypes/Game'; | 6 | import { Game } from "@customTypes/Game"; |
| 7 | import { API } from '@api/Api'; | 7 | import { API } from "@api/Api"; |
| 8 | import { useNavigate } from 'react-router-dom'; | 8 | import { useNavigate } from "react-router-dom"; |
| 9 | import useMessage from '@hooks/UseMessage'; | 9 | import useMessage from "@hooks/UseMessage"; |
| 10 | import useConfirm from '@hooks/UseConfirm'; | 10 | import useConfirm from "@hooks/UseConfirm"; |
| 11 | import useMessageLoad from '@hooks/UseMessageLoad'; | 11 | import useMessageLoad from "@hooks/UseMessageLoad"; |
| 12 | import { MapNames } from '@customTypes/MapNames'; | 12 | import { MapNames } from "@customTypes/MapNames"; |
| 13 | 13 | ||
| 14 | interface UploadRunDialogProps { | 14 | interface UploadRunDialogProps { |
| 15 | token?: string; | 15 | token?: string; |
| @@ -38,7 +38,7 @@ const UploadRunDialog: React.FC<UploadRunDialogProps> = ({ | |||
| 38 | }); | 38 | }); |
| 39 | 39 | ||
| 40 | const [selectedGameID, setSelectedGameID] = React.useState<number>(0); | 40 | const [selectedGameID, setSelectedGameID] = React.useState<number>(0); |
| 41 | const [selectedGameName, setSelectedGameName] = React.useState<string>(''); | 41 | const [selectedGameName, setSelectedGameName] = React.useState<string>(""); |
| 42 | 42 | ||
| 43 | // dropdowns | 43 | // dropdowns |
| 44 | const [dropdown1Vis, setDropdown1Vis] = React.useState<boolean>(false); | 44 | const [dropdown1Vis, setDropdown1Vis] = React.useState<boolean>(false); |
| @@ -102,7 +102,7 @@ const UploadRunDialog: React.FC<UploadRunDialogProps> = ({ | |||
| 102 | setDropdown1Vis(!dropdown1Vis); | 102 | setDropdown1Vis(!dropdown1Vis); |
| 103 | } else if (dropdown === 2) { | 103 | } else if (dropdown === 2) { |
| 104 | setDropdown2Vis(!dropdown2Vis); | 104 | setDropdown2Vis(!dropdown2Vis); |
| 105 | document.querySelector('#dropdown2')?.scrollTo(0, 0); | 105 | document.querySelector("#dropdown2")?.scrollTo(0, 0); |
| 106 | } | 106 | } |
| 107 | }; | 107 | }; |
| 108 | 108 | ||
| @@ -133,15 +133,15 @@ const UploadRunDialog: React.FC<UploadRunDialogProps> = ({ | |||
| 133 | if (token) { | 133 | if (token) { |
| 134 | if (games[selectedGameID].is_coop) { | 134 | if (games[selectedGameID].is_coop) { |
| 135 | if (uploadRunContent.host_demo === null) { | 135 | if (uploadRunContent.host_demo === null) { |
| 136 | await message('Error', 'You must select a host demo to upload.'); | 136 | await message("Error", "You must select a host demo to upload."); |
| 137 | return; | 137 | return; |
| 138 | } else if (uploadRunContent.partner_demo === null) { | 138 | } else if (uploadRunContent.partner_demo === null) { |
| 139 | await message('Error', 'You must select a partner demo to upload.'); | 139 | await message("Error", "You must select a partner demo to upload."); |
| 140 | return; | 140 | return; |
| 141 | } | 141 | } |
| 142 | } else { | 142 | } else { |
| 143 | if (uploadRunContent.host_demo === null) { | 143 | if (uploadRunContent.host_demo === null) { |
| 144 | await message('Error', 'You must select a demo to upload.'); | 144 | await message("Error", "You must select a demo to upload."); |
| 145 | return; | 145 | return; |
| 146 | } | 146 | } |
| 147 | } | 147 | } |
| @@ -157,7 +157,7 @@ const UploadRunDialog: React.FC<UploadRunDialogProps> = ({ | |||
| 157 | 157 | ||
| 158 | if (!scoreboard) { | 158 | if (!scoreboard) { |
| 159 | await message( | 159 | await message( |
| 160 | 'Error', | 160 | "Error", |
| 161 | "Error while processing demo: Unable to get scoreboard result. Either there is a demo that is corrupt or haven't been recorded in challenge mode." | 161 | "Error while processing demo: Unable to get scoreboard result. Either there is a demo that is corrupt or haven't been recorded in challenge mode." |
| 162 | ); | 162 | ); |
| 163 | return; | 163 | return; |
| @@ -165,22 +165,22 @@ const UploadRunDialog: React.FC<UploadRunDialogProps> = ({ | |||
| 165 | 165 | ||
| 166 | if (!demo.mapName || !MapNames[demo.mapName]) { | 166 | if (!demo.mapName || !MapNames[demo.mapName]) { |
| 167 | await message( | 167 | await message( |
| 168 | 'Error', | 168 | "Error", |
| 169 | 'Error while processing demo: Invalid map name.' | 169 | "Error while processing demo: Invalid map name." |
| 170 | ); | 170 | ); |
| 171 | return; | 171 | return; |
| 172 | } | 172 | } |
| 173 | 173 | ||
| 174 | if (selectedGameID === 0 && MapNames[demo.mapName] > 60) { | 174 | if (selectedGameID === 0 && MapNames[demo.mapName] > 60) { |
| 175 | await message( | 175 | await message( |
| 176 | 'Error', | 176 | "Error", |
| 177 | 'Error while processing demo: Invalid cooperative demo in singleplayer submission.' | 177 | "Error while processing demo: Invalid cooperative demo in singleplayer submission." |
| 178 | ); | 178 | ); |
| 179 | return; | 179 | return; |
| 180 | } else if (selectedGameID === 1 && MapNames[demo.mapName] <= 60) { | 180 | } else if (selectedGameID === 1 && MapNames[demo.mapName] <= 60) { |
| 181 | await message( | 181 | await message( |
| 182 | 'Error', | 182 | "Error", |
| 183 | 'Error while processing demo: Invalid singleplayer demo in cooperative submission.' | 183 | "Error while processing demo: Invalid singleplayer demo in cooperative submission." |
| 184 | ); | 184 | ); |
| 185 | return; | 185 | return; |
| 186 | } | 186 | } |
| @@ -189,7 +189,7 @@ const UploadRunDialog: React.FC<UploadRunDialogProps> = ({ | |||
| 189 | scoreboard.userMessage?.as<ScoreboardTempUpdate>() ?? {}; | 189 | scoreboard.userMessage?.as<ScoreboardTempUpdate>() ?? {}; |
| 190 | 190 | ||
| 191 | const userConfirmed = await confirm( | 191 | const userConfirmed = await confirm( |
| 192 | 'Upload Record', | 192 | "Upload Record", |
| 193 | `Map Name: ${demo.mapName}\nPortal Count: ${portalScore}\nTicks: ${timeScore}\n\nAre you sure you want to upload this demo?` | 193 | `Map Name: ${demo.mapName}\nPortal Count: ${portalScore}\nTicks: ${timeScore}\n\nAre you sure you want to upload this demo?` |
| 194 | ); | 194 | ); |
| 195 | 195 | ||
| @@ -197,21 +197,21 @@ const UploadRunDialog: React.FC<UploadRunDialogProps> = ({ | |||
| 197 | return; | 197 | return; |
| 198 | } | 198 | } |
| 199 | 199 | ||
| 200 | messageLoad('Uploading...'); | 200 | messageLoad("Uploading..."); |
| 201 | const [success, response] = await API.post_record( | 201 | const [success, response] = await API.post_record( |
| 202 | token, | 202 | token, |
| 203 | uploadRunContent, | 203 | uploadRunContent, |
| 204 | MapNames[demo.mapName] | 204 | MapNames[demo.mapName] |
| 205 | ); | 205 | ); |
| 206 | messageLoadClose(); | 206 | messageLoadClose(); |
| 207 | await message('Upload Record', response); | 207 | await message("Upload Record", response); |
| 208 | if (success) { | 208 | if (success) { |
| 209 | setUploadRunContent({ | 209 | setUploadRunContent({ |
| 210 | host_demo: null, | 210 | host_demo: null, |
| 211 | partner_demo: null, | 211 | partner_demo: null, |
| 212 | }); | 212 | }); |
| 213 | onClose(success); | 213 | onClose(success); |
| 214 | navigate('/profile'); | 214 | navigate("/profile"); |
| 215 | } | 215 | } |
| 216 | } | 216 | } |
| 217 | }; | 217 | }; |
| @@ -220,7 +220,7 @@ const UploadRunDialog: React.FC<UploadRunDialogProps> = ({ | |||
| 220 | if (open) { | 220 | if (open) { |
| 221 | setDragHighlightPartner(false); | 221 | setDragHighlightPartner(false); |
| 222 | setDragHighlight(false); | 222 | setDragHighlight(false); |
| 223 | _handle_game_select('1', 'Portal 2 - Singleplayer'); // a different approach?. | 223 | _handle_game_select("1", "Portal 2 - Singleplayer"); // a different approach?. |
| 224 | } | 224 | } |
| 225 | }, [open]); | 225 | }, [open]); |
| 226 | 226 | ||
| @@ -236,35 +236,35 @@ const UploadRunDialog: React.FC<UploadRunDialogProps> = ({ | |||
| 236 | <div id="upload-run-menu-add"> | 236 | <div id="upload-run-menu-add"> |
| 237 | <div id="upload-run-route-category"> | 237 | <div id="upload-run-route-category"> |
| 238 | <div | 238 | <div |
| 239 | style={{ padding: '15px 0px' }} | 239 | style={{ padding: "15px 0px" }} |
| 240 | className="upload-run-dropdown-container upload-run-item" | 240 | className="upload-run-dropdown-container upload-run-item" |
| 241 | > | 241 | > |
| 242 | <h3 style={{ margin: '0px 0px' }}>Select Game</h3> | 242 | <h3 style={{ margin: "0px 0px" }}>Select Game</h3> |
| 243 | <div | 243 | <div |
| 244 | onClick={() => _handle_dropdowns(1)} | 244 | onClick={() => _handle_dropdowns(1)} |
| 245 | style={{ | 245 | style={{ |
| 246 | display: 'flex', | 246 | display: "flex", |
| 247 | alignItems: 'center', | 247 | alignItems: "center", |
| 248 | cursor: 'pointer', | 248 | cursor: "pointer", |
| 249 | justifyContent: 'space-between', | 249 | justifyContent: "space-between", |
| 250 | margin: '10px 0px', | 250 | margin: "10px 0px", |
| 251 | }} | 251 | }} |
| 252 | > | 252 | > |
| 253 | <div className="dropdown-cur">{selectedGameName}</div> | 253 | <div className="dropdown-cur">{selectedGameName}</div> |
| 254 | <i | 254 | <i |
| 255 | style={{ | 255 | style={{ |
| 256 | rotate: '-90deg', | 256 | rotate: "-90deg", |
| 257 | transform: 'translate(-5px, 10px)', | 257 | transform: "translate(-5px, 10px)", |
| 258 | }} | 258 | }} |
| 259 | className="triangle" | 259 | className="triangle" |
| 260 | ></i> | 260 | ></i> |
| 261 | </div> | 261 | </div> |
| 262 | <div | 262 | <div |
| 263 | style={{ top: '110px' }} | 263 | style={{ top: "110px" }} |
| 264 | className={ | 264 | className={ |
| 265 | dropdown1Vis | 265 | dropdown1Vis |
| 266 | ? 'upload-run-dropdown' | 266 | ? "upload-run-dropdown" |
| 267 | : 'upload-run-dropdown hidden' | 267 | : "upload-run-dropdown hidden" |
| 268 | } | 268 | } |
| 269 | > | 269 | > |
| 270 | {games.map(game => ( | 270 | {games.map(game => ( |
| @@ -284,7 +284,7 @@ const UploadRunDialog: React.FC<UploadRunDialogProps> = ({ | |||
| 284 | {!loading && ( | 284 | {!loading && ( |
| 285 | <> | 285 | <> |
| 286 | <div> | 286 | <div> |
| 287 | <h3 style={{ margin: '10px 0px' }}>Host Demo</h3> | 287 | <h3 style={{ margin: "10px 0px" }}>Host Demo</h3> |
| 288 | <div | 288 | <div |
| 289 | onClick={() => { | 289 | onClick={() => { |
| 290 | _handle_file_click(true); | 290 | _handle_file_click(true); |
| @@ -298,7 +298,7 @@ const UploadRunDialog: React.FC<UploadRunDialogProps> = ({ | |||
| 298 | onDragLeave={e => { | 298 | onDragLeave={e => { |
| 299 | _handle_drag_leave(e, true); | 299 | _handle_drag_leave(e, true); |
| 300 | }} | 300 | }} |
| 301 | className={`upload-run-drag-area ${dragHightlight ? 'upload-run-drag-area-highlight' : ''} ${uploadRunContent.host_demo ? 'upload-run-drag-area-hidden' : ''}`} | 301 | className={`upload-run-drag-area ${dragHightlight ? "upload-run-drag-area-highlight" : ""} ${uploadRunContent.host_demo ? "upload-run-drag-area-hidden" : ""}`} |
| 302 | > | 302 | > |
| 303 | <input | 303 | <input |
| 304 | ref={fileInputRef} | 304 | ref={fileInputRef} |
| @@ -316,7 +316,7 @@ const UploadRunDialog: React.FC<UploadRunDialogProps> = ({ | |||
| 316 | <div> | 316 | <div> |
| 317 | <span | 317 | <span |
| 318 | style={{ | 318 | style={{ |
| 319 | fontFamily: 'BarlowSemiCondensed-Regular', | 319 | fontFamily: "BarlowSemiCondensed-Regular", |
| 320 | }} | 320 | }} |
| 321 | > | 321 | > |
| 322 | Or click here | 322 | Or click here |
| @@ -324,9 +324,9 @@ const UploadRunDialog: React.FC<UploadRunDialogProps> = ({ | |||
| 324 | <br /> | 324 | <br /> |
| 325 | <button | 325 | <button |
| 326 | style={{ | 326 | style={{ |
| 327 | borderRadius: '24px', | 327 | borderRadius: "24px", |
| 328 | padding: '5px 8px', | 328 | padding: "5px 8px", |
| 329 | margin: '5px 0px', | 329 | margin: "5px 0px", |
| 330 | }} | 330 | }} |
| 331 | > | 331 | > |
| 332 | Upload | 332 | Upload |
| @@ -342,7 +342,7 @@ const UploadRunDialog: React.FC<UploadRunDialogProps> = ({ | |||
| 342 | {games[selectedGameID].is_coop && ( | 342 | {games[selectedGameID].is_coop && ( |
| 343 | <> | 343 | <> |
| 344 | <div> | 344 | <div> |
| 345 | <h3 style={{ margin: '10px 0px' }}>Partner Demo</h3> | 345 | <h3 style={{ margin: "10px 0px" }}>Partner Demo</h3> |
| 346 | <div | 346 | <div |
| 347 | onClick={() => { | 347 | onClick={() => { |
| 348 | _handle_file_click(false); | 348 | _handle_file_click(false); |
| @@ -356,7 +356,7 @@ const UploadRunDialog: React.FC<UploadRunDialogProps> = ({ | |||
| 356 | onDragLeave={e => { | 356 | onDragLeave={e => { |
| 357 | _handle_drag_leave(e, false); | 357 | _handle_drag_leave(e, false); |
| 358 | }} | 358 | }} |
| 359 | className={`upload-run-drag-area ${dragHightlightPartner ? 'upload-run-drag-area-highlight-partner' : ''} ${uploadRunContent.partner_demo ? 'upload-run-drag-area-hidden' : ''}`} | 359 | className={`upload-run-drag-area ${dragHightlightPartner ? "upload-run-drag-area-highlight-partner" : ""} ${uploadRunContent.partner_demo ? "upload-run-drag-area-hidden" : ""}`} |
| 360 | > | 360 | > |
| 361 | <input | 361 | <input |
| 362 | ref={fileInputRefPartner} | 362 | ref={fileInputRefPartner} |
| @@ -367,14 +367,14 @@ const UploadRunDialog: React.FC<UploadRunDialogProps> = ({ | |||
| 367 | onChange={e => | 367 | onChange={e => |
| 368 | _handle_file_change(e.target.files, false) | 368 | _handle_file_change(e.target.files, false) |
| 369 | } | 369 | } |
| 370 | />{' '} | 370 | />{" "} |
| 371 | {!uploadRunContent.partner_demo ? ( | 371 | {!uploadRunContent.partner_demo ? ( |
| 372 | <div> | 372 | <div> |
| 373 | <span>Drag and drop</span> | 373 | <span>Drag and drop</span> |
| 374 | <div> | 374 | <div> |
| 375 | <span | 375 | <span |
| 376 | style={{ | 376 | style={{ |
| 377 | fontFamily: 'BarlowSemiCondensed-Regular', | 377 | fontFamily: "BarlowSemiCondensed-Regular", |
| 378 | }} | 378 | }} |
| 379 | > | 379 | > |
| 380 | Or click here | 380 | Or click here |
| @@ -382,9 +382,9 @@ const UploadRunDialog: React.FC<UploadRunDialogProps> = ({ | |||
| 382 | <br /> | 382 | <br /> |
| 383 | <button | 383 | <button |
| 384 | style={{ | 384 | style={{ |
| 385 | borderRadius: '24px', | 385 | borderRadius: "24px", |
| 386 | padding: '5px 8px', | 386 | padding: "5px 8px", |
| 387 | margin: '5px 0px', | 387 | margin: "5px 0px", |
| 388 | }} | 388 | }} |
| 389 | > | 389 | > |
| 390 | Upload | 390 | Upload |