Skip to content

Commit

Permalink
Reroute to dashboard after delete profile is complete
Browse files Browse the repository at this point in the history
  • Loading branch information
louilinn committed Oct 10, 2023
1 parent c96b449 commit 05e5396
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/components/ButtonDeleteProfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -24,6 +27,7 @@ const ButtonDeleteProfile = () => {
const dispatch = useDispatch();

const [isOpenDialogCloseInfo, setIsOpenDialogCloseInfo] = useState(false);
const [isProfileDeleted, setIsProfileDeleted] = useState(false);

const dialogCloseInfoHandler = () => {
setIsOpenDialogCloseInfo(false);
Expand All @@ -40,6 +44,8 @@ const ButtonDeleteProfile = () => {
type: NotificationsTypes.SUCCESS,
}),
);

setIsProfileDeleted(true);
} catch (error) {
logError(error);
dispatch(
Expand Down Expand Up @@ -102,6 +108,10 @@ const ButtonDeleteProfile = () => {
</Box>
);

if (isProfileDeleted) {
return <Redirect to={DASHBOARD_PATH} />;
}

return (
<Box>
<DialogInfo
Expand Down

0 comments on commit 05e5396

Please sign in to comment.