Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Revert "Revert "Merge branch 'trunk' into experiment/buy-it-again-blo…
Browse files Browse the repository at this point in the history
…ck""

This reverts commit d84447f.
  • Loading branch information
wavvves authored and opr committed Dec 16, 2022
1 parent d84447f commit c69f13d
Show file tree
Hide file tree
Showing 24 changed files with 984 additions and 491 deletions.
39 changes: 14 additions & 25 deletions assets/js/base/context/hooks/cart/use-store-cart-coupons.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/** @typedef { import('@woocommerce/type-defs/hooks').StoreCartCoupon } StoreCartCoupon */

/**
* External dependencies
*/
Expand Down Expand Up @@ -32,32 +30,23 @@ export const useStoreCartCoupons = ( context = '' ): StoreCartCoupon => {
const { setValidationErrors } = useDispatch( VALIDATION_STORE_KEY );

const {
applyCoupon,
removeCoupon,
isApplyingCoupon,
isRemovingCoupon,
}: Pick<
StoreCartCoupon,
| 'applyCoupon'
| 'removeCoupon'
| 'isApplyingCoupon'
| 'isRemovingCoupon'
| 'receiveApplyingCoupon'
> = useSelect(
( select, { dispatch } ) => {
const store = select( storeKey );
const actions = dispatch( storeKey );
}: Pick< StoreCartCoupon, 'isApplyingCoupon' | 'isRemovingCoupon' > =
useSelect(
( select ) => {
const store = select( storeKey );

return {
isApplyingCoupon: store.isApplyingCoupon(),
isRemovingCoupon: store.isRemovingCoupon(),
};
},
[ createErrorNotice, createNotice ]
);

return {
applyCoupon: actions.applyCoupon,
removeCoupon: actions.removeCoupon,
isApplyingCoupon: store.isApplyingCoupon(),
isRemovingCoupon: store.isRemovingCoupon(),
receiveApplyingCoupon: actions.receiveApplyingCoupon,
};
},
[ createErrorNotice, createNotice ]
);
const { applyCoupon, removeCoupon, receiveApplyingCoupon } =
useDispatch( storeKey );

const applyCouponWithNotices = ( couponCode: string ) => {
applyCoupon( couponCode )
Expand Down
2 changes: 1 addition & 1 deletion assets/js/data/cart/action-types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const ACTION_TYPES = {
RECEIVE_CART: 'RECEIVE_CART',
SET_CART_DATA: 'SET_CART_DATA',
RECEIVE_ERROR: 'RECEIVE_ERROR',
REPLACE_ERRORS: 'REPLACE_ERRORS',
APPLYING_COUPON: 'APPLYING_COUPON',
Expand Down
Loading

0 comments on commit c69f13d

Please sign in to comment.