From 3ee18a8cb3a2893f552275c35b0724daf4b8ab69 Mon Sep 17 00:00:00 2001
From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com>
Date: Tue, 22 Oct 2024 12:23:35 +0300
Subject: frontend: await message

---
 frontend/src/pages/Profile.tsx | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

(limited to 'frontend/src/pages/Profile.tsx')

diff --git a/frontend/src/pages/Profile.tsx b/frontend/src/pages/Profile.tsx
index 7559c77..05f372e 100644
--- a/frontend/src/pages/Profile.tsx
+++ b/frontend/src/pages/Profile.tsx
@@ -63,7 +63,7 @@ const Profile: React.FC<ProfileProps> = ({ profile, token, gameData, onDeleteRec
   };
 
   const _delete_submission = async (map_id: number, record_id: number) => {
-    const userConfirmed = await confirm("Delete record?", "This action cannot be undone");
+    const userConfirmed = await confirm("Delete Record", "Are you sure you want to delete this record?");
 
     if (!userConfirmed) {
       return;
@@ -71,9 +71,9 @@ const Profile: React.FC<ProfileProps> = ({ profile, token, gameData, onDeleteRec
 
     const api_success = await API.delete_map_record(token!, map_id, record_id);
     if (api_success) {
-      message("Success", "Successfully deleted record");
+      await message("Delete Record", "Successfully deleted record.");
     } else {
-      message("Error", "Could not delete record");
+      await message("Delete Record", "Could not delete record.");
     }
   };
 
-- 
cgit v1.2.3


From 0f81fafe764f6fc4b8f64e184520b5ea0a26a0d0 Mon Sep 17 00:00:00 2001
From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com>
Date: Tue, 22 Oct 2024 13:32:47 +0300
Subject: frontend: update profile on delete run

---
 frontend/src/App.tsx           | 15 ++++-----------
 frontend/src/pages/Profile.tsx |  1 +
 2 files changed, 5 insertions(+), 11 deletions(-)

(limited to 'frontend/src/pages/Profile.tsx')

diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx
index e39e1b6..c6952b1 100644
--- a/frontend/src/App.tsx
+++ b/frontend/src/App.tsx
@@ -1,5 +1,5 @@
 import React from 'react';
-import { Routes, Route, useLocation } from "react-router-dom";
+import { Routes, Route } from "react-router-dom";
 
 import { UserProfile } from './types/Profile';
 import Sidebar from './components/Sidebar';
@@ -18,22 +18,15 @@ import { API } from './api/Api';
 import Maplist from './pages/Maplist';
 import Rankings from './pages/Rankings';
 import { get_user_id_from_token, get_user_mod_from_token } from './utils/Jwt';
-import { MapDeleteEndpoint } from './types/Map';
 
 const App: React.FC = () => {
   const [token, setToken] = React.useState<string | undefined>(undefined);
   const [profile, setProfile] = React.useState<UserProfile | undefined>(undefined);
   const [isModerator, setIsModerator] = React.useState<boolean>(false);
 
-  const [msgIsOpen, setMsgIsOpen] = React.useState<boolean>(false);
-
   const [games, setGames] = React.useState<Game[]>([]);
 
   const [uploadRunDialog, setUploadRunDialog] = React.useState<boolean>(false);
-  const [uploadRunDialogMapID, setUploadRunDialogMapID] = React.useState<number | undefined>(undefined);
-
-  const [confirmDialogOpen, setConfirmDialogOpen] = React.useState<boolean>(false);
-  const [currDeleteMapInfo, setCurrDeleteMapInfo] = React.useState<MapDeleteEndpoint>();
 
   const _fetch_token = async () => {
     const token = await API.get_token();
@@ -83,18 +76,18 @@ const App: React.FC = () => {
     <>
       <UploadRunDialog token={token} open={uploadRunDialog} onClose={(updateProfile) => {
         setUploadRunDialog(false);
-        if (updateProfile && token) {
+        if (updateProfile) {
           _set_profile(get_user_id_from_token(token));
         }
       }} games={games} />
       <Sidebar setToken={setToken} profile={profile} setProfile={setProfile} onUploadRun={() => setUploadRunDialog(true)} />
       <Routes>
         <Route path="/" element={<Homepage />} />
-        <Route path="/profile" element={<Profile profile={profile} token={token} gameData={games} onDeleteRecord={() => setConfirmDialogOpen(true)} />} />
+        <Route path="/profile" element={<Profile profile={profile} token={token} gameData={games} onDeleteRecord={() => _set_profile(get_user_id_from_token(token))} />} />
         <Route path="/users/*" element={<User profile={profile} token={token} gameData={games} />} />
         <Route path="/games" element={<Games games={games} />} />
         <Route path='/games/:id' element={<Maplist />}></Route>
-        <Route path="/maps/*" element={<Maps token={token} isModerator={isModerator} />}/>
+        <Route path="/maps/*" element={<Maps token={token} isModerator={isModerator} />} />
         <Route path="/rules" element={<Rules />} />
         <Route path="/about" element={<About />} />
         <Route path='/rankings' element={<Rankings />}></Route>
diff --git a/frontend/src/pages/Profile.tsx b/frontend/src/pages/Profile.tsx
index 05f372e..5d1c75d 100644
--- a/frontend/src/pages/Profile.tsx
+++ b/frontend/src/pages/Profile.tsx
@@ -72,6 +72,7 @@ const Profile: React.FC<ProfileProps> = ({ profile, token, gameData, onDeleteRec
     const api_success = await API.delete_map_record(token!, map_id, record_id);
     if (api_success) {
       await message("Delete Record", "Successfully deleted record.");
+      onDeleteRecord();
     } else {
       await message("Delete Record", "Could not delete record.");
     }
-- 
cgit v1.2.3

