From 3348d62b84daab874b3ddeb0b72ec8daf4c9b1ce Mon Sep 17 00:00:00 2001 From: blushi Date: Mon, 23 Sep 2024 17:57:08 +0200 Subject: [PATCH] test: fix CreditsAmount test --- .../molecules/CreditsAmount/CreditsAmount.stories.tsx | 2 ++ .../molecules/CreditsAmount/CreditsAmount.test.tsx | 1 + .../components/molecules/CreditsAmount/CreditsAmount.tsx | 8 ++------ .../molecules/CreditsAmount/CreditsAmount.types.tsx | 2 +- .../organisms/ChooseCreditsForm/ChooseCreditsForm.tsx | 1 + 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/web-marketplace/src/components/molecules/CreditsAmount/CreditsAmount.stories.tsx b/web-marketplace/src/components/molecules/CreditsAmount/CreditsAmount.stories.tsx index 740c51b184..75002d11f9 100644 --- a/web-marketplace/src/components/molecules/CreditsAmount/CreditsAmount.stories.tsx +++ b/web-marketplace/src/components/molecules/CreditsAmount/CreditsAmount.stories.tsx @@ -30,6 +30,7 @@ const CreditsWithForm = (args: any) => { args.paymentOption === PAYMENT_OPTIONS.CARD ? { askDenom: CURRENCIES.usd, askBaseDenom: CURRENCIES.usd } : defaultCryptoCurrency; + const [currency] = useState(initCurrency); const [spendingCap, setSpendingCap] = useState(0); const [creditsAvailable, setCreditsAvailable] = useState(0); @@ -52,6 +53,7 @@ const CreditsWithForm = (args: any) => {
{ const formDefaultValues = { paymentOption: PAYMENT_OPTIONS.CARD, + currency: { askDenom: CURRENCIES.usd, askBaseDenom: CURRENCIES.usd }, spendingCap: 3185, setSpendingCap: () => {}, creditsAvailable: 1125, diff --git a/web-marketplace/src/components/molecules/CreditsAmount/CreditsAmount.tsx b/web-marketplace/src/components/molecules/CreditsAmount/CreditsAmount.tsx index bf2102c85c..a09a68ed05 100644 --- a/web-marketplace/src/components/molecules/CreditsAmount/CreditsAmount.tsx +++ b/web-marketplace/src/components/molecules/CreditsAmount/CreditsAmount.tsx @@ -28,6 +28,7 @@ import { CreditsInput } from './CreditsInput'; import { CurrencyInput } from './CurrencyInput'; export const CreditsAmount = ({ + currency, paymentOption, creditsAvailable, setCreditsAvailable, @@ -41,12 +42,7 @@ export const CreditsAmount = ({ creditTypePrecision, }: CreditsAmountProps) => { const [maxCreditsSelected, setMaxCreditsSelected] = useState(false); - const { setValue, trigger, control } = - useFormContext(); - const currency = useWatch({ - control, - name: CURRENCY, - }); + const { setValue, trigger } = useFormContext(); const card = paymentOption === PAYMENT_OPTIONS.CARD; const orderedSellOrders = useMemo( diff --git a/web-marketplace/src/components/molecules/CreditsAmount/CreditsAmount.types.tsx b/web-marketplace/src/components/molecules/CreditsAmount/CreditsAmount.types.tsx index 2ce9b7aa5c..9854ca04ef 100644 --- a/web-marketplace/src/components/molecules/CreditsAmount/CreditsAmount.types.tsx +++ b/web-marketplace/src/components/molecules/CreditsAmount/CreditsAmount.types.tsx @@ -5,7 +5,6 @@ import { UseStateSetter } from 'web-components/src/types/react/useState'; import { PaymentOptionsType } from 'pages/BuyCredits/BuyCredits.types'; import { UISellOrderInfo } from 'pages/Projects/AllProjects/AllProjects.types'; -import { ChooseCreditsFormSchemaType } from 'components/organisms/ChooseCreditsForm/ChooseCreditsForm.schema'; import { AllowedDenoms } from '../DenomLabel/DenomLabel.utils'; @@ -25,6 +24,7 @@ export interface CreditsAmountProps { cryptoCurrencies: Currency[]; allowedDenoms?: AllowedDenoms; creditTypePrecision?: number | null; + currency: Currency; } export interface CreditsInputProps { diff --git a/web-marketplace/src/components/organisms/ChooseCreditsForm/ChooseCreditsForm.tsx b/web-marketplace/src/components/organisms/ChooseCreditsForm/ChooseCreditsForm.tsx index 3e45415c1c..163455c627 100644 --- a/web-marketplace/src/components/organisms/ChooseCreditsForm/ChooseCreditsForm.tsx +++ b/web-marketplace/src/components/organisms/ChooseCreditsForm/ChooseCreditsForm.tsx @@ -203,6 +203,7 @@ export function ChooseCreditsForm({ cryptoCurrencies={cryptoCurrencies} allowedDenoms={allowedDenoms} creditTypePrecision={creditTypePrecision} + currency={currency} /> )} {paymentOption === PAYMENT_OPTIONS.CRYPTO && (