Skip to content

Commit

Permalink
feat: add error banner
Browse files Browse the repository at this point in the history
  • Loading branch information
lucas-barros committed Apr 30, 2024
1 parent b0cb467 commit e6ecc41
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 5 deletions.
1 change: 1 addition & 0 deletions apps/browser-extension-wallet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"@lace/cardano": "0.1.0",
"@lace/common": "0.1.0",
"@lace/core": "0.1.0",
"@lace/icons": "workspace:^",
"@lace/staking": "0.1.0",
"@lace/ui": "^0.1.0",
"@react-rxjs/core": "^0.9.8",
Expand Down
7 changes: 6 additions & 1 deletion apps/browser-extension-wallet/src/hooks/useInitializeTx.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable consistent-return */
import { useEffect, useCallback } from 'react';
import { Wallet } from '@lace/cardano';
import { BuiltTxData, OutputsMap } from '../views/browser-view/features/send-transaction/types';
Expand Down Expand Up @@ -29,7 +30,11 @@ export const coinSelectionErrors = new Map<COIN_SELECTION_ERRORS, TranslationKey

export const getErrorMessage =
(t: UseTranslationResponse<'translation'>['t']) =>
(key: COIN_SELECTION_ERRORS): string => {
(key: COIN_SELECTION_ERRORS): string | undefined => {
if (key === COIN_SELECTION_ERRORS.FULLY_DEPLETED_ERROR) {
return;
}

if (coinSelectionErrors.has(key)) {
return t(coinSelectionErrors.get(key));
}
Expand Down
1 change: 1 addition & 0 deletions apps/browser-extension-wallet/src/lib/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@
"browserView.transaction.send.advancedTransaction": "Advanced transaction",
"browserView.transaction.send.confirmationTitle": "Transaction confirmation",
"browserView.transaction.send.customSubmitApiBannerText": "Custom submit API enabled to send transactions. To disable, go to Settings >> Custom submit API",
"browserView.transaction.send.utxoDepletedBannerText": "Due to the minUTXO requirement for native assets, some ADA in your portfolio cannot be spent.",
"browserView.transaction.send.drawer.addBundle": "Add bundle",
"browserView.transaction.send.drawer.addressBook": "Address book",
"browserView.transaction.send.drawer.addressBookEmpty": "You don't have saved addresses yet",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import React, { useEffect, useMemo, useState } from 'react';
import { Skeleton } from 'antd';
import { useTranslation } from 'react-i18next';
import { Tokens } from '@src/types';
import { PriceResult, useCustomSubmitApi } from '@hooks';
import { COIN_SELECTION_ERRORS, PriceResult, useCustomSubmitApi } from '@hooks';
import { useCurrencyStore } from '@providers';
import { Wallet } from '@lace/cardano';
import { SendTransactionCost } from '@lace/core';
import { Button, useObservable, WarningBanner } from '@lace/common';
import { Banner, Button, useObservable, WarningBanner } from '@lace/common';
import { useWalletStore } from '@src/stores';
import { useMaxAda } from '@hooks/useMaxAda';
import BundleIcon from '../../../../../../assets/icons/bundle-icon.component.svg';
Expand All @@ -16,6 +16,8 @@ import { getReachedMaxAmountList } from '../../helpers';
import { MetadataInput } from './MetadataInput';
import { BundlesList } from './BundlesList';
import { formatAdaAllocation, getNextBundleCoinId } from './util';
import { Text } from '@lace/ui';
import { ReactComponent as WarningIconCircle } from '@lace/icons/dist/WarningIconCircleComponent';
import styles from './Form.module.scss';

export interface Props {
Expand All @@ -42,7 +44,7 @@ export const Form = ({
environmentName
} = useWalletStore();
const balance = useObservable(inMemoryWallet.balance.utxo.total$);
const { builtTxData: { totalMinimumCoins, uiTx } = {} } = useBuiltTxState();
const { builtTxData: { totalMinimumCoins, uiTx, error } = {} } = useBuiltTxState();

const [isBundle, setIsBundle] = useState(false);
const tokensUsed = useSpentBalances();
Expand Down Expand Up @@ -109,6 +111,17 @@ export const Form = ({
{getCustomSubmitApiForNetwork(environmentName).status && (
<WarningBanner message={t('browserView.transaction.send.customSubmitApiBannerText')} />
)}
{error === COIN_SELECTION_ERRORS.FULLY_DEPLETED_ERROR && (
<Banner
withIcon
message={<Text.Button>{t('browserView.transaction.send.utxoDepletedBannerText')}</Text.Button>}
customIcon={
<Text.Label color="warning">
<WarningIconCircle />
</Text.Label>
}
/>
)}
<BundlesList
isPopupView={isPopupView}
coinBalance={coinBalance}
Expand Down
5 changes: 5 additions & 0 deletions packages/icons/raw/warning-icon-circle.component.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions packages/ui/src/design-system/text/text.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export const typography = recipe({
highlight: sx({ color: '$data_blue' }),
success: sx({ color: '$data_green' }),
error: sx({ color: '$data_pink' }),
warning: sx({ color: '$data_orange' }),
},
},
});
Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/design-system/text/text.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ const colors: TypographyVariants['color'][] = [
'error',
'success',
'accent',
'warning',
];

export const Overview = (): JSX.Element => (
Expand Down
3 changes: 2 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10720,6 +10720,7 @@ __metadata:
"@lace/cardano": 0.1.0
"@lace/common": 0.1.0
"@lace/core": 0.1.0
"@lace/icons": "workspace:^"
"@lace/staking": 0.1.0
"@lace/ui": ^0.1.0
"@react-rxjs/core": ^0.9.8
Expand Down Expand Up @@ -10927,7 +10928,7 @@ __metadata:
languageName: unknown
linkType: soft

"@lace/icons@0.1.0, @lace/icons@^0.1.0, @lace/icons@workspace:packages/icons":
"@lace/icons@0.1.0, @lace/icons@^0.1.0, @lace/icons@workspace:^, @lace/icons@workspace:packages/icons":
version: 0.0.0-use.local
resolution: "@lace/icons@workspace:packages/icons"
dependencies:
Expand Down

0 comments on commit e6ecc41

Please sign in to comment.