diff options
| author | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2024-09-09 20:10:16 +0300 |
|---|---|---|
| committer | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2024-09-09 20:10:16 +0300 |
| commit | 188e806427ff6c9b302d994fc9c84a0300526688 (patch) | |
| tree | de6b28b307efc181a26ff422895246b25d70de8a /frontend/src | |
| parent | refactor: upload run form, lots of random shit (diff) | |
| download | lphub-188e806427ff6c9b302d994fc9c84a0300526688.tar.gz lphub-188e806427ff6c9b302d994fc9c84a0300526688.tar.bz2 lphub-188e806427ff6c9b302d994fc9c84a0300526688.zip | |
refactor: make names clickable throughout the site, fix user pages
Diffstat (limited to 'frontend/src')
| -rw-r--r-- | frontend/src/api/Api.tsx | 12 | ||||
| -rw-r--r-- | frontend/src/components/Discussions.tsx | 9 | ||||
| -rw-r--r-- | frontend/src/components/Leaderboards.tsx | 13 | ||||
| -rw-r--r-- | frontend/src/components/RankingEntry.tsx | 2 | ||||
| -rw-r--r-- | frontend/src/css/Maps.css | 6 | ||||
| -rw-r--r-- | frontend/src/css/Rankings.css | 8 | ||||
| -rw-r--r-- | frontend/src/pages/Homepage.tsx | 2 | ||||
| -rw-r--r-- | frontend/src/pages/Maps.tsx | 1 | ||||
| -rw-r--r-- | frontend/src/pages/User.tsx | 2 |
9 files changed, 38 insertions, 17 deletions
diff --git a/frontend/src/api/Api.tsx b/frontend/src/api/Api.tsx index 1f77088..30c0ad6 100644 --- a/frontend/src/api/Api.tsx +++ b/frontend/src/api/Api.tsx | |||
| @@ -145,7 +145,17 @@ const get_map_leaderboard = async (map_id: string): Promise<MapLeaderboard | und | |||
| 145 | if (!response.data.success) { | 145 | if (!response.data.success) { |
| 146 | return undefined; | 146 | return undefined; |
| 147 | } | 147 | } |
| 148 | return response.data.data; | 148 | const data = response.data.data; |
| 149 | // map the kind of leaderboard | ||
| 150 | data.records = data.records.map((record: any) => { | ||
| 151 | if (record.host && record.partner) { | ||
| 152 | return { ...record, kind: 'multiplayer' }; | ||
| 153 | } else { | ||
| 154 | return { ...record, kind: 'singleplayer' }; | ||
| 155 | } | ||
| 156 | }); | ||
| 157 | // should be unreachable | ||
| 158 | return undefined; | ||
| 149 | }; | 159 | }; |
| 150 | 160 | ||
| 151 | // MAP DISCUSSIONS | 161 | // MAP DISCUSSIONS |
diff --git a/frontend/src/components/Discussions.tsx b/frontend/src/components/Discussions.tsx index 1cd3523..787104b 100644 --- a/frontend/src/components/Discussions.tsx +++ b/frontend/src/components/Discussions.tsx | |||
| @@ -5,6 +5,7 @@ import { MapDiscussionCommentContent, MapDiscussionContent } from '../types/Cont | |||
| 5 | import { time_ago } from '../utils/Time'; | 5 | import { time_ago } from '../utils/Time'; |
| 6 | import { API } from '../api/Api'; | 6 | import { API } from '../api/Api'; |
| 7 | import "../css/Maps.css" | 7 | import "../css/Maps.css" |
| 8 | import { Link } from 'react-router-dom'; | ||
| 8 | 9 | ||
| 9 | interface DiscussionsProps { | 10 | interface DiscussionsProps { |
| 10 | data?: MapDiscussions; | 11 | data?: MapDiscussions; |
| @@ -88,7 +89,9 @@ const Discussions: React.FC<DiscussionsProps> = ({ data, isModerator, mapID, onR | |||
| 88 | </div> | 89 | </div> |
| 89 | 90 | ||
| 90 | <div> | 91 | <div> |
| 91 | <img src={discussionThread.discussion.creator.avatar_link} alt="" /> | 92 | <Link to={`/users/${discussionThread.discussion.creator.steam_id}`}> |
| 93 | <img src={discussionThread.discussion.creator.avatar_link} alt="" /> | ||
| 94 | </Link> | ||
| 92 | <div> | 95 | <div> |
| 93 | <span>{discussionThread.discussion.creator.user_name}</span> | 96 | <span>{discussionThread.discussion.creator.user_name}</span> |
| 94 | <span>{time_ago(new Date(discussionThread.discussion.created_at.replace("T", " ").replace("Z", "")))}</span> | 97 | <span>{time_ago(new Date(discussionThread.discussion.created_at.replace("T", " ").replace("Z", "")))}</span> |
| @@ -98,7 +101,9 @@ const Discussions: React.FC<DiscussionsProps> = ({ data, isModerator, mapID, onR | |||
| 98 | discussionThread.discussion.comments.sort((a, b) => new Date(a.date).getTime() - new Date(b.date).getTime()) | 101 | discussionThread.discussion.comments.sort((a, b) => new Date(a.date).getTime() - new Date(b.date).getTime()) |
| 99 | .map(e => ( | 102 | .map(e => ( |
| 100 | <> | 103 | <> |
| 101 | <img src={e.user.avatar_link} alt="" /> | 104 | <Link to={`/users/${e.user.steam_id}`}> |
| 105 | <img src={e.user.avatar_link} alt="" /> | ||
| 106 | </Link> | ||
| 102 | <div> | 107 | <div> |
| 103 | <span>{e.user.user_name}</span> | 108 | <span>{e.user.user_name}</span> |
| 104 | <span>{time_ago(new Date(e.date.replace("T", " ").replace("Z", "")))}</span> | 109 | <span>{time_ago(new Date(e.date.replace("T", " ").replace("Z", "")))}</span> |
diff --git a/frontend/src/components/Leaderboards.tsx b/frontend/src/components/Leaderboards.tsx index badff37..159f3ed 100644 --- a/frontend/src/components/Leaderboards.tsx +++ b/frontend/src/components/Leaderboards.tsx | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | import React from 'react'; | 1 | import React from 'react'; |
| 2 | import { Link } from 'react-router-dom'; | ||
| 2 | 3 | ||
| 3 | import { DownloadIcon, ThreedotIcon } from '../images/Images'; | 4 | import { DownloadIcon, ThreedotIcon } from '../images/Images'; |
| 4 | import { MapLeaderboard } from '../types/Map'; | 5 | import { MapLeaderboard } from '../types/Map'; |
| @@ -70,11 +71,13 @@ const Leaderboards: React.FC<LeaderboardsProps> = ({ data }) => { | |||
| 70 | <span> </span> | 71 | <span> </span> |
| 71 | {r.kind === "multiplayer" ? ( | 72 | {r.kind === "multiplayer" ? ( |
| 72 | <div> | 73 | <div> |
| 73 | <span><img src={r.host.avatar_link} alt='' /> {r.host.user_name}</span> | 74 | <Link to={`/users/${r.host.steam_id}`}><span><img src={r.host.avatar_link} alt='' /> {r.host.user_name}</span></Link> |
| 74 | <span><img src={r.partner.avatar_link} alt='' /> {r.partner.user_name}</span> | 75 | <Link to={`/users/${r.partner.steam_id}`}><span><img src={r.partner.avatar_link} alt='' /> {r.partner.user_name}</span></Link> |
| 76 | </div> | ||
| 77 | ) : r.kind === "singleplayer" && ( | ||
| 78 | <div> | ||
| 79 | <Link to={`/users/${r.user.steam_id}`}><span><img src={r.user.avatar_link} alt='' /> {r.user.user_name}</span></Link> | ||
| 75 | </div> | 80 | </div> |
| 76 | ) : ( | ||
| 77 | <div><span><img src={r.user.avatar_link} alt='' /> {r.user.user_name}</span></div> | ||
| 78 | )} | 81 | )} |
| 79 | 82 | ||
| 80 | <span>{r.score_count}</span> | 83 | <span>{r.score_count}</span> |
| @@ -88,7 +91,7 @@ const Leaderboards: React.FC<LeaderboardsProps> = ({ data }) => { | |||
| 88 | <button onClick={() => window.location.href = `https://lp.ardapektezol.com/api/v1/demos?uuid=${r.partner_demo_id}`}><img src={DownloadIcon} alt="download" style={{ filter: "hue-rotate(160deg) contrast(60%) saturate(1000%)" }} /></button> | 91 | <button onClick={() => window.location.href = `https://lp.ardapektezol.com/api/v1/demos?uuid=${r.partner_demo_id}`}><img src={DownloadIcon} alt="download" style={{ filter: "hue-rotate(160deg) contrast(60%) saturate(1000%)" }} /></button> |
| 89 | <button onClick={() => window.location.href = `https://lp.ardapektezol.com/api/v1/demos?uuid=${r.host_demo_id}`}><img src={DownloadIcon} alt="download" style={{ filter: "hue-rotate(300deg) contrast(60%) saturate(1000%)" }} /></button> | 92 | <button onClick={() => window.location.href = `https://lp.ardapektezol.com/api/v1/demos?uuid=${r.host_demo_id}`}><img src={DownloadIcon} alt="download" style={{ filter: "hue-rotate(300deg) contrast(60%) saturate(1000%)" }} /></button> |
| 90 | </span> | 93 | </span> |
| 91 | ) : ( | 94 | ) : r.kind === "singleplayer" && ( |
| 92 | 95 | ||
| 93 | <span> | 96 | <span> |
| 94 | <button onClick={() => { window.alert(`Demo ID: ${r.demo_id}`) }}><img src={ThreedotIcon} alt="demo_id" /></button> | 97 | <button onClick={() => { window.alert(`Demo ID: ${r.demo_id}`) }}><img src={ThreedotIcon} alt="demo_id" /></button> |
diff --git a/frontend/src/components/RankingEntry.tsx b/frontend/src/components/RankingEntry.tsx index b77bb3d..023a896 100644 --- a/frontend/src/components/RankingEntry.tsx +++ b/frontend/src/components/RankingEntry.tsx | |||
| @@ -11,8 +11,10 @@ const RankingEntry: React.FC<RankingEntryProps> = (curRankingData) => { | |||
| 11 | <div className='leaderboard-entry'> | 11 | <div className='leaderboard-entry'> |
| 12 | <span>{curRankingData.curRankingData.placement}</span> | 12 | <span>{curRankingData.curRankingData.placement}</span> |
| 13 | <div> | 13 | <div> |
| 14 | <Link to={`/users/${curRankingData.curRankingData.user.steam_id}`}> | ||
| 14 | <img src={curRankingData.curRankingData.user.avatar_link}></img> | 15 | <img src={curRankingData.curRankingData.user.avatar_link}></img> |
| 15 | <span>{curRankingData.curRankingData.user.user_name}</span> | 16 | <span>{curRankingData.curRankingData.user.user_name}</span> |
| 17 | </Link> | ||
| 16 | </div> | 18 | </div> |
| 17 | <span>{curRankingData.curRankingData.total_score}</span> | 19 | <span>{curRankingData.curRankingData.total_score}</span> |
| 18 | </div> | 20 | </div> |
diff --git a/frontend/src/css/Maps.css b/frontend/src/css/Maps.css index d38eea5..b69f588 100644 --- a/frontend/src/css/Maps.css +++ b/frontend/src/css/Maps.css | |||
| @@ -399,7 +399,7 @@ text-align: center; | |||
| 399 | height: 44px; | 399 | height: 44px; |
| 400 | } | 400 | } |
| 401 | 401 | ||
| 402 | .leaderboard-record>div>span>img{ | 402 | .leaderboard-record>div>a>span>img{ |
| 403 | height: 36px; | 403 | height: 36px; |
| 404 | border-radius: 50px; | 404 | border-radius: 50px; |
| 405 | padding: 0; | 405 | padding: 0; |
| @@ -410,7 +410,7 @@ text-align: center; | |||
| 410 | grid-template-columns: 50% 50%; | 410 | grid-template-columns: 50% 50%; |
| 411 | place-items: left; | 411 | place-items: left; |
| 412 | } | 412 | } |
| 413 | .leaderboard-record>div>span{ | 413 | .leaderboard-record>div>a>span{ |
| 414 | display: flex; | 414 | display: flex; |
| 415 | place-items: center; | 415 | place-items: center; |
| 416 | height: 44px; | 416 | height: 44px; |
| @@ -611,7 +611,7 @@ text-align: center; | |||
| 611 | } | 611 | } |
| 612 | 612 | ||
| 613 | 613 | ||
| 614 | #discussion-thread>div:nth-child(2)>img{ | 614 | #discussion-thread>div:nth-child(2)>a>img{ |
| 615 | width: 60px; height: 60px; | 615 | width: 60px; height: 60px; |
| 616 | border-radius: 100px; | 616 | border-radius: 100px; |
| 617 | margin: 20px 0 0 0; | 617 | margin: 20px 0 0 0; |
diff --git a/frontend/src/css/Rankings.css b/frontend/src/css/Rankings.css index 8e49ef9..edc5a00 100644 --- a/frontend/src/css/Rankings.css +++ b/frontend/src/css/Rankings.css | |||
| @@ -32,11 +32,11 @@ | |||
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | .nav-1 div { | 34 | .nav-1 div { |
| 35 | width: 65%; | 35 | width: 60%; |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | .nav-2 div { | 38 | .nav-2 div { |
| 39 | width: 80%; | 39 | width: 75%; |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | .rankings-leaderboard { | 42 | .rankings-leaderboard { |
| @@ -73,12 +73,12 @@ | |||
| 73 | text-align: left; | 73 | text-align: left; |
| 74 | } | 74 | } |
| 75 | 75 | ||
| 76 | .leaderboard-entry div { | 76 | .leaderboard-entry div a { |
| 77 | display: flex; | 77 | display: flex; |
| 78 | align-items: center; | 78 | align-items: center; |
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | .leaderboard-entry div span { | 81 | .leaderboard-entry div a span { |
| 82 | margin-left: 5px; | 82 | margin-left: 5px; |
| 83 | } | 83 | } |
| 84 | 84 | ||
diff --git a/frontend/src/pages/Homepage.tsx b/frontend/src/pages/Homepage.tsx index d4f3095..8e5bb4b 100644 --- a/frontend/src/pages/Homepage.tsx +++ b/frontend/src/pages/Homepage.tsx | |||
| @@ -10,7 +10,7 @@ const Homepage: React.FC = () => { | |||
| 10 | <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> |
| 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>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> |
| 12 | <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> |
| 13 | <p>By using LPHUB, you agree that you have read the 'Leaderboard Rules' and the 'About P2LP' pages.</p> | 13 | <p>By using LPHUB, you agree that you have read the 'Leaderboard Rules' and the 'About LPHUB' pages.</p> |
| 14 | </section> | 14 | </section> |
| 15 | </main> | 15 | </main> |
| 16 | ); | 16 | ); |
diff --git a/frontend/src/pages/Maps.tsx b/frontend/src/pages/Maps.tsx index 5548650..62fc3cc 100644 --- a/frontend/src/pages/Maps.tsx +++ b/frontend/src/pages/Maps.tsx | |||
| @@ -39,6 +39,7 @@ const Maps: React.FC<MapProps> = ({ profile, isModerator, onUploadRun }) => { | |||
| 39 | 39 | ||
| 40 | const _fetch_map_leaderboards = async () => { | 40 | const _fetch_map_leaderboards = async () => { |
| 41 | const mapLeaderboards = await API.get_map_leaderboard(mapID); | 41 | const mapLeaderboards = await API.get_map_leaderboard(mapID); |
| 42 | console.log(mapLeaderboards?.records[0]); | ||
| 42 | setMapLeaderboardData(mapLeaderboards); | 43 | setMapLeaderboardData(mapLeaderboards); |
| 43 | }; | 44 | }; |
| 44 | 45 | ||
diff --git a/frontend/src/pages/User.tsx b/frontend/src/pages/User.tsx index 1f6d8d0..1605ada 100644 --- a/frontend/src/pages/User.tsx +++ b/frontend/src/pages/User.tsx | |||
| @@ -79,7 +79,7 @@ const User: React.FC = () => { | |||
| 79 | 79 | ||
| 80 | React.useEffect(() => { | 80 | React.useEffect(() => { |
| 81 | _fetch_user(); | 81 | _fetch_user(); |
| 82 | }, []); | 82 | }, [user]); |
| 83 | 83 | ||
| 84 | React.useEffect(() => { | 84 | React.useEffect(() => { |
| 85 | if (game !== "0") { | 85 | if (game !== "0") { |