From 27e158b8d3198694a6fa6beb33a01e20542ced79 Mon Sep 17 00:00:00 2001 From: r41ph Date: Mon, 9 Dec 2024 15:56:09 +0000 Subject: [PATCH] feat: APP-396 two decimal digits for usd amount (#2544) --- .../CreditsAmount/CreditsAmount.utils.tsx | 53 +++++++++++++--- .../molecules/CreditsAmount/CreditsInput.tsx | 33 ++++++++-- .../molecules/CreditsAmount/CurrencyInput.tsx | 61 +++++++++++++++---- .../OrderSummaryCard.Content.tsx | 1 - .../ChooseCreditsForm.constants.tsx | 1 + .../ChooseCreditsForm.schema.tsx | 7 +++ .../ChooseCreditsForm/ChooseCreditsForm.tsx | 6 ++ web-marketplace/src/lib/i18n/locales/en.po | 52 ++++++++-------- web-marketplace/src/lib/i18n/locales/es.po | 55 +++++++++-------- .../src/pages/BuyCredits/BuyCredits.utils.tsx | 4 +- 10 files changed, 193 insertions(+), 80 deletions(-) diff --git a/web-marketplace/src/components/molecules/CreditsAmount/CreditsAmount.utils.tsx b/web-marketplace/src/components/molecules/CreditsAmount/CreditsAmount.utils.tsx index eb49757a69..aab65b8184 100644 --- a/web-marketplace/src/components/molecules/CreditsAmount/CreditsAmount.utils.tsx +++ b/web-marketplace/src/components/molecules/CreditsAmount/CreditsAmount.utils.tsx @@ -29,10 +29,12 @@ export function getSpendingCap( cardSellOrders: Array, ) { return paymentOption === PAYMENT_OPTIONS.CARD - ? cardSellOrders.reduce( - (prev, cur) => prev + Number(cur.quantity) * cur.usdPrice, - 0, - ) + ? cardSellOrders.reduce((prev, cur) => { + return formatCurrencyAmountTwoDecimals( + prev + Number(cur.quantity) * cur.usdPrice, + true, + ); + }, 0) : microToDenom( filteredCryptoSellOrders?.reduce( (prev, cur) => prev + Number(cur.quantity) * Number(cur.askAmount), @@ -53,7 +55,9 @@ export const getCreditsAmount = ({ orderedSellOrders, creditTypePrecision, }: GetCreditsAmountParams) => { - const currentCurrencyAmount = card ? value : denomToMicro(value); + const currentCurrencyAmount = card + ? formatCurrencyAmountTwoDecimals(value, true) + : denomToMicro(value); let currentCreditsAmount = 0; let currencyAmountLeft = currentCurrencyAmount; const sellOrders = []; @@ -65,9 +69,9 @@ export const getCreditsAmount = ({ const orderTotalAmount = quantity * price; if (currencyAmountLeft >= orderTotalAmount) { - currencyAmountLeft = parseFloat( - (currencyAmountLeft - orderTotalAmount).toFixed(6), - ); + currencyAmountLeft = card + ? formatCurrencyAmountTwoDecimals(currencyAmountLeft - orderTotalAmount) + : parseFloat((currencyAmountLeft - orderTotalAmount).toFixed(6)); currentCreditsAmount += quantity; sellOrders.push(formatSellOrder({ order, card, price })); if (currencyAmountLeft === 0) break; @@ -138,7 +142,7 @@ export const getCurrencyAmount = ({ return { [CURRENCY_AMOUNT]: card - ? parseFloat(currentCurrencyAmount.toFixed(6)) + ? formatCurrencyAmountTwoDecimals(currentCurrencyAmount, true) : parseFloat(microToDenom(currentCurrencyAmount).toFixed(6)), sellOrders, }; @@ -171,3 +175,34 @@ export const formatSellOrder = ({ price: card ? parseFloat((price * 100).toFixed(2)) : undefined, // stripe amounts should be in the smallest currency unit (e.g., 100 cents to charge $1.00) }; }; + +/** + * Formats a given value to a currency amount with max two decimals. + * + * @param value - The value to format. Can be a string or a number. + * @param roundUpDecimal - Optional. If true, rounds the value up to the nearest two decimals. Defaults to false. + * @returns The formatted currency amount as a number with two decimals. + * + */ +export const formatCurrencyAmountTwoDecimals = ( + value: string | number, + roundUpDecimal = false, +) => { + const numericValue = typeof value === 'string' ? parseFloat(value) : value; + const stringValue = value.toString(); + const [integerPart, decimalPart] = stringValue.split('.'); + + if (isNaN(numericValue)) { + return 0; + } + + // Round to two decimals, either returning the value with + // the first two decimals only, if any, or rounding them up. + const formattedValue = roundUpDecimal + ? +(Math.ceil(numericValue * 100) / 100).toFixed(2) + : decimalPart?.length > 2 + ? +`${integerPart}.${decimalPart.slice(0, 2)}` + : +`${integerPart}`; + + return formattedValue; +}; diff --git a/web-marketplace/src/components/molecules/CreditsAmount/CreditsInput.tsx b/web-marketplace/src/components/molecules/CreditsAmount/CreditsInput.tsx index c589685182..05a8691604 100644 --- a/web-marketplace/src/components/molecules/CreditsAmount/CreditsInput.tsx +++ b/web-marketplace/src/components/molecules/CreditsAmount/CreditsInput.tsx @@ -1,4 +1,4 @@ -import { ChangeEvent } from 'react'; +import { ChangeEvent, FocusEvent, useCallback } from 'react'; import { useFormContext } from 'react-hook-form'; import { msg, Trans } from '@lingui/macro'; import { useLingui } from '@lingui/react'; @@ -24,17 +24,38 @@ export const CreditsInput = ({ const { onChange } = register(CREDITS_AMOUNT); const onHandleChange = (event: ChangeEvent) => { - // Remove zeros in non decimal values and update the value - const value = event.target.value; - if (!value.includes('.')) setValue(CREDITS_AMOUNT, Number(value)); onChange(event); handleCreditsAmountChange(event); }; + const handleInput = useCallback( + (event: ChangeEvent): void => { + let value = event.target.value; + if (/^0[0-9]/.test(value)) { + value = value.replace(/^0+/, ''); + setValue(CREDITS_AMOUNT, parseFloat(Number(value).toFixed(2)), { + shouldValidate: true, + }); + } + }, + [setValue], + ); + + const handleOnBlur = useCallback( + (event: FocusEvent): void => { + // If the value is empty, set it to 0 + const value = event.target.value; + if (value === '') { + setValue(CREDITS_AMOUNT, 0, { shouldValidate: true }); + } + }, + [setValue], + ); + return (
@@ -45,7 +46,7 @@ export const CurrencyInput = ({ const { data, handleSave, activeStep } = useMultiStep(); const paymentOption = useAtomValue(paymentOptionAtom); - + const card = paymentOption === PAYMENT_OPTIONS.CARD; const { onChange } = register(CURRENCY_AMOUNT); const currency = useWatch({ @@ -55,13 +56,46 @@ export const CurrencyInput = ({ const handleOnChange = useCallback( (event: ChangeEvent) => { - // Remove zeros in non decimal values and update the value - const value = event.target.value; - if (!value.includes('.')) setValue(CURRENCY_AMOUNT, Number(value)); onChange(event); handleCurrencyAmountChange(event); }, - [handleCurrencyAmountChange, onChange, setValue], + [handleCurrencyAmountChange, onChange], + ); + + const handleInput = useCallback( + (event: ChangeEvent): void => { + let value = event.target.value; + const decimalPart = value.split('.')?.[1]; + // Check if the value has a decimal part longer than 2 digits, + // or if the value starts with leading zero/s + if ( + (decimalPart && + decimalPart.length > 2 && + paymentOption === PAYMENT_OPTIONS.CARD) || + /^0[0-9]/.test(value) + ) { + value = value.replace(/^0+/, ''); + setValue( + CURRENCY_AMOUNT, + formatCurrencyAmountTwoDecimals(value, false), + { + shouldValidate: true, + }, + ); + } + }, + [paymentOption, setValue], + ); + + const handleOnBlur = useCallback( + (event: FocusEvent): void => { + // If the value is empty, set it to 0 + const value = event.target.value; + if (value === '') { + setValue(CURRENCY_AMOUNT, 0, { shouldValidate: true }); + } + }, + [setValue], ); const onHandleCurrencyChange = useCallback( @@ -89,7 +123,7 @@ export const CurrencyInput = ({ return (
- {paymentOption === PAYMENT_OPTIONS.CARD && ( + {card && ( $ @@ -97,21 +131,22 @@ export const CurrencyInput = ({ - paymentOption === PAYMENT_OPTIONS.CARD ? theme.spacing(5) : 0, + paddingRight: theme => (card ? theme.spacing(5) : 0), '& input': { overflow: 'hidden', textOverflow: 'ellipsis', @@ -137,7 +172,7 @@ export const CurrencyInput = ({ }, }} endAdornment={ - paymentOption === PAYMENT_OPTIONS.CARD ? ( + card ? ( findDisplayDenom({ diff --git a/web-marketplace/src/components/organisms/ChooseCreditsForm/ChooseCreditsForm.constants.tsx b/web-marketplace/src/components/organisms/ChooseCreditsForm/ChooseCreditsForm.constants.tsx index 383c84e55b..8f38cee65c 100644 --- a/web-marketplace/src/components/organisms/ChooseCreditsForm/ChooseCreditsForm.constants.tsx +++ b/web-marketplace/src/components/organisms/ChooseCreditsForm/ChooseCreditsForm.constants.tsx @@ -1,6 +1,7 @@ import { msg } from '@lingui/macro'; export const MAX_AMOUNT = msg`Amount cannot exceed`; +export const MIN_USD_AMOUNT = msg`Must be at least`; export const MAX_CREDITS = msg`Credits cannot exceed`; export const POSITIVE_NUMBER = msg`Must be positive`; export const NOT_ENOUGH_BALANCE = msg`You don’t have enough`; diff --git a/web-marketplace/src/components/organisms/ChooseCreditsForm/ChooseCreditsForm.schema.tsx b/web-marketplace/src/components/organisms/ChooseCreditsForm/ChooseCreditsForm.schema.tsx index 98a368b1b4..6e5d0b9cb5 100644 --- a/web-marketplace/src/components/organisms/ChooseCreditsForm/ChooseCreditsForm.schema.tsx +++ b/web-marketplace/src/components/organisms/ChooseCreditsForm/ChooseCreditsForm.schema.tsx @@ -13,6 +13,7 @@ import { PAYMENT_OPTIONS } from 'pages/BuyCredits/BuyCredits.constants'; import { MAX_AMOUNT, MAX_CREDITS, + MIN_USD_AMOUNT, NOT_ENOUGH_BALANCE, POSITIVE_NUMBER, } from './ChooseCreditsForm.constants'; @@ -46,6 +47,12 @@ export const createChooseCreditsFormSchema = ({ { message: `${i18n._(NOT_ENOUGH_BALANCE)}`, }, + ) + .refine( + value => paymentOption === PAYMENT_OPTIONS.CRYPTO || value >= 0.5, + { + message: `${i18n._(MIN_USD_AMOUNT)} 0.5`, + }, ), [CREDITS_AMOUNT]: z.coerce .number() diff --git a/web-marketplace/src/components/organisms/ChooseCreditsForm/ChooseCreditsForm.tsx b/web-marketplace/src/components/organisms/ChooseCreditsForm/ChooseCreditsForm.tsx index 62772039a6..421f6fee64 100644 --- a/web-marketplace/src/components/organisms/ChooseCreditsForm/ChooseCreditsForm.tsx +++ b/web-marketplace/src/components/organisms/ChooseCreditsForm/ChooseCreditsForm.tsx @@ -266,6 +266,12 @@ export const ChooseCreditsForm = React.memo( handlePaymentOptions, ]); + useEffect(() => { + if (spendingCap && creditsAvailable) { + form.trigger(); + } + }, [form, form.trigger, creditsAvailable, spendingCap]); + // Advanced settings not enabled for MVP // const [advanceSettingsOpen, setAdvanceSettingsOpen] = useState(false); // const creditVintageOptions = useWatch({ diff --git a/web-marketplace/src/lib/i18n/locales/en.po b/web-marketplace/src/lib/i18n/locales/en.po index 74d2203cde..c16d9bc74a 100644 --- a/web-marketplace/src/lib/i18n/locales/en.po +++ b/web-marketplace/src/lib/i18n/locales/en.po @@ -63,7 +63,7 @@ msgstr "" msgid "{ADDRESS_USED_ERROR} Do you want to merge these accounts?" msgstr "" -#: src/pages/BuyCredits/BuyCredits.utils.tsx:173 +#: src/pages/BuyCredits/BuyCredits.utils.tsx:175 msgid "{creditsAvailable, plural, one {Only {formattedCreditsAvailable} credit available with those paramaters, order quantity changed} other {Only {formattedCreditsAvailable} credits available with those paramaters, order quantity changed}}" msgstr "" @@ -117,7 +117,7 @@ msgstr "" #~ msgid "{years, plural, one {year project duration} other {year project duration}}" #~ msgstr "" -#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:106 +#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:105 #: src/components/organisms/Order/Order.Summary.tsx:85 msgid "# credits" msgstr "" @@ -176,7 +176,7 @@ msgstr "" msgid "+Create project" msgstr "" -#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:156 +#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:155 msgid "<0>{0} ending in {1}" msgstr "" @@ -629,7 +629,7 @@ msgstr "" msgid "Avg Price" msgstr "" -#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:93 +#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:92 msgid "avg price per credit" msgstr "" @@ -799,7 +799,7 @@ msgstr "" msgid "Buy" msgstr "" -#: src/components/organisms/SellOrdersActionsBar/SellOrdersActionsBar.tsx:215 +#: src/components/organisms/SellOrdersActionsBar/SellOrdersActionsBar.tsx:218 #: src/pages/Marketplace/Storefront/Storefront.constants.ts:4 msgid "BUY" msgstr "" @@ -816,7 +816,7 @@ msgstr "" msgid "buy credits" msgstr "" -#: src/components/organisms/SellOrdersActionsBar/SellOrdersActionsBar.tsx:215 +#: src/components/organisms/SellOrdersActionsBar/SellOrdersActionsBar.tsx:218 msgid "BUY CREDITS" msgstr "" @@ -869,7 +869,7 @@ msgstr "" msgid "By default these credits are tradable but you may check “retire all credits upon transfer” below to automatically retire them upon sending." msgstr "" -#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:116 +#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:115 #: src/components/organisms/ConnectWalletFlow/ConnectWalletFlow.constants.ts:12 #: src/components/organisms/LoginButton/LoginButton.constants.ts:9 msgid "cancel" @@ -940,7 +940,7 @@ msgstr "" msgid "change admin" msgstr "" -#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:164 +#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:163 msgid "Change payment card" msgstr "" @@ -1077,7 +1077,7 @@ msgstr "" msgid "Compliance" msgstr "" -#: src/components/templates/ProjectDetails/TerrasosCreditsInfo/TerrasosCredits.utils.tsx:58 +#: src/components/templates/ProjectDetails/TerrasosCreditsInfo/TerrasosCredits.utils.tsx:64 msgid "Compliance Credits" msgstr "" @@ -1374,7 +1374,7 @@ msgstr "" msgid "Credit unit definition" msgstr "" -#: src/components/molecules/CreditsAmount/CreditsInput.tsx:59 +#: src/components/molecules/CreditsAmount/CreditsInput.tsx:82 msgid "credits" msgstr "" @@ -1420,7 +1420,7 @@ msgstr "" msgid "Credits Cancelled" msgstr "" -#: src/components/organisms/ChooseCreditsForm/ChooseCreditsForm.constants.tsx:4 +#: src/components/organisms/ChooseCreditsForm/ChooseCreditsForm.constants.tsx:5 msgid "Credits cannot exceed" msgstr "" @@ -1436,7 +1436,7 @@ msgstr "" msgid "Credits have been issued!" msgstr "" -#: src/components/molecules/CreditsAmount/CreditsInput.tsx:43 +#: src/components/molecules/CreditsAmount/CreditsInput.tsx:64 msgid "Credits Input" msgstr "" @@ -1498,7 +1498,7 @@ msgstr "" msgid "CURRENCY DENOM" msgstr "" -#: src/components/molecules/CreditsAmount/CurrencyInput.tsx:108 +#: src/components/molecules/CreditsAmount/CurrencyInput.tsx:144 msgid "Currency Input" msgstr "" @@ -1739,7 +1739,7 @@ msgstr "" msgid "edit" msgstr "" -#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:114 +#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:113 #: src/components/organisms/Order/Order.MakeAnonymous.tsx:76 #: src/lib/constants/shared.constants.tsx:22 msgid "Edit" @@ -1783,7 +1783,7 @@ msgstr "" msgid "Edit your file" msgstr "" -#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:113 +#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:112 msgid "Editable credits" msgstr "" @@ -2532,7 +2532,11 @@ msgstr "" msgid "Must be a date in the past" msgstr "" -#: src/components/organisms/ChooseCreditsForm/ChooseCreditsForm.constants.tsx:5 +#: src/components/organisms/ChooseCreditsForm/ChooseCreditsForm.constants.tsx:4 +msgid "Must be at least" +msgstr "" + +#: src/components/organisms/ChooseCreditsForm/ChooseCreditsForm.constants.tsx:6 #: src/lib/constants/shared.constants.tsx:82 msgid "Must be positive" msgstr "" @@ -2733,7 +2737,7 @@ msgstr "" msgid "or, log in with email / social" msgstr "" -#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:84 +#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:83 msgid "Order Summary" msgstr "" @@ -2781,7 +2785,7 @@ msgstr "" msgid "partners" msgstr "" -#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:148 +#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:147 msgid "payment" msgstr "" @@ -3080,7 +3084,7 @@ msgstr "" msgid "Program Guide" msgstr "" -#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:87 +#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:86 #: src/components/organisms/CreditBatches/CreditBatches.config.ts:18 #: src/pages/BuyCredits/BuyCredits.utils.tsx:157 #: src/pages/Dashboard/MyEcocredits/hooks/useBasketPutSubmit.tsx:105 @@ -3109,7 +3113,7 @@ msgstr "" msgid "PROJECT" msgstr "" -#: src/components/organisms/ProjectTopSection/ProjectTopSection.tsx:175 +#: src/components/organisms/ProjectTopSection/ProjectTopSection.tsx:176 msgid "Project {onChainProjectId}" msgstr "" @@ -3973,7 +3977,7 @@ msgstr "" msgid "Tebu banner" msgstr "" -#: src/components/templates/ProjectDetails/TerrasosCreditsInfo/TerrasosCredits.utils.tsx:45 +#: src/components/templates/ProjectDetails/TerrasosCreditsInfo/TerrasosCredits.utils.tsx:51 msgid "Tebu Credits" msgstr "" @@ -4290,7 +4294,7 @@ msgstr "" msgid "total credits you have purchased" msgstr "" -#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:131 +#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:130 #: src/components/organisms/Order/Order.Summary.tsx:91 msgid "total price" msgstr "" @@ -4380,7 +4384,7 @@ msgstr "" msgid "Untitled" msgstr "" -#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:115 +#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:114 #: src/components/organisms/Order/Order.MakeAnonymous.tsx:68 msgid "update" msgstr "" @@ -4792,7 +4796,7 @@ msgstr "" msgid "You do not have any tradable credits to sell from this project." msgstr "" -#: src/components/organisms/ChooseCreditsForm/ChooseCreditsForm.constants.tsx:6 +#: src/components/organisms/ChooseCreditsForm/ChooseCreditsForm.constants.tsx:7 msgid "You don’t have enough" msgstr "" diff --git a/web-marketplace/src/lib/i18n/locales/es.po b/web-marketplace/src/lib/i18n/locales/es.po index d62a3ca938..5ba0ae0496 100644 --- a/web-marketplace/src/lib/i18n/locales/es.po +++ b/web-marketplace/src/lib/i18n/locales/es.po @@ -22,9 +22,6 @@ msgstr "" #: src/components/organisms/CreditActivityTable/CreditActivityTable.tsx:65 #: src/components/organisms/Documentation/Documentation.constants.ts:11 #: src/pages/CreditClassDetails/CreditClassDetailsWithContent/CreditClassDetailsWithContent.constants.ts:35 -msgid "" -msgstr "" - #: src/lib/constants/shared.constants.tsx:96 msgid "- see less" msgstr "- ver menos" @@ -69,7 +66,7 @@ msgstr "{0, plural, one {clase de crédito permitida} other {clases de crédito msgid "{ADDRESS_USED_ERROR} Do you want to merge these accounts?" msgstr "{ADDRESS_USED_ERROR} ¿Quieres fusionar estas cuentas?" -#: src/pages/BuyCredits/BuyCredits.utils.tsx:173 +#: src/pages/BuyCredits/BuyCredits.utils.tsx:175 msgid "{creditsAvailable, plural, one {Only {formattedCreditsAvailable} credit available with those paramaters, order quantity changed} other {Only {formattedCreditsAvailable} credits available with those paramaters, order quantity changed}}" msgstr "{créditosDisponibles, plural, one {Solo {formattedCreditsAvailable} créditos disponibles con esos parámetros, se modificó la cantidad del pedido} other {Solo {formattedCreditsAvailable} créditos disponibles con esos parámetros, se modificó la cantidad del pedido}}" @@ -119,7 +116,7 @@ msgstr "{remainingTitleCharacters, plural, one {{remainingTitleCharacters} cará msgid "{years, plural, one {{years} year project duration} other {{years} year project duration}}" msgstr "{years, plural, one {Duración del proyecto: {years} año} other {Duración del proyecto: {years} años}}" -#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:106 +#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:105 #: src/components/organisms/Order/Order.Summary.tsx:85 msgid "# credits" msgstr "# créditos" @@ -178,7 +175,7 @@ msgstr "+Añadir destinatario" msgid "+Create project" msgstr "+Crear proyecto" -#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:156 +#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:155 msgid "<0>{0} ending in {1}" msgstr "<0>{0} terminando en {1}" @@ -627,7 +624,7 @@ msgstr "Disponible" msgid "Avg Price" msgstr "Precio promedio" -#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:93 +#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:92 msgid "avg price per credit" msgstr "precio promedio por crédito" @@ -801,7 +798,7 @@ msgstr "cuentas de grupo de búfer" msgid "Buy" msgstr "Comprar" -#: src/components/organisms/SellOrdersActionsBar/SellOrdersActionsBar.tsx:215 +#: src/components/organisms/SellOrdersActionsBar/SellOrdersActionsBar.tsx:218 #: src/pages/Marketplace/Storefront/Storefront.constants.ts:4 msgid "BUY" msgstr "COMPRAR" @@ -818,7 +815,7 @@ msgstr "Compre créditos de carbono y otros créditos de servicios de sistemas e msgid "buy credits" msgstr "comprar créditos" -#: src/components/organisms/SellOrdersActionsBar/SellOrdersActionsBar.tsx:215 +#: src/components/organisms/SellOrdersActionsBar/SellOrdersActionsBar.tsx:218 msgid "BUY CREDITS" msgstr "COMPRAR CRÉDITOS" @@ -875,7 +872,7 @@ msgstr "Por defecto, se comprará primero el crédito más barato." msgid "By default these credits are tradable but you may check “retire all credits upon transfer” below to automatically retire them upon sending." msgstr "De forma predeterminada, estos créditos son negociables, pero puedes marcar “retirar todos los créditos al transferir” a continuación para retirarlos automáticamente al enviarlos." -#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:116 +#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:115 #: src/components/organisms/ConnectWalletFlow/ConnectWalletFlow.constants.ts:12 #: src/components/organisms/LoginButton/LoginButton.constants.ts:9 msgid "cancel" @@ -946,7 +943,7 @@ msgstr "Cadena" msgid "change admin" msgstr "cambiar administrador" -#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:164 +#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:163 msgid "Change payment card" msgstr "Cambiar tarjeta de pago" @@ -1087,7 +1084,7 @@ msgstr "Completo" msgid "Compliance" msgstr "Cumplimiento" -#: src/components/templates/ProjectDetails/TerrasosCreditsInfo/TerrasosCredits.utils.tsx:58 +#: src/components/templates/ProjectDetails/TerrasosCreditsInfo/TerrasosCredits.utils.tsx:64 msgid "Compliance Credits" msgstr "Créditos de cumplimiento" @@ -1392,7 +1389,7 @@ msgstr "Tipo de crédito 2" msgid "Credit unit definition" msgstr "Definición de unidad de crédito" -#: src/components/molecules/CreditsAmount/CreditsInput.tsx:59 +#: src/components/molecules/CreditsAmount/CreditsInput.tsx:82 msgid "credits" msgstr "créditos" @@ -1438,7 +1435,7 @@ msgstr "Lotes de créditos" msgid "Credits Cancelled" msgstr "Créditos cancelados" -#: src/components/organisms/ChooseCreditsForm/ChooseCreditsForm.constants.tsx:4 +#: src/components/organisms/ChooseCreditsForm/ChooseCreditsForm.constants.tsx:5 msgid "Credits cannot exceed" msgstr "Los créditos no pueden exceder" @@ -1454,7 +1451,7 @@ msgstr "Créditos por" msgid "Credits have been issued!" msgstr "¡Se han emitido los créditos!" -#: src/components/molecules/CreditsAmount/CreditsInput.tsx:43 +#: src/components/molecules/CreditsAmount/CreditsInput.tsx:64 msgid "Credits Input" msgstr "Entrada de créditos" @@ -1516,7 +1513,7 @@ msgstr "Opciones de compra de criptomonedas" msgid "CURRENCY DENOM" msgstr "DENOMINACIÓN MONEDA" -#: src/components/molecules/CreditsAmount/CurrencyInput.tsx:108 +#: src/components/molecules/CreditsAmount/CurrencyInput.tsx:144 msgid "Currency Input" msgstr "Entrada de moneda" @@ -1757,7 +1754,7 @@ msgstr "Ecosistemas donde la información sobre los niveles de degradación ambi msgid "edit" msgstr "editar" -#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:114 +#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:113 #: src/components/organisms/Order/Order.MakeAnonymous.tsx:76 #: src/lib/constants/shared.constants.tsx:22 msgid "Edit" @@ -1801,7 +1798,7 @@ msgstr "Editar página del proyecto" msgid "Edit your file" msgstr "Editar tu archivo" -#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:113 +#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:112 msgid "Editable credits" msgstr "Créditos editables" @@ -2554,11 +2551,15 @@ msgstr "Error de MsgCreateProject" msgid "Must be a date in the past" msgstr "Debe ser una fecha en el pasado" +#: src/components/organisms/ChooseCreditsForm/ChooseCreditsForm.constants.tsx:4 +msgid "Must be at least" +msgstr "Debe ser al menos" + #: src/components/organisms/BuyCreditsModal/BuyCreditsModal.utils.tsx:248 #~ msgid "Must be less than or equal to the max credit(s) available ({creditAvailable})." #~ msgstr "Debe ser menor o igual al máximo de créditos disponibles ({creditAvailable})." -#: src/components/organisms/ChooseCreditsForm/ChooseCreditsForm.constants.tsx:5 +#: src/components/organisms/ChooseCreditsForm/ChooseCreditsForm.constants.tsx:6 #: src/lib/constants/shared.constants.tsx:82 msgid "Must be positive" msgstr "Debe ser positivo" @@ -2759,7 +2760,7 @@ msgstr "Oportunidades" msgid "or, log in with email / social" msgstr "o inicie sesión con correo electrónico / redes sociales" -#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:84 +#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:83 msgid "Order Summary" msgstr "Resumen del pedido" @@ -2807,7 +2808,7 @@ msgstr "Pacífico" msgid "partners" msgstr "fogonadura" -#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:148 +#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:147 msgid "payment" msgstr "pago" @@ -3110,7 +3111,7 @@ msgstr "programa" msgid "Program Guide" msgstr "Guía del programa" -#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:87 +#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:86 #: src/components/organisms/CreditBatches/CreditBatches.config.ts:18 #: src/pages/BuyCredits/BuyCredits.utils.tsx:157 #: src/pages/Dashboard/MyEcocredits/hooks/useBasketPutSubmit.tsx:105 @@ -3139,7 +3140,7 @@ msgstr "Proyecto" msgid "PROJECT" msgstr "PROYECTO" -#: src/components/organisms/ProjectTopSection/ProjectTopSection.tsx:175 +#: src/components/organisms/ProjectTopSection/ProjectTopSection.tsx:176 msgid "Project {onChainProjectId}" msgstr "Proyecto {onChainProjectId}" @@ -4011,7 +4012,7 @@ msgstr "Insignia de bastón" msgid "Tebu banner" msgstr "Bandera Tebu de azúcar." -#: src/components/templates/ProjectDetails/TerrasosCreditsInfo/TerrasosCredits.utils.tsx:45 +#: src/components/templates/ProjectDetails/TerrasosCreditsInfo/TerrasosCredits.utils.tsx:51 msgid "Tebu Credits" msgstr "Créditos Tebu" @@ -4347,7 +4348,7 @@ msgstr "Total de créditos emitidos" msgid "total credits you have purchased" msgstr "total de créditos que has comprado" -#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:131 +#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:130 #: src/components/organisms/Order/Order.Summary.tsx:91 msgid "total price" msgstr "Precio total" @@ -4441,7 +4442,7 @@ msgstr "Proyectos no registrados" msgid "Untitled" msgstr "Intitulado" -#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:115 +#: src/components/molecules/OrderSummaryCard/OrderSummaryCard.Content.tsx:114 #: src/components/organisms/Order/Order.MakeAnonymous.tsx:68 msgid "update" msgstr "actualizar" @@ -4857,7 +4858,7 @@ msgstr "No tienes ninguna ficha de canasta NCT." msgid "You do not have any tradable credits to sell from this project." msgstr "No tienes créditos comercializables para vender de este proyecto." -#: src/components/organisms/ChooseCreditsForm/ChooseCreditsForm.constants.tsx:6 +#: src/components/organisms/ChooseCreditsForm/ChooseCreditsForm.constants.tsx:7 msgid "You don’t have enough" msgstr "No tienes suficiente" diff --git a/web-marketplace/src/pages/BuyCredits/BuyCredits.utils.tsx b/web-marketplace/src/pages/BuyCredits/BuyCredits.utils.tsx index 8852e42ac1..2f2465e01c 100644 --- a/web-marketplace/src/pages/BuyCredits/BuyCredits.utils.tsx +++ b/web-marketplace/src/pages/BuyCredits/BuyCredits.utils.tsx @@ -169,7 +169,9 @@ export const getCardItems = ({ ]; export const getCreditsAvailableBannerText = (creditsAvailable: number) => { - const formattedCreditsAvailable = i18n.number(creditsAvailable); + const formattedCreditsAvailable = i18n.number(creditsAvailable, { + maximumFractionDigits: 6, + }); return plural(creditsAvailable, { one: `Only ${formattedCreditsAvailable} credit available with those paramaters, order quantity changed`, other: `Only ${formattedCreditsAvailable} credits available with those paramaters, order quantity changed`,