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 new hooks related to payment methods and checkout and remove obsolete. #1929
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
773a45b
add various hooks and improve hooks folder structure
nerrad 0f9fbdb
implement usePaymentMethodInterface hook in payment method components
nerrad 8a11c3e
remove obsolete hooks and implement new checkout context hooks
nerrad b842292
add alias for `@woocommerce/base-utils` to jest config
nerrad ff5de13
use consistent variable names for payment method id
nerrad File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './use-store-cart'; | ||
export * from './use-store-cart-coupons'; | ||
export * from './use-store-cart-item-quantity'; |
File renamed without changes.
File renamed without changes.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
export { default as useCheckoutEvents } from './use-checkout-events'; | ||
export { default as useCheckoutNotices } from './use-checkout-notices'; | ||
export { default as useCheckoutRedirectUrls } from './use-checkout-redirect-urls'; | ||
export { default as useCheckoutData } from './use-checkout-data'; | ||
export * from './use-checkout-redirect-url'; | ||
export * from './use-checkout-submit'; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
assets/js/base/hooks/checkout/use-checkout-place-order-label.js
This file was deleted.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
assets/js/base/hooks/checkout/use-checkout-redirect-url.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { useCheckoutContext } from '@woocommerce/base-context'; | ||
|
||
/** | ||
* Returns redirect url interface from checkout context. | ||
*/ | ||
export const useCheckoutRedirectUrl = () => { | ||
const { redirectUrl, dispatchActions } = useCheckoutContext(); | ||
|
||
return { | ||
redirectUrl, | ||
setRedirectUrl: dispatchActions.setRedirectUrl, | ||
}; | ||
}; |
22 changes: 0 additions & 22 deletions
22
assets/js/base/hooks/checkout/use-checkout-redirect-urls.js
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { useCheckoutContext } from '@woocommerce/base-context'; | ||
|
||
/** | ||
* Returns the submitLabel and onSubmit interface from the checkout context | ||
*/ | ||
export const useCheckoutSubmit = () => { | ||
const { submitLabel, onSubmit } = useCheckoutContext(); | ||
return { submitLabel, onSubmit }; | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,13 @@ | ||
export * from './use-query-state'; | ||
export * from './use-shallow-equal'; | ||
export * from './use-store-cart'; | ||
export * from './use-store-cart-coupons'; | ||
export * from './use-store-cart-item-quantity'; | ||
export * from './use-store-products'; | ||
export * from './use-store-notices'; | ||
export * from './cart'; | ||
export * from './checkout'; | ||
export * from './order'; | ||
export * from './payment-methods'; | ||
export * from './shipping'; | ||
export * from './use-collection'; | ||
export * from './use-collection-header'; | ||
export * from './use-collection-data'; | ||
export * from './use-previous'; | ||
export * from './checkout'; | ||
export * from './payment-methods'; | ||
export * from './use-shipping-rates'; | ||
export * from './use-select-shipping-rate'; | ||
export * from './use-shallow-equal'; | ||
export * from './use-store-products'; | ||
export * from './use-store-notices'; | ||
export * from './use-query-state'; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './use-store-order'; | ||
export * from './use-billing-data'; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { usePaymentMethodDataContext } from '@woocommerce/base-context'; | ||
|
||
/** | ||
* Exposes billing data api interface from the payment method data context. | ||
*/ | ||
export const useBillingData = () => { | ||
const { billingData, setBillingData } = usePaymentMethodDataContext(); | ||
return { | ||
billingData, | ||
setBillingData, | ||
}; | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// @todo finish out this hook which will return a store draft order id and | ||
// order loading (likely from payment data context). | ||
|
||
export const useStoreOrder = () => { | ||
const orderId = 0; | ||
return { | ||
orderId, | ||
isLoading: false, | ||
}; | ||
}; |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export { default as useActivePaymentMethod } from './use-active-payment-method'; | ||
export { default as usePaymentEvents } from './use-payment-events'; | ||
export * from './use-payment-method-interface'; | ||
export * from './use-payment-methods'; |
Oops, something went wrong.
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.
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 seen that payment methods sometimes have a
slug
, other times anid
(and these is used askey
andname
in components). If we can standardise on one name for this id / slug (slug?) that might help simplify this.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.
Good call on this. I looked for places where this was inconsistent and addressed (see ff5de1)