Skip to content

Commit 543ec53

Browse files
cursoragentn3ps
andcommitted
refactor: migrate coin buttons toast (CEUX-1188)
Isolated ticket-only changes on top of toast-helpers. Co-authored-by: Francis Nepomuceno <n3ps@users.noreply.github.com>
1 parent ef7bf5c commit 543ec53

1 file changed

Lines changed: 12 additions & 26 deletions

File tree

ui/components/app/wallet-overview/coin-buttons.tsx

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ import IconButton from '../../ui/icon-button';
6666
import useRampsNavigation from '../../../hooks/ramps/useRampsNavigation/useRampsNavigation';
6767
import useBridging from '../../../hooks/bridge/useBridging';
6868
import { ReceiveModal } from '../../multichain/receive-modal';
69-
import { Toast, ToastContainer } from '../../multichain/toast';
69+
import { showSuccessToast } from '../../ui/toast/toast';
7070
import { setActiveNetworkWithError } from '../../../store/actions';
7171
import {
7272
getMultichainNativeCurrency,
@@ -85,8 +85,12 @@ import {
8585
ARC_ERC20_USDC_BRIDGE_ASSET,
8686
ARC_HEX_CHAIN_ID,
8787
} from '../assets/enablement/arc';
88+
import { SECOND } from '../../../../shared/constants/time';
8889
import { useHandleSendNonEvm } from './hooks/useHandleSendNonEvm';
8990

91+
const BUY_TAB_OPENED_TOAST_ID = 'buy-tab-opened-toast';
92+
const BUY_TAB_OPENED_TOAST_DURATION = 3 * SECOND;
93+
9094
/**
9195
* Allows to manually set the default Swap token when clicking on the Swap CTA from
9296
* native token page. If unset, `getNativeAssetForChainId` of bridge-controller is used.
@@ -196,25 +200,6 @@ const MoreButtonsGroup = ({
196200
);
197201
};
198202

199-
const TabOpenedToast = ({ onClose }: { onClose: () => void }) => {
200-
const t = useContext(I18nContext);
201-
202-
return (
203-
<ToastContainer>
204-
<Toast
205-
startAdornment={
206-
<Icon name={IconName.Export} color={IconColor.IconDefault} />
207-
}
208-
text={t('buyTabOpenedToastText')}
209-
description={t('buyTabOpenedToastDescription')}
210-
onClose={onClose}
211-
autoHideTime={3000}
212-
onAutoHideToast={onClose}
213-
/>
214-
</ToastContainer>
215-
);
216-
};
217-
218203
type CoinButtonsProps = {
219204
account: InternalAccount;
220205
chainId: `0x${string}` | CaipChainId | number;
@@ -246,7 +231,6 @@ const CoinButtons = ({
246231

247232
const { trackEvent, createEventBuilder } = useAnalytics();
248233
const [showReceiveModal, setShowReceiveModal] = useState(false);
249-
const [showTabOpenedToast, setShowTabOpenedToast] = useState(false);
250234

251235
const { address: selectedAddress } = account;
252236
const navigate = useNavigate();
@@ -430,7 +414,13 @@ const CoinButtons = ({
430414
// flow enabled, goToBuy navigates in-app, so the "tab opened" toast would
431415
// be misleading.
432416
if (!isRampsEnabled) {
433-
setShowTabOpenedToast(true);
417+
showSuccessToast({
418+
dataTestId: BUY_TAB_OPENED_TOAST_ID,
419+
title: t('buyTabOpenedToastText'),
420+
description: t('buyTabOpenedToastDescription'),
421+
id: BUY_TAB_OPENED_TOAST_ID,
422+
duration: BUY_TAB_OPENED_TOAST_DURATION,
423+
});
434424
}
435425
trackEvent(
436426
createEventBuilder(MetaMetricsEventName.NavBuyButtonClicked)
@@ -623,10 +613,6 @@ const CoinButtons = ({
623613
},
624614
]}
625615
/>
626-
627-
{showTabOpenedToast && (
628-
<TabOpenedToast onClose={() => setShowTabOpenedToast(false)} />
629-
)}
630616
</Box>
631617
);
632618
};

0 commit comments

Comments
 (0)