-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add account data deletion functionality
- Loading branch information
Showing
4 changed files
with
139 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
import { Box, Typography } from '@mui/material'; | ||
import makeStyles from '@mui/styles/makeStyles'; | ||
import React, { useState } from 'react'; | ||
import { useDispatch } from 'react-redux'; | ||
|
||
import Button from '~/components/Button'; | ||
import DialogInfo from '~/components/DialogInfo'; | ||
import translate from '~/services/locale'; | ||
import notify, { NotificationsTypes } from '~/store/notifications/actions'; | ||
import logError, { translateErrorForUser } from '~/utils/debug'; | ||
|
||
const useStyles = makeStyles(() => ({ | ||
textContainer: { | ||
maxWidth: '250px', | ||
margin: '0 auto', | ||
marginBottom: '20px', | ||
}, | ||
btnContainer: { | ||
display: 'flex', | ||
flexDirection: 'row', | ||
alignItems: 'center', | ||
justifyContent: 'flex-end', | ||
marginTop: '32px', | ||
}, | ||
})); | ||
|
||
const RemoveYourData = () => { | ||
const classes = useStyles(); | ||
const dispatch = useDispatch(); | ||
|
||
const [isOpenDialogCloseInfo, setIsOpenDialogCloseInfo] = useState(false); | ||
|
||
const dialogCloseInfoHandler = () => { | ||
setIsOpenDialogCloseInfo(false); | ||
try { | ||
// TODO add delete logic | ||
|
||
dispatch( | ||
notify({ | ||
text: ( | ||
<Typography classes={{ root: 'body4_white' }} variant="body4"> | ||
{translate('RemoveYourData.confirmationText')} | ||
</Typography> | ||
), | ||
type: NotificationsTypes.SUCCESS, | ||
}), | ||
); | ||
} catch (error) { | ||
logError(error); | ||
dispatch( | ||
notify({ | ||
text: ( | ||
<Typography classes={{ root: 'body4_white' }} variant="body4"> | ||
{translateErrorForUser(error)} | ||
</Typography> | ||
), | ||
type: NotificationsTypes.ERROR, | ||
}), | ||
); | ||
} | ||
}; | ||
|
||
const dialogOpenInfoHandler = () => { | ||
setIsOpenDialogCloseInfo(true); | ||
}; | ||
|
||
const dialogContentClose = ( | ||
<Box className={classes.dialogContentContainer}> | ||
<Typography align="center" mb={2}> | ||
{translate('RemoveYourData.bodyText')} | ||
</Typography> | ||
<Typography align="center" mb={2}> | ||
{translate('RemoveYourData.bodyText2')} | ||
</Typography> | ||
<Typography align="center" mb={2}> | ||
{translate('RemoveYourData.bodyText3')} | ||
</Typography> | ||
<Typography align="center" mb={2}> | ||
{translate('RemoveYourData.bodyText4')} | ||
</Typography> | ||
<Box className={classes.btnContainer}> | ||
<Button | ||
className={classes.continueButton} | ||
fullWidth | ||
onClick={dialogCloseInfoHandler} | ||
> | ||
{translate('RemoveYourData.confirmationDelete')} | ||
</Button> | ||
<Button | ||
fullWidth | ||
isText | ||
onClick={() => setIsOpenDialogCloseInfo(false)} | ||
> | ||
{translate('RemoveYourData.confirmationCancel')} | ||
</Button> | ||
</Box> | ||
</Box> | ||
); | ||
|
||
return ( | ||
<Box> | ||
<DialogInfo | ||
dialogContent={dialogContentClose} | ||
fullWidth | ||
handleClose={() => setIsOpenDialogCloseInfo(false)} | ||
isBtnClose={false} | ||
isOpen={isOpenDialogCloseInfo} | ||
maxWidth={'xs'} | ||
title={translate('RemoveYourData.titleText')} | ||
/> | ||
<Button fullWidth isText onClick={dialogOpenInfoHandler}> | ||
{translate('RemoveYourData.btnText')} | ||
</Button> | ||
</Box> | ||
); | ||
}; | ||
|
||
export default RemoveYourData; |
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