Skip to content

[READY] Disable submit button when the quote is outdated#613

Merged
ebma merged 5 commits into
stagingfrom
593-update-quote-if-input-amount-changed
May 2, 2025
Merged

[READY] Disable submit button when the quote is outdated#613
ebma merged 5 commits into
stagingfrom
593-update-quote-if-input-amount-changed

Conversation

@Sharqiewicz
Copy link
Copy Markdown
Member

@Sharqiewicz Sharqiewicz commented May 2, 2025

  • Disable the submit button when the quote is fetching
  • Add animation to output when the quote is fetching

@Sharqiewicz Sharqiewicz linked an issue May 2, 2025 that may be closed by this pull request
@netlify
Copy link
Copy Markdown

netlify Bot commented May 2, 2025

Deploy Preview for pendulum-pay ready!

Name Link
🔨 Latest commit f38ff31
🔍 Latest deploy log https://app.netlify.com/sites/pendulum-pay/deploys/6814d7ec658b02000892bc92
😎 Deploy Preview https://deploy-preview-613--pendulum-pay.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@Sharqiewicz Sharqiewicz changed the title Disable submit button when the quote is outdated [READY] Disable submit button when the quote is outdated May 2, 2025
@Sharqiewicz Sharqiewicz requested review from a team and Copilot May 2, 2025 11:11
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request disables the submit button when the quote is outdated and adds a loading animation to indicate that the quote is being fetched. Key changes include:

  • Adding quote and quoteLoading hooks into RampSubmitButtons and ramp components.
  • Incorporating isQuoteOutdated logic to update button disabled and pending states.
  • Enabling a loading indicator in AssetNumericInput when the quote is being fetched.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

File Description
frontend/src/components/RampSubmitButtons/index.tsx Introduces quote comparison logic using Big number equality to determine when the quote is outdated.
frontend/src/components/Ramp/Onramp/index.tsx Adds the quoteLoading state to the props and updates dependencies in memoized selections.
frontend/src/components/Ramp/Offramp/index.tsx Adds the quoteLoading state and updates the dependency array to support the new loading behavior.
frontend/src/components/AssetNumericInput/index.tsx Adds a new loading prop to display a loading indicator instead of the NumericInput when needed.

@@ -55,8 +61,9 @@ export const RampSubmitButtons: FC<RampSubmitButtonsProps> = ({ toAmount }) => {
return t('components.swapSubmitButton.confirm');
};

Copy link

Copilot AI May 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a comment to explain the rationale behind using Big number equality for comparing quote input amounts with the current input, which would improve code clarity for future maintainers.

Suggested change
// Use Big.js for equality comparison to ensure precise comparison of arbitrary-precision decimal numbers.

Copilot uses AI. Check for mistakes.
/>
),
[toToken, form, toAmount, openTokenSelectModal],
[toToken.networkAssetIcon, toToken.assetSymbol, form, quoteLoading, toAmount, openTokenSelectModal],
Copy link

Copilot AI May 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verify that breaking the 'toToken' object into specific properties for the dependency array aligns with the intended re-render behavior; if 'toToken' might update in ways that affect this memoization, consider including those properties or the entire object as needed.

Suggested change
[toToken.networkAssetIcon, toToken.assetSymbol, form, quoteLoading, toAmount, openTokenSelectModal],
[toToken, form, quoteLoading, toAmount, openTokenSelectModal],

Copilot uses AI. Check for mistakes.
/>
),
[toToken.fiat.assetIcon, toToken.fiat.symbol, form, toAmount, openTokenSelectModal],
[toToken.fiat.assetIcon, toToken.fiat.symbol, quoteLoading, form, toAmount, openTokenSelectModal],
Copy link

Copilot AI May 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double-check that the dependency array correctly reflects all necessary changes; explicitly listing properties like fiat.assetIcon and fiat.symbol should be intentional to avoid unwanted re-renders if related properties of 'toToken.fiat' change.

Suggested change
[toToken.fiat.assetIcon, toToken.fiat.symbol, quoteLoading, form, toAmount, openTokenSelectModal],
[toToken.fiat, quoteLoading, form, toAmount, openTokenSelectModal],

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

@ebma ebma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 👍

@ebma ebma merged commit 48e0cf7 into staging May 2, 2025
4 of 5 checks passed
@ebma ebma deleted the 593-update-quote-if-input-amount-changed branch May 2, 2025 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update quote if input amount changed

3 participants