Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React from 'react';
import PropTypes from 'prop-types';
import { useI18nContext } from '../../../../hooks/useI18nContext';

import Popover from '../../../../components/ui/popover';
import Box from '../../../../components/ui/box';

import {
Expand All @@ -19,6 +18,12 @@ import {
Button,
BUTTON_VARIANT,
Text,
Modal,
ModalOverlay,
ModalContent,
ModalHeader,
ModalBody,
ModalFooter,
} from '../../../../components/component-library';

const SetApproveForAllWarning = ({
Expand All @@ -29,88 +34,98 @@ const SetApproveForAllWarning = ({
isERC721,
onSubmit,
onCancel,
isOpen = true,
onClose,
}) => {
const t = useI18nContext();
const handleClose = onClose ?? onCancel;

const footer = (
<Box
display={DISPLAY.FLEX}
flexDirection={FLEX_DIRECTION.COLUMN}
justifyContent={JustifyContent.SPACE_BETWEEN}
className="set-approval-for-all-warning__footer"
gap={4}
return (
<Modal
isOpen={isOpen}
onClose={handleClose}
className="set-approval-for-all-warning__content"
>
<Button
className="set-approval-for-all-warning__footer__approve-button"
variant={BUTTON_VARIANT.PRIMARY}
danger
onClick={onSubmit}
>
{t('approveButtonText')}
</Button>
<Button
className="set-approval-for-all-warning__footer__cancel-button"
variant={BUTTON_VARIANT.SECONDARY}
onClick={onCancel}
>
{t('reject')}
</Button>
</Box>
);
<ModalOverlay />
<ModalContent>
<ModalHeader onClose={handleClose}>
<Box
display={DISPLAY.FLEX}
flexDirection={FLEX_DIRECTION.ROW}
className="set-approval-for-all-warning__content__header"
>
<Icon
name={IconName.Danger}
className="set-approval-for-all-warning__content__header__warning-icon"
/>
<Text variant={TextVariant.headingSm} as="h4">
{t('yourNFTmayBeAtRisk')}
</Text>
</Box>
</ModalHeader>
<ModalBody>
<Box
display={DISPLAY.FLEX}
justifyContent={JustifyContent.spaceBetween}
className="set-approval-for-all-warning__content__account"
>
<Box display={DISPLAY.FLEX}>
<PreferredAvatar address={senderAddress} />
<Text
variant={TextVariant.bodyMd}
as="h5"
marginLeft={2}
className="set-approval-for-all-warning__content__account-name"
>
<strong>{name}</strong> {` (${shortenAddress(senderAddress)})`}
</Text>
</Box>
{isERC721 && total && <Text>{`${t('total')}: ${total}`}</Text>}
</Box>

return (
<Popover className="set-approval-for-all-warning__content" footer={footer}>
<Box
display={DISPLAY.FLEX}
flexDirection={FLEX_DIRECTION.ROW}
padding={4}
className="set-approval-for-all-warning__content__header"
>
<Icon
name={IconName.Danger}
className="set-approval-for-all-warning__content__header__warning-icon"
/>
<Text variant={TextVariant.headingSm} as="h4">
{t('yourNFTmayBeAtRisk')}
</Text>
</Box>
<Box
display={DISPLAY.FLEX}
padding={4}
justifyContent={JustifyContent.spaceBetween}
className="set-approval-for-all-warning__content__account"
>
<Box display={DISPLAY.FLEX}>
<PreferredAvatar address={senderAddress} />
<Text
variant={TextVariant.bodyMd}
as="h5"
marginLeft={2}
className="set-approval-for-all-warning__content__account-name"
marginTop={4}
marginBottom={4}
variant={TextVariant.bodySm}
as="h6"
>
<strong>{name}</strong> {` (${shortenAddress(senderAddress)})`}
{t('nftWarningContent', [
<strong key="non_custodial_bold">
{t('nftWarningContentBold', [collectionName || ''])}
</strong>,
<strong key="non_custodial_grey">
{t('nftWarningContentGrey')}
</strong>,
])}
</Text>
</Box>
{isERC721 && total && <Text>{`${t('total')}: ${total}`}</Text>}
</Box>

<Text
margin={4}
marginTop={4}
marginBottom={4}
variant={TextVariant.bodySm}
as="h6"
>
{t('nftWarningContent', [
<strong key="non_custodial_bold">
{t('nftWarningContentBold', [collectionName || ''])}
</strong>,
<strong key="non_custodial_grey">
{t('nftWarningContentGrey')}
</strong>,
])}
</Text>
</Popover>
</ModalBody>
<ModalFooter>
<Box
display={DISPLAY.FLEX}
flexDirection={FLEX_DIRECTION.COLUMN}
justifyContent={JustifyContent.SPACE_BETWEEN}
className="set-approval-for-all-warning__footer"
gap={4}
>
<Button
className="set-approval-for-all-warning__footer__approve-button"
variant={BUTTON_VARIANT.PRIMARY}
danger
onClick={onSubmit}
>
{t('approveButtonText')}
</Button>
<Button
className="set-approval-for-all-warning__footer__cancel-button"
variant={BUTTON_VARIANT.SECONDARY}
onClick={onCancel}
>
{t('reject')}
</Button>
</Box>
</ModalFooter>
</ModalContent>
</Modal>
);
};

Expand Down Expand Up @@ -143,6 +158,14 @@ SetApproveForAllWarning.propTypes = {
* Function that rejects collection
*/
onCancel: PropTypes.func,
/**
* Whether the modal is open
*/
isOpen: PropTypes.bool,
/**
* Function called when the modal requests to close (defaults to onCancel)
*/
onClose: PropTypes.func,
};

export default SetApproveForAllWarning;
Loading