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
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new hooks related to payment methods and checkout and remove obso…
…lete. (#1929) * add various hooks and improve hooks folder structure - Also restructures hooks directory to make things a bit more organized - Add useStoreOrder placeholder (followed up in future pull) - Add useBillingData hook. * implement usePaymentMethodInterface hook in payment method components * remove obsolete hooks and implement new checkout context hooks - add useCheckoutSubmit which exposes checkout submit button interface - add useCheckoutRedirectUrl which exposes checkout redirect url interface * add alias for `@woocommerce/base-utils` to jest config * use consistent variable names for payment method id
- Loading branch information
Showing
29 changed files
with
484 additions
and
261 deletions.
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.