aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/pages/Profile.tsx
diff options
context:
space:
mode:
authorWolfboy248 <105884620+Wolfboy248@users.noreply.github.com>2024-10-20 00:27:38 +0200
committerWolfboy248 <105884620+Wolfboy248@users.noreply.github.com>2024-10-20 00:27:38 +0200
commit8c8edfc9c8bb1a0fa3d1e02aab576044857f1c95 (patch)
treecf23b52befb9af6d16321b9e9031ace724543875 /frontend/src/pages/Profile.tsx
parentbackend: actually fix download demo (diff)
downloadlphub-8c8edfc9c8bb1a0fa3d1e02aab576044857f1c95.tar.gz
lphub-8c8edfc9c8bb1a0fa3d1e02aab576044857f1c95.tar.bz2
lphub-8c8edfc9c8bb1a0fa3d1e02aab576044857f1c95.zip
refactor: custom modals
Diffstat (limited to 'frontend/src/pages/Profile.tsx')
-rw-r--r--frontend/src/pages/Profile.tsx19
1 files changed, 14 insertions, 5 deletions
diff --git a/frontend/src/pages/Profile.tsx b/frontend/src/pages/Profile.tsx
index 09033a5..bf79a65 100644
--- a/frontend/src/pages/Profile.tsx
+++ b/frontend/src/pages/Profile.tsx
@@ -8,7 +8,8 @@ import { Map } from '../types/Map';
8import { ticks_to_time } from '../utils/Time'; 8import { ticks_to_time } from '../utils/Time';
9import "../css/Profile.css"; 9import "../css/Profile.css";
10import { API } from '../api/Api'; 10import { API } from '../api/Api';
11import MapDeleteConfirmDialog from '../components/MapDeleteConfirmDialog'; 11import useConfirm from '../components/UseConfirm';
12import useMessage from '../components/UseMessage';
12 13
13interface ProfileProps { 14interface ProfileProps {
14 profile?: UserProfile; 15 profile?: UserProfile;
@@ -18,7 +19,8 @@ interface ProfileProps {
18} 19}
19 20
20const Profile: React.FC<ProfileProps> = ({ profile, token, gameData, onDeleteRecord }) => { 21const Profile: React.FC<ProfileProps> = ({ profile, token, gameData, onDeleteRecord }) => {
21 22 const { confirm, ConfirmDialogComponent } = useConfirm("Delete record?", "This action cannot be undone");
23 const { message, MessageDialogComponent } = useMessage();
22 const [navState, setNavState] = React.useState(0); 24 const [navState, setNavState] = React.useState(0);
23 const [pageNumber, setPageNumber] = React.useState(1); 25 const [pageNumber, setPageNumber] = React.useState(1);
24 const [pageMax, setPageMax] = React.useState(0); 26 const [pageMax, setPageMax] = React.useState(0);
@@ -61,12 +63,17 @@ const Profile: React.FC<ProfileProps> = ({ profile, token, gameData, onDeleteRec
61 }; 63 };
62 64
63 const _delete_submission = async (map_id: number, record_id: number) => { 65 const _delete_submission = async (map_id: number, record_id: number) => {
64 onDeleteRecord(); 66 const userConfirmed = await confirm();
67
68 if (!userConfirmed) {
69 return;
70 }
71
65 const api_success = await API.delete_map_record(token!, map_id, record_id); 72 const api_success = await API.delete_map_record(token!, map_id, record_id);
66 if (api_success) { 73 if (api_success) {
67 window.alert("Successfully deleted record"); 74 message("Success", "Successfully deleted record");
68 } else { 75 } else {
69 window.alert("Error: Could not delete record"); 76 message("Error", "Could not delete record");
70 } 77 }
71 }; 78 };
72 79
@@ -96,6 +103,8 @@ const Profile: React.FC<ProfileProps> = ({ profile, token, gameData, onDeleteRec
96 103
97 return ( 104 return (
98 <main> 105 <main>
106 {ConfirmDialogComponent}
107 {MessageDialogComponent}
99 <section id='section1' className='profile'> 108 <section id='section1' className='profile'>
100 109
101 {profile.profile 110 {profile.profile