From f5ad360d02303ce27a65e67feb8ae38f1e26742c Mon Sep 17 00:00:00 2001 From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> Date: Thu, 31 Oct 2024 23:58:14 +0300 Subject: frontend: convert all native confirm and alerts to custom hooks --- frontend/src/pages/Profile.tsx | 396 ++++++++++++++++++++--------------------- 1 file changed, 198 insertions(+), 198 deletions(-) (limited to 'frontend/src/pages/Profile.tsx') diff --git a/frontend/src/pages/Profile.tsx b/frontend/src/pages/Profile.tsx index 5c5676e..590bb9b 100644 --- a/frontend/src/pages/Profile.tsx +++ b/frontend/src/pages/Profile.tsx @@ -71,10 +71,10 @@ const Profile: React.FC = ({ profile, token, gameData, onDeleteRec return; } - messageLoad("Deleting..."); + messageLoad("Deleting..."); const api_success = await API.delete_map_record(token!, map_id, record_id); - messageLoadClose(); + messageLoadClose(); if (api_success) { await message("Delete Record", "Successfully deleted record."); onDeleteRecord(); @@ -108,240 +108,240 @@ const Profile: React.FC = ({ profile, token, gameData, onDeleteRec }; return ( -
- {MessageDialogComponent} - {MessageDialogLoadComponent} - {ConfirmDialogComponent} - -
-
- - {profile.profile - ? ( -
- profile-image - Refresh +
+ {MessageDialogComponent} + {MessageDialogLoadComponent} + {ConfirmDialogComponent} + +
+
+ + {profile.profile + ? ( +
+ profile-image + Refresh +
+ ) : ( +
+ profile-image +
+ )} + +
+
+
{profile.user_name}
+
+ {profile.country_code === "XX" ? "" : {profile.country_code}} +
+
+ {profile.titles.map(e => ( + + {e.name} + + ))} +
- ) : (
- profile-image + {profile.links.steam === "-" ? "" : Steam} + {profile.links.twitch === "-" ? "" : Twitch} + {profile.links.youtube === "-" ? "" : Youtube} + {profile.links.p2sr === "-" ? "" : P2SR}
- )} -
-
-
{profile.user_name}
+
+
- {profile.country_code === "XX" ? "" : {profile.country_code}} + Overall + {profile.rankings.overall.rank === 0 ? "N/A " : "#" + profile.rankings.overall.rank + " "} + ({profile.rankings.overall.completion_count}/{profile.rankings.overall.completion_total}) +
- {profile.titles.map(e => ( - - {e.name} - - ))} + Singleplayer + {profile.rankings.singleplayer.rank === 0 ? "N/A " : "#" + profile.rankings.singleplayer.rank + " "} + ({profile.rankings.singleplayer.completion_count}/{profile.rankings.singleplayer.completion_total}) + +
+
+ Cooperative + {profile.rankings.cooperative.rank === 0 ? "N/A " : "#" + profile.rankings.cooperative.rank + " "} + ({profile.rankings.cooperative.completion_count}/{profile.rankings.cooperative.completion_total}) +
-
- {profile.links.steam === "-" ? "" : Steam} - {profile.links.twitch === "-" ? "" : Twitch} - {profile.links.youtube === "-" ? "" : Youtube} - {profile.links.p2sr === "-" ? "" : P2SR} -
- -
-
-
- Overall - {profile.rankings.overall.rank === 0 ? "N/A " : "#" + profile.rankings.overall.rank + " "} - ({profile.rankings.overall.completion_count}/{profile.rankings.overall.completion_total}) - -
-
- Singleplayer - {profile.rankings.singleplayer.rank === 0 ? "N/A " : "#" + profile.rankings.singleplayer.rank + " "} - ({profile.rankings.singleplayer.completion_count}/{profile.rankings.singleplayer.completion_total}) - -
-
- Cooperative - {profile.rankings.cooperative.rank === 0 ? "N/A " : "#" + profile.rankings.cooperative.rank + " "} - ({profile.rankings.cooperative.completion_count}/{profile.rankings.cooperative.completion_total}) - -
-
-
- - -
- - -
+
+
+ + +
-
-
- {gameData === null ? : - - } - {game === "0" ? - - : chapterData === null ? : +
+
+ {gameData === null ? : - { + setGame((document.querySelector('#select-game') as HTMLInputElement).value); + setChapter("0"); + const chapterSelect = document.querySelector('#select-chapter') as HTMLSelectElement; + if (chapterSelect) { + chapterSelect.value = "0"; + } + }}> + + {gameData.map((e, i) => ( ))} - } -
-
- Map Name - Portals - WRΔ - Time - - Rank - Date -
-
- - {pageNumber}/{pageMax} - + } + + {game === "0" ? + + : chapterData === null ? : + + + } +
+
+ Map Name + Portals + WRΔ + Time + + Rank + Date +
+
+ + {pageNumber}/{pageMax} + +
-
-
-
+
+
- {game === "0" - ? ( + {game === "0" + ? ( - profile.records.sort((a, b) => a.map_id - b.map_id) - .map((r, index) => ( - - Math.ceil((index + 1) / 20) === pageNumber ? ( - - - - {i === 0 && r.scores.length > 1 ? : ""} - - - ))} - - - ) : "" - ))) : maps ? - - maps.filter(e => e.is_disabled === false).sort((a, b) => a.id - b.id) - .map((r, index) => { - if (Math.ceil((index + 1) / 20) === pageNumber) { - let record = profile.records.find((e) => e.map_id === r.id); - return record === undefined ? ( - - ) : ( + profile.records.sort((a, b) => a.map_id - b.map_id) + .map((r, index) => ( + + Math.ceil((index + 1) / 20) === pageNumber ? ( - + + - {i === 0 && record!.scores.length > 1 ? : ""} ))} - - ) - } else { return null } - }) : (<>{console.warn(maps)})} -
-
-
-
+ + ) : "" + ))) : maps ? + + maps.filter(e => e.is_disabled === false).sort((a, b) => a.id - b.id) + .map((r, index) => { + if (Math.ceil((index + 1) / 20) === pageNumber) { + let record = profile.records.find((e) => e.map_id === r.id); + return record === undefined ? ( + + ) : ( + + + + {i === 0 && record!.scores.length > 1 ? : ""} + + + ))} + + + ) + } else { return null } + }) : (<>{console.warn(maps)})} + + + + ); }; -- cgit v1.2.3