Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
rustam-cb committed Dec 20, 2024
1 parent af24c30 commit f6f1845
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 27 deletions.
5 changes: 4 additions & 1 deletion src/fund/components/FundCardPaymentMethodSelectRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ export const FundCardPaymentMethodSelectRow = memo(
>
<span className="flex items-center gap-3">
{!hideImage && (
<FundCardPaymentMethodImage paymentMethod={paymentMethod} className='h-4 w-4'/>
<FundCardPaymentMethodImage
paymentMethod={paymentMethod}
className="h-4 w-4"
/>
)}
<span className="flex flex-col items-start">
<span className={cn(text.headline)}>{paymentMethod.name}</span>
Expand Down
5 changes: 4 additions & 1 deletion src/fund/components/FundCardPaymentMethodSelectorToggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ export const FundCardPaymentMethodSelectorToggle = forwardRef(
data-testid="ockFundCardPaymentMethodSelectorToggle"
>
<div className="w-4">
<FundCardPaymentMethodImage paymentMethod={paymentMethod} className='h-4 w-4'/>
<FundCardPaymentMethodImage
paymentMethod={paymentMethod}
className="h-4 w-4"
/>
</div>
<span
className={cn(text.headline, color.foreground, 'flex w-full')}
Expand Down
42 changes: 21 additions & 21 deletions src/fund/components/FundCardProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,27 +46,27 @@ export function FundCardProvider({ children, asset }: FundCardProviderReact) {
const [submitButtonState, setSubmitButtonState] =
useState<FundButtonStateReact>('default');

const fetchExchangeRate = useDebounce(async () => {
setExchangeRateLoading(true);
const quote = await fetchOnrampQuote({
purchaseCurrency: selectedAsset,
paymentCurrency: 'USD',
paymentAmount: '100',
paymentMethod: 'CARD',
country: 'US',
});
setExchangeRateLoading(false);
setExchangeRate(
Number(quote.purchaseAmount.value) / Number(quote.paymentSubtotal.value),
);
}, 1000);
// biome-ignore lint/correctness/useExhaustiveDependencies: One time effect
useEffect(() => {
fetchExchangeRate();
}, []);
const fetchExchangeRate = useDebounce(async () => {
setExchangeRateLoading(true);
const quote = await fetchOnrampQuote({
purchaseCurrency: selectedAsset,
paymentCurrency: 'USD',
paymentAmount: '100',
paymentMethod: 'CARD',
country: 'US',
});

setExchangeRateLoading(false);

setExchangeRate(
Number(quote.purchaseAmount.value) / Number(quote.paymentSubtotal.value),
);
}, 1000);

// biome-ignore lint/correctness/useExhaustiveDependencies: One time effect
useEffect(() => {
fetchExchangeRate();
}, []);

const value = useValue<FundCardContextType>({
selectedAsset,
Expand Down
12 changes: 8 additions & 4 deletions src/fund/components/FundProvider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe('FundCardProvider', () => {
render(
<FundCardProvider asset="BTC">
<TestComponent />
</FundCardProvider>,
</FundCardProvider>,
);
});

Expand All @@ -91,8 +91,12 @@ describe('FundCardProvider', () => {

// Wait for exchange rate to be set
await waitFor(() => {
expect(screen.getByTestId('exchange-rate').textContent).toBe('0.0008333333333333334');
expect(screen.getByTestId('loading-state').textContent).toBe('not-loading');
expect(screen.getByTestId('exchange-rate').textContent).toBe(
'0.0008333333333333334',
);
expect(screen.getByTestId('loading-state').textContent).toBe(
'not-loading',
);
});

// Verify fetch was called with correct parameters
Expand All @@ -101,7 +105,7 @@ describe('FundCardProvider', () => {
expect.objectContaining({
method: 'POST',
body: expect.stringContaining('"purchase_currency":"BTC"'),
})
}),
);
});

Expand Down

0 comments on commit f6f1845

Please sign in to comment.