From 05e53969dde98fa2ca1683a35d885a03d54b956b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louise=20Linn=C3=A9?= Date: Fri, 29 Sep 2023 00:41:38 +0200 Subject: [PATCH] Reroute to dashboard after delete profile is complete --- src/components/ButtonDeleteProfile.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/components/ButtonDeleteProfile.js b/src/components/ButtonDeleteProfile.js index 38a63a2e..9a268fe4 100644 --- a/src/components/ButtonDeleteProfile.js +++ b/src/components/ButtonDeleteProfile.js @@ -2,6 +2,9 @@ import { Box, Typography } from '@mui/material'; import makeStyles from '@mui/styles/makeStyles'; import React, { useState } from 'react'; import { useDispatch } from 'react-redux'; +import { Redirect } from 'react-router-dom'; + +import { DASHBOARD_PATH } from '~/routes'; import Button from '~/components/Button'; import DialogInfo from '~/components/DialogInfo'; @@ -24,6 +27,7 @@ const ButtonDeleteProfile = () => { const dispatch = useDispatch(); const [isOpenDialogCloseInfo, setIsOpenDialogCloseInfo] = useState(false); + const [isProfileDeleted, setIsProfileDeleted] = useState(false); const dialogCloseInfoHandler = () => { setIsOpenDialogCloseInfo(false); @@ -40,6 +44,8 @@ const ButtonDeleteProfile = () => { type: NotificationsTypes.SUCCESS, }), ); + + setIsProfileDeleted(true); } catch (error) { logError(error); dispatch( @@ -102,6 +108,10 @@ const ButtonDeleteProfile = () => { ); + if (isProfileDeleted) { + return ; + } + return (