This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 219
Add types to Checkout State Provider, and introduce Context Module Functions #3983
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mikejolley
requested review from
ralucaStan
and removed request for
a team and
ralucaStan
March 19, 2021 23:28
Size Change: -284 B (0%) Total Size: 1.16 MB
ℹ️ View Unchanged
|
mikejolley
commented
Mar 22, 2021
// Checkout state provider dispatch function. | ||
dispatch: React.Dispatch< ActionType >; | ||
// Submits the checkout and begins processing. | ||
onSubmit: () => void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've left this in place because it's exposed to Payment Methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potentially, the usePaymentMethodIntegrations
hook could just pull in the dispatch functions and expose them though right?
mikejolley
force-pushed
the
refactor/checkout-state-provider
branch
from
March 22, 2021 17:58
94beca1
to
c6c5463
Compare
mikejolley
changed the title
In progress - Refactor checkout state provider
Add types to Checkout State Provider, and introduce Context Module Functions
Mar 22, 2021
mikejolley
added
status: needs review
type: refactor
The issue/PR is related to refactoring.
block: checkout
Issues related to the checkout block.
labels
Mar 22, 2021
I am extracting the TS changes to a new PR. |
This was referenced May 12, 2021
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
block: checkout
Issues related to the checkout block.
type: refactor
The issue/PR is related to refactoring.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements Typescript in the Checkout State Provider. Doing this revealed a bunch of typos and bugs!
As well as this, I added some shared helpers to base-utils to help with Typescript support (isObject, objectHasProp, isNull).
Finally, inspired by epic react I added some new functions exported from the context provider which take
dispatch
as a parameter and do something. These were previously exported by the context provider, but with this method we only need to export the dispatcher which means the functions can be tree-shaken.submitCheckout
resetCheckout
setRedirectUrl
setHasError
incrementCalculating
decrementCalculating
setCustomerId
setOrderId
setOrderNotes
setShouldCreateAccount
setAfterProcessing
So example usage would be:
To test:
Smoke test the checkout process, including making payment. Checkout state provider is only used during checkout.