-
Notifications
You must be signed in to change notification settings - Fork 219
Conversation
bb4d7db
to
d44a8b1
Compare
`useEmitResponse` is not a react hook, it just exposes so...`useEmitResponse` is not a react hook, it just exposes some functions as properties of an object. Refactor this to not be a hook, we could simply import those functions where needed
woocommerce-blocks/assets/js/data/checkout/utils.ts Lines 28 to 41 in e1128eb
🚀 This comment was generated by the automations bot based on a
|
Fix this type after we move to validation storeFix this type after we move to validation store
woocommerce-blocks/assets/js/data/checkout/thunks.ts Lines 52 to 63 in e1128eb
🚀 This comment was generated by the automations bot based on a
|
Gutenberg with Thunks was released in WP 6.0.Gutenberg with Thunks was released in WP 6.0. Once 6.1 is released, remove the experimental flag here eslint-disable-next-line @typescript-eslint/ban-ts-comment
woocommerce-blocks/assets/js/data/checkout/index.ts Lines 19 to 31 in e1128eb
🚀 This comment was generated by the automations bot based on a
|
`useEmitResponse` is not a react hook, it just exposes so...`useEmitResponse` is not a react hook, it just exposes some functions as properties of an object. Refactor this to not be a hook, we could simply import those functions where needed
woocommerce-blocks/assets/js/data/checkout/utils.ts Lines 28 to 41 in 6cc5a48
🚀 This comment was generated by the automations bot based on a
|
Size Change: -30.7 kB (-3%) Total Size: 903 kB
ℹ️ View Unchanged
|
`useEmitResponse` is not a react hook, it just exposes so...`useEmitResponse` is not a react hook, it just exposes some functions as properties of an object. Refactor this to not be a hook, we could simply import those functions where needed
woocommerce-blocks/assets/js/data/checkout/utils.ts Lines 24 to 37 in 4dff564
🚀 This comment was generated by the automations bot based on a
|
`useEmitResponse` is not a react hook, it just exposes so...`useEmitResponse` is not a react hook, it just exposes some functions as properties of an object. Refactor this to not be a hook, we could simply import those functions where needed
woocommerce-blocks/assets/js/data/checkout/utils.ts Lines 24 to 37 in 850f395
🚀 This comment was generated by the automations bot based on a
|
`useEmitResponse` is not a react hook, it just exposes so...`useEmitResponse` is not a react hook, it just exposes some functions as properties of an object. Refactor this to not be a hook, we could simply import those functions where needed
woocommerce-blocks/assets/js/data/checkout/utils.ts Lines 24 to 37 in 6b4dd69
🚀 This comment was generated by the automations bot based on a
|
Script Dependencies ReportThere is no changed script dependency between this branch and trunk. This comment was automatically generated by the |
The release ZIP for this PR is accessible via:
|
return state.currentStatus; | ||
}; | ||
|
||
export const getShouldSavePaymentMethod = ( state: PaymentMethodDataState ) => { |
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.
There is another selector above called shouldSavePaymentMethod
that returns the same thing. Let's remove one.
See if we can stop this being dispatched if the currently...See if we can stop this being dispatched if the currently selected method is still available.
woocommerce-blocks/assets/js/data/payment-methods/actions.ts Lines 83 to 94 in c5b173d
🚀 This comment was generated by the automations bot based on a
|
assets/js/blocks/cart-checkout-shared/payment-methods/payment-method-card.js
Outdated
Show resolved
Hide resolved
f6d5513
to
a5940d4
Compare
afeb55a
to
065770b
Compare
While smoke testing this PR, I found and fixed 2 bugs.
This was fixed in this commit, by reseting the rest of the
This was fixed in this commit, by checking if the store is initialised before we check active payment methods. The cart store checks the active payment methods on every change because third party developers can choose to activate/deactivate payment methods based on cart data. |
…yment data store (#6669) * Mock getCartTotals * Change test to use data store instead of context * Move payment method context test to data store selectors * Change description of test suite * Bump commit to trigger tests * Fix path in test * update package lock * Set correct state payment method reducer tests/use correct actions * Get saved payment methods from store not context * Mock stores and update tests to allow switching payment methods * Update tests to get onSubmit from checkoutEventsContext * Remove cartTotalsLoaded check from payment method initialize check * Make PaymentMethods test wait until payments initialized * initialize payment method data store when cart is loaded * Remove unneeded actions and add initializePaymentMethodDataStore * Remove check for cart totals loaded in checkPaymentMethods * Remove updateAvilablePaymentMethods from registry * Remove unneeded mock * Remove unused import * Rename imports to fix eslint errors * Remove unused imports * Remove return false from checkPaymentMethods * Remove unnecessary setPaymentMethodsInitialized call * Add todo comment to track refactoring opportunity * Remove savedpayment methods from payment method context and rename it * Rename payment method data context to payment method events context * Add tests for setDefaultPaymentMethods * Optimize the availablePaymentMethods state data Store only the "name" attribute for now. * Get list of payment methods from the registry instead of the store We are using this hook to get some React elements in the payment method object. So, we are getting the raw data directly from the registry instead of the store. * Fix payment state not loading on the Checkout edit page * Handle checkout edit page case * Fix infinite loop error on C&C Blocks * Include @wordpress/redux-routine in transformIgnorePatterns jest config Co-authored-by: Saad Tarhi <[email protected]>
…est config" This reverts commit 6b13235.
…method-card.js Co-authored-by: Thomas Roberts <[email protected]>
… `wc/store/validation` data store (#7146) * Convert checkout context to data store - part 1 (#6232) * Add checkout data store * wip on checkout data store * CheckoutContext now uses the checkout store * Investigated and removed setting the redirectUrl on the default state * update extension and address hooks to use checkout data store * use checkout data store in checkout-processor and use-checkout-button * trim useCheckoutContext from use-payment-method-interface && use-store-cart-item-quantity * Remove useCheckoutContext from shipping provider * Remove isCalculating from state * Removed useCheckoutContext from lots of places * Remove useCheckoutContext from checkout-payment-block * Remove useCheckoutContext in checkout-shipping-methods-block and checkout-shipping-address-block * add isCart selector and action and update the checkoutstate context * Fixed redirectUrl bug by using thunks * Remove dispatchActions from checkout-state * Change SET_HAS_ERROR action to be neater * Thomas' feedback * Tidy up * Oops, deleted things I shouldn't have * Typescript * Fix types * Fix tests * Remove isCart * Update docs and remove unecessary getRedirectUrl() selector * set correct type for preloadedCheckoutData * Remove duplicate Address type * Fix missing addresses from type-defs index * Update docs/block-client-apis/checkout/checkout-api.md Co-authored-by: Thomas Roberts <[email protected]> * Update docs/block-client-apis/checkout/checkout-api.md Co-authored-by: Thomas Roberts <[email protected]> * Update docs * Update docs/block-client-apis/checkout/checkout-api.md Co-authored-by: Thomas Roberts <[email protected]> * Update docs/block-client-apis/checkout/checkout-api.md Co-authored-by: Thomas Roberts <[email protected]> * Revert feedback changes * REvert feedback formatting * Update docs formatting * Delete empty types.ts file * remove merge conflict from docs * Correct linting in docs Co-authored-by: Thomas Roberts <[email protected]> * Move checkout state code into thunks and rename `CheckoutState` context to `CheckoutEvents` (#6455) * Add checkout data store * wip on checkout data store * CheckoutContext now uses the checkout store * Investigated and removed setting the redirectUrl on the default state * update extension and address hooks to use checkout data store * use checkout data store in checkout-processor and use-checkout-button * trim useCheckoutContext from use-payment-method-interface && use-store-cart-item-quantity * Remove useCheckoutContext from shipping provider * Remove isCalculating from state * Removed useCheckoutContext from lots of places * Remove useCheckoutContext from checkout-payment-block * Remove useCheckoutContext in checkout-shipping-methods-block and checkout-shipping-address-block * add isCart selector and action and update the checkoutstate context * Fixed redirectUrl bug by using thunks * Remove dispatchActions from checkout-state * Change SET_HAS_ERROR action to be neater * Thomas' feedback * Tidy up * Oops, deleted things I shouldn't have * Typescript * Fix types * Fix tests * Remove isCart * Update docs and remove unecessary getRedirectUrl() selector * validate event emitter button * Added thunks in a separate file * Call thunks from checkout-state * Checkout logic tested and working * Remove dependency injection as much as poss, tidy up and fix some TS errors * Fix types in thunks.ts * Fixed some ts errors * WIP * Fixed bug * Shift side effects from checkout-state to checkout-processor * Revert "Shift side effects from checkout-state to checkout-processor" This reverts commit 059533d. * Rename CheckoutState to CheckoutEvents * Move status check outside the thunk * remove duplicate EVENTS constant * remove temp buttons * Remove console logs * Augment @wordpress/data package with our new store types * Add correct type for CheckoutAction * Remove createErrorNotice arg from runCheckoutAfterProcessingWithErrorObservers * Remove createErrorNotice from emit event types * Use type keyword when importing types * Add correct types for dispatch and select in thunks * Update wordpress/data types * Replace store creation with new preferred method * Set correct action type on reducer * Remove unnecessary async from thunk * add CHECKOUT_ prefix to checkout events again * export EVENTS with eveything else in checkout0-events/event-emit * Remove duplicate SelectFromMap and TailParameters * Updated type for paymentStatus * TODO remove wp/data experimental thunks * Remove `setCustomerId` from events and `processCheckoutResponseHeaders` (#6586) * Prevent passing dispatch, instead get actions direct from store * Get setCustomerId from the store instead of passing it to processCheckoutResponseHeaders * Revert "Prevent passing dispatch, instead get actions direct from store" This reverts commit 4479a2e. * Auto stash before revert of "Prevent passing dispatch, instead get actions direct from store" * Remove duplicate dispatch * Fix unit tests Co-authored-by: Thomas Roberts <[email protected]> Co-authored-by: Thomas Roberts <[email protected]> * Refactor selectors to not return functions anymore This is a poor DevEx and naming did not reflect what the selector was returning. * Update combobox to be more explicit when selecting validation error * Update useValidation to use the new getValidationError selector * Include @woocommerce/base-hooks in tsconfig * Update ValidationInputError to use new selector * Update ValidatedTextInput to use new selectors * Prevent reference errors when getting validation errors in ComboBox * Defend against case where message prop of error object is undefined * Fix totals/coupon to use new validation selector * Use validation data store in CheckoutTerms block * Update AddressForm to use new validation selector * Update AttributeSelectControl to use new validation selector * Fix syntax error in ValidatedTextInput * Fix multiple import error from rebase * Fix lint issue in useStoreCartItemQantity * Fix tests to reflect new selector API * Remove unused validation prop from CheckoutTermsBlock * Change CheckoutTermsBlock unit tests to use validation data store * Fix JSDOC syntax * fix merge conflict in checkout-api.md Co-authored-by: Alex Florisca <[email protected]> Co-authored-by: Niels Lange <[email protected]>
6446933
to
f761e76
Compare
4d586f0
to
9703a33
Compare
This is a feature PR that contains multiple PRs related to the data store migration project. The goal is to replace some of the contexts with data stores, in order to make the data easier to access (not restricted to the context where it's defined)
Fixes #7158
PRs to be merged into this PR:
CheckoutState
context toCheckoutEvents
#6455Issues to be solved before this PR is merged:
Other things to consider before this PR is merged:
This is a issue tracker of things that are related to this PR, but that can wait until we merge this to trunk
#6625
Other Checks
Testing
Automated Tests
This PR includes some automated tests for the reducers of the new data stores
Manual Testing
The full instructions for testing this PR can be found here. At a minimum, we will need to smoke test by trying the different stripe failure modes
WooCommerce Visibility
Changelog