// Copyright 2019-2021 @polkadot/extension-ui authors & contributors // SPDX-License-Identifier: Apache-2.0 import type { ThemeProps } from '../types'; import React, { useCallback, useContext, useState } from 'react'; import { RouteComponentProps, withRouter } from 'react-router'; import styled from 'styled-components'; import { ActionBar, ActionContext, ActionText, Address, Button, Warning } from '../components'; import useTranslation from '../hooks/useTranslation'; import { forgetAccount } from '../messaging'; import { Header } from '../partials'; interface Props extends RouteComponentProps<{ address: string }>, ThemeProps { className?: string; } function Forget ({ className, match: { params: { address } } }: Props): React.ReactElement { const { t } = useTranslation(); const onAction = useContext(ActionContext); const [isBusy, setIsBusy] = useState(false); const _goHome = useCallback( () => onAction('/'), [onAction] ); const _onClick = useCallback( (): void => { setIsBusy(true); forgetAccount(address) .then(() => { setIsBusy(false); onAction('/'); }) .catch((error: Error) => { setIsBusy(false); console.error(error); }); }, [address, onAction] ); return ( <>
('Forget account')} />
{t('You are about to remove the account. This means that you will not be able to access it via this extension anymore. If you wish to recover it, you would need to use the seed.')}
('Cancel')} />
); } export default withRouter(styled(Forget)` .actionArea { padding: 10px 24px; } .center { margin: auto; } .movedWarning { margin-top: 8px; } .withMarginTop { margin-top: 4px; } `);