diff options
author | Sebastian <sebasjm@gmail.com> | 2024-03-05 13:51:52 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2024-03-05 13:59:44 -0300 |
commit | df3c8cdf0644439221fa4a9ea73d4f7a99f93d8e (patch) | |
tree | 3a0276ab74068e9d87fcb04dca733d29f93db94f /packages/demobank-ui | |
parent | f9c45391bed222b4ebbedc376a30e44051d2a649 (diff) |
fix #8572
Diffstat (limited to 'packages/demobank-ui')
-rw-r--r-- | packages/demobank-ui/src/pages/business/CreateCashout.tsx | 45 |
1 files changed, 33 insertions, 12 deletions
diff --git a/packages/demobank-ui/src/pages/business/CreateCashout.tsx b/packages/demobank-ui/src/pages/business/CreateCashout.tsx index 7adacb775..20053b53c 100644 --- a/packages/demobank-ui/src/pages/business/CreateCashout.tsx +++ b/packages/demobank-ui/src/pages/business/CreateCashout.tsx @@ -200,11 +200,15 @@ export function CreateCashout({ useEffect(() => { async function doAsync() { await handleError(async () => { - if (Amounts.isNonZero(inputAmount)) { + const higerThanMin = Amounts.cmp(inputAmount, conversionInfo.cashout_min_amount) === 1 + const notZero = Amounts.isNonZero(inputAmount) + if (notZero && higerThanMin) { const resp = await (form.isDebit ? calculateFromDebit(inputAmount, sellFee) : calculateFromCredit(inputAmount, sellFee)); setCalc(resp); + } else { + setCalc(zeroCalc) } }); } @@ -224,8 +228,8 @@ export function CreateCashout({ ? i18n.str`Invalid` : Amounts.cmp(limit, calc.debit) === -1 ? i18n.str`Balance is not enough` - : Amounts.cmp(calc.credit, sellFee) === -1 - ? i18n.str`Need to be higher due to fees` + : Amounts.cmp(inputAmount, conversionInfo.cashout_min_amount) < 1 + ? i18n.str`Needs to be higher than ${Amounts.stringifyValueWithSpec(Amounts.parseOrThrow(conversionInfo.cashout_min_amount), regional_currency_specification).normal}` : Amounts.isZero(calc.credit) ? i18n.str`The total transfer at destination will be zero` : undefined, @@ -330,6 +334,10 @@ export function CreateCashout({ ? undefined : cashoutAccount.targetPath; + const cashoutLegalName = !cashoutAccount + ? undefined + : cashoutAccount.params["receiver-name"]; + return ( <div> <LocalNotificationBanner notification={notification} /> @@ -374,15 +382,28 @@ export function CreateCashout({ /> </dd> </div> - {cashoutAccountName ? ( - <div class="flex items-center justify-between border-t-2 afu pt-4"> - <dt class="flex items-center text-sm text-gray-600"> - <span> - <i18n.Translate>To account</i18n.Translate> - </span> - </dt> - <dd class="text-sm text-gray-900">{cashoutAccountName}</dd> - </div> + {cashoutAccountName && cashoutLegalName ? ( + <Fragment> + <div class="flex items-center justify-between border-t-2 afu pt-4"> + <dt class="flex items-center text-sm text-gray-600"> + <span> + <i18n.Translate>To account</i18n.Translate> + </span> + </dt> + <dd class="text-sm text-gray-900">{cashoutAccountName}</dd> + </div> + <div class="flex items-center justify-between border-t-2 afu pt-4"> + <dt class="flex items-center text-sm text-gray-600"> + <span> + <i18n.Translate>Legal name</i18n.Translate> + </span> + </dt> + <dd class="text-sm text-gray-900">{cashoutLegalName}</dd> + </div> + <p class="mt-2 text-sm text-gray-500"> + <i18n.Translate>If this name doesn't match the account holders name your transaction may fail.</i18n.Translate> + </p> + </Fragment> ) : ( <div class="flex items-center justify-between border-t-2 afu pt-4"> <Attention type="warning" title={i18n.str`No cashout account`}> |