Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checkout: Convert useCreateExistingCards to TypeScript #50723

Merged
merged 7 commits into from
Mar 3, 2021

Conversation

sirbrillig
Copy link
Member

@sirbrillig sirbrillig commented Mar 3, 2021

Changes proposed in this Pull Request

Eventually it would be nice to convert all of useCreatePaymentMethods to TypeScript, but it's a lot of code. This takes the first step by moving the hook to its own directory and then converting one of its sub-functions, useCreateExistingCards. That function also happens to be used independently by the payment management pages.

Testing instructions

Two areas are affected by this change: checkout (for saved cards) and the "change payment method" pages (both site-level and account-level, although they use the same component so only one needs to be tested).

To test checkout:

  • Using an account with at least one saved card, add a product to your cart and visit checkout.
  • Verify that you see the saved card shown as an option in the last step.

To test payment method changes:

  • Visit either site-level or account-level payment management, click on a subscription that already has a payment method assigned, and click "Change payment method".
  • Verify that you see the saved cards listed in the form.

@sirbrillig sirbrillig requested a review from a team as a code owner March 3, 2021 17:33
@matticbot
Copy link
Contributor

@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Mar 3, 2021
@sirbrillig sirbrillig self-assigned this Mar 3, 2021
@matticbot
Copy link
Contributor

matticbot commented Mar 3, 2021

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

Sections (~13 bytes added 📈 [gzipped])

name            parsed_size           gzip_size
site-purchases        +44 B  (+0.0%)      +12 B  (+0.0%)
purchases             +44 B  (+0.0%)      +12 B  (+0.0%)
checkout              +24 B  (+0.0%)       -6 B  (-0.0%)

Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to.

Async-loaded Components (~6 bytes removed 📉 [gzipped])

name                                             parsed_size           gzip_size
async-load-calypso-blocks-editor-checkout-modal        +24 B  (+0.0%)       -6 B  (-0.0%)

React components that are loaded lazily, when a certain part of UI is displayed for the first time.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

@sirbrillig sirbrillig added the [Feature] Checkout The checkout screen and process for purchases made on WordPress.com. label Mar 3, 2021
import { useRef, useEffect } from 'react';

// See https://usehooks.com/useMemoCompare/
export default function useMemoCompare< A, B >(
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems general purpose enough to warrant being put in a less specific place, but I'm not sure where that would be.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, same. There's a few things in this directory and lib that fall into a general utility category but I figure we can always move them later.

@nbloomf
Copy link
Contributor

nbloomf commented Mar 3, 2021

Looks good and works as expected.

@nbloomf nbloomf added [Status] Ready to Merge and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Mar 3, 2021
@sirbrillig
Copy link
Member Author

sirbrillig commented Mar 3, 2021

The only relevant failing e2e test seems to be that the G Suite upgrade card (see #48516) is redirecting back to the domains page when clicking "Skip for now". This could be an actual bug, but I don't think it's related to this PR so I'm going to research it separately. I'm adding a notice to that redirect in #50738 to help track it down.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Estimate] 1 [Feature] Checkout The checkout screen and process for purchases made on WordPress.com.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants