2020-07-28 00:42:28 +03:00
import React , { ComponentType , useCallback , useState } from 'react' ;
2020-07-27 10:28:37 +03:00
import { FormattedMessage as Message } from 'react-intl' ;
import { Helmet } from 'react-helmet-async' ;
import { Button } from 'app/components/ui/form' ;
import styles from './accountDeleted.scss' ;
interface Props {
2020-07-28 00:42:28 +03:00
onRestore ? : ( ) = > Promise < void > ;
2020-07-27 10:28:37 +03:00
}
const AccountDeleted : ComponentType < Props > = ( { onRestore } ) = > {
2020-07-28 00:42:28 +03:00
const [ isSubmitted , setIsSubmitted ] = useState < boolean > ( false ) ;
const onRestoreClick = useCallback ( ( ) = > {
if ( ! onRestore ) {
return ;
}
setIsSubmitted ( true ) ;
onRestore ( ) . finally ( ( ) = > setIsSubmitted ( false ) ) ;
} , [ onRestore ] ) ;
2020-07-27 10:28:37 +03:00
return (
2020-07-28 23:00:51 +03:00
< div className = { styles . wrapper } data-testid = "deletedAccount" >
2020-07-27 14:25:51 +03:00
< Message key = "accountDeleted" defaultMessage = "Account is deleted" >
2020-07-27 10:28:37 +03:00
{ ( pageTitle : string ) = > (
< h2 className = { styles . title } >
< Helmet title = { pageTitle } / >
{ pageTitle }
< / h2 >
) }
< / Message >
< div className = { styles . description } >
< Message
key = "accountDeletedDescription"
2020-07-27 14:25:51 +03:00
defaultMessage = "The account has been marked for deletion and will be permanently removed within a week. Until then, all account activities have been suspended."
2020-07-27 10:28:37 +03:00
/ >
< / div >
< div className = { styles . description } >
< Message
key = "ifYouWantToRestoreAccount"
defaultMessage = "If you want to restore your account, click on the button below."
/ >
< / div >
2020-07-28 00:42:28 +03:00
< Button onClick = { onRestoreClick } color = "black" small loading = { isSubmitted } >
2020-07-27 10:28:37 +03:00
< Message key = "restoreAccount" defaultMessage = "Restore account" / >
< / Button >
< / div >
) ;
} ;
export default AccountDeleted ;