1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-23 02:10:12 +01:00
metamask-extension/ui/components/multichain/import-account/bottom-buttons.js
David Walsh 28137798b6
UX: Multichain: Move Add Account and Import Account into Account Menu Popover (#19346)
* UX: Multichain: Move Add Account and Import Account into Account Menu Popover

* Create a new CreateAccount component for the Account Menu

* Add actions for import form

* Use separate actions for cancel vs. submit

* Fix jest tests

* Remove commented route navigation

* Accommodate for failing import

* Fix tests

* Remove routes for new account and import

* Remove old create account page

* Move import-account files to multichain directory

* Fix paths on the import files

* Remove deprecated component library variables

* Fix error property of add form

* Fix user-actions-benchmark
2023-06-13 10:07:01 -05:00

61 lines
1.5 KiB
JavaScript

import PropTypes from 'prop-types';
import React from 'react';
import { useDispatch } from 'react-redux';
import {
ButtonPrimary,
ButtonSecondary,
BUTTON_SECONDARY_SIZES,
} from '../../component-library';
import Box from '../../ui/box/box';
import { Display } from '../../../helpers/constants/design-system';
import { useI18nContext } from '../../../hooks/useI18nContext';
import * as actions from '../../../store/actions';
BottomButtons.propTypes = {
importAccountFunc: PropTypes.func.isRequired,
isPrimaryDisabled: PropTypes.bool.isRequired,
onActionComplete: PropTypes.func.isRequired,
};
export default function BottomButtons({
importAccountFunc,
isPrimaryDisabled,
onActionComplete,
}) {
const t = useI18nContext();
const dispatch = useDispatch();
return (
<Box display={Display.Flex} gap={4}>
<ButtonSecondary
onClick={() => {
dispatch(actions.hideWarning());
onActionComplete();
}}
size={BUTTON_SECONDARY_SIZES.LG}
block
>
{t('cancel')}
</ButtonSecondary>
<ButtonPrimary
onClick={async () => {
try {
const result = await importAccountFunc();
if (result) {
onActionComplete(true);
}
} catch (e) {
// Take no action
}
}}
disabled={isPrimaryDisabled}
size={BUTTON_SECONDARY_SIZES.LG}
data-testid="import-account-confirm-button"
block
>
{t('import')}
</ButtonPrimary>
</Box>
);
}