Removed unnecessary timeout and replaced Promise.then()

This commit is contained in:
Daniel Cojocea committed 2024-07-10 10:01:36 -04:00
1 parent bd5ed007eb
commit 85a2177f1d
2 files changed
+6 -10

No files matched your search

@@ -183,13 +183,12 @@ const ProfilePanel = () => {
}; };
// Initiates the account deletion process // Initiates the account deletion process
const handleDeleteAccount = () => { const handleDeleteAccount = async () => {
dispatch(deleteUser(authToken)).then((action) => { const action = await dispatch(deleteUser(authToken));
if (action.payload.success) { if (action.payload.success) {
dispatch(clearAuthState()); dispatch(clearAuthState());
dispatch(clearMonitorState()); dispatch(clearMonitorState());
} }
});
}; };
// Modal state and control functions // Modal state and control functions
-3
View File
@@ -80,9 +80,6 @@ export const deleteUser = createAsyncThunk(
async (data, thunkApi) => { async (data, thunkApi) => {
const user = jwtDecode(data); const user = jwtDecode(data);
//1.5s delay to show loading spinner
await new Promise((resolve) => setTimeout(resolve, 1500));
try { try {
const res = await axiosInstance.delete(`/auth/user/${user._id}`, { const res = await axiosInstance.delete(`/auth/user/${user._id}`, {
headers: { Authorization: `Bearer ${data}` }, headers: { Authorization: `Bearer ${data}` },