-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bc8a27c
commit ada1bc6
Showing
11 changed files
with
42 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,9 @@ import { deleteAccount, logout } from '../../../api'; | |
import UserContext from '../../../auth/Context'; | ||
import { useHistory } from 'react-router'; | ||
import { useConfirm } from 'material-ui-confirm'; | ||
import { useSnackbar } from 'notistack'; | ||
import useTranslations from '../../../translations'; | ||
import { trackEvent } from '../../../track'; | ||
|
||
type DeleteModalProps = { | ||
onClose: () => void; | ||
|
@@ -35,6 +37,7 @@ export function DeleteModal({ onClose }: DeleteModalProps) { | |
const [deletePosts, setDeletePosts] = useState(false); | ||
const [deleteVotes, setDeleteVotes] = useState(false); | ||
const { setUser } = useContext(UserContext); | ||
const { enqueueSnackbar } = useSnackbar(); | ||
const user = useUser(); | ||
const { push } = useHistory(); | ||
const confirm = useConfirm(); | ||
|
@@ -61,10 +64,19 @@ export function DeleteModal({ onClose }: DeleteModalProps) { | |
confirmationButtonProps: { color: 'error', variant: 'contained' }, | ||
}) | ||
.then(async () => { | ||
await deleteAccount(payload); | ||
logout(); | ||
setUser(null); | ||
push('/'); | ||
trackEvent('account/gdpr/delete-account'); | ||
const success = await deleteAccount(payload); | ||
if (success) { | ||
logout(); | ||
setUser(null); | ||
push('/'); | ||
} else { | ||
enqueueSnackbar( | ||
'Deleting your account failed. Please contact support: [email protected]', | ||
{ variant: 'error' } | ||
); | ||
onClose(); | ||
} | ||
}) | ||
.catch(() => { | ||
onClose(); | ||
|
@@ -79,6 +91,7 @@ export function DeleteModal({ onClose }: DeleteModalProps) { | |
confirm, | ||
onClose, | ||
translations, | ||
enqueueSnackbar, | ||
]); | ||
|
||
if (!user) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters