@daffodil/cart 0.64.2 → 0.66.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/driver/in-memory/backend/cart/cart.service.d.ts +3 -1
- package/driver/in-memory/backend/cart-items/cart-items.service.d.ts +3 -1
- package/driver/in-memory/backend/cart-shipping-information/cart-shipping-information.service.d.ts +3 -1
- package/driver/in-memory/helpers/compute-cart-item-prices.d.ts +3 -0
- package/driver/in-memory/helpers/compute-cart-totals.d.ts +3 -0
- package/driver/magento/models/responses/cart.d.ts +1 -1
- package/esm2020/driver/in-memory/backend/cart/cart.service.mjs +9 -5
- package/esm2020/driver/in-memory/backend/cart-items/cart-items.service.mjs +21 -16
- package/esm2020/driver/in-memory/backend/cart-shipping-information/cart-shipping-information.service.mjs +10 -6
- package/esm2020/driver/in-memory/helpers/compute-cart-item-prices.mjs +7 -0
- package/esm2020/driver/in-memory/helpers/compute-cart-totals.mjs +46 -0
- package/esm2020/driver/magento/models/responses/cart.mjs +1 -1
- package/esm2020/driver/magento/transforms/outputs/cart-totals-transformer.mjs +23 -18
- package/esm2020/injection-tokens/public_api.mjs +1 -2
- package/esm2020/models/cart-total.mjs +1 -1
- package/esm2020/models/cart.mjs +1 -1
- package/esm2020/state/actions/cart-address.actions.mjs +1 -1
- package/esm2020/state/actions/cart-billing-address.actions.mjs +1 -1
- package/esm2020/state/actions/cart-coupon.actions.mjs +1 -1
- package/esm2020/state/actions/cart-item.actions.mjs +1 -1
- package/esm2020/state/actions/cart-order.actions.mjs +1 -1
- package/esm2020/state/actions/cart-payment-methods.actions.mjs +1 -1
- package/esm2020/state/actions/cart-payment.actions.mjs +1 -1
- package/esm2020/state/actions/cart-retrieval.mjs +71 -0
- package/esm2020/state/actions/cart-shipping-address.actions.mjs +1 -1
- package/esm2020/state/actions/cart-shipping-information.actions.mjs +1 -1
- package/esm2020/state/actions/cart-shipping-methods.actions.mjs +1 -1
- package/esm2020/state/actions/cart.actions.mjs +1 -1
- package/esm2020/state/actions/public_api.mjs +2 -1
- package/esm2020/state/cart-retrieval/get-response.mjs +12 -0
- package/esm2020/state/cart-retrieval/public_api.mjs +4 -0
- package/esm2020/state/cart-retrieval/token.mjs +14 -0
- package/esm2020/state/cart-retrieval/type.mjs +2 -0
- package/esm2020/state/cart-state.module.mjs +8 -3
- package/esm2020/state/effects/cart-address.effects.mjs +8 -7
- package/esm2020/state/effects/cart-billing-address.effects.mjs +7 -5
- package/esm2020/state/effects/cart-coupon.effects.mjs +17 -16
- package/esm2020/state/effects/cart-item.effects.mjs +12 -10
- package/esm2020/state/effects/cart-order.effects.mjs +8 -7
- package/esm2020/state/effects/cart-payment-methods.effects.mjs +6 -4
- package/esm2020/state/effects/cart-payment-processor.effects.mjs +7 -6
- package/esm2020/state/effects/cart-payment.effects.mjs +9 -7
- package/esm2020/state/effects/cart-resolver.effects.mjs +20 -15
- package/esm2020/state/effects/cart-shipping-address.effects.mjs +7 -5
- package/esm2020/state/effects/cart-shipping-information.effects.mjs +8 -6
- package/esm2020/state/effects/cart-shipping-methods.effects.mjs +6 -4
- package/esm2020/state/effects/cart.effects.mjs +16 -15
- package/esm2020/state/injection-tokens/error-matcher.token.mjs +8 -0
- package/esm2020/state/injection-tokens/public_api.mjs +2 -1
- package/esm2020/state/models/public_api.mjs +2 -1
- package/esm2020/state/models/stateful-cart.mjs +2 -0
- package/esm2020/state/public_api.mjs +2 -1
- package/esm2020/state/reducers/cart/cart.reducer.mjs +3 -16
- package/esm2020/state/reducers/cart/retrieval-actions.reducer.mjs +21 -0
- package/esm2020/state/reducers/cart-billing-address/cart-billing-address.reducer.mjs +2 -6
- package/esm2020/state/reducers/cart-coupon/cart-coupon.reducer.mjs +2 -6
- package/esm2020/state/reducers/cart-item/cart-item.reducer.mjs +2 -10
- package/esm2020/state/reducers/cart-item-entities/cart-item-entities.reducer.mjs +2 -35
- package/esm2020/state/reducers/cart-item-entities/retrieval-actions.reducer.mjs +20 -0
- package/esm2020/state/reducers/cart-item-entities/set-state.meta-reducer.mjs +46 -0
- package/esm2020/state/reducers/cart-order/cart-order.reducer.mjs +2 -5
- package/esm2020/state/reducers/cart-payment/cart-payment.reducer.mjs +2 -6
- package/esm2020/state/reducers/cart-payment/payment.reducer.mjs +2 -2
- package/esm2020/state/reducers/cart-payment-methods/cart-payment-methods.reducer.mjs +2 -2
- package/esm2020/state/reducers/cart-shipping-address/cart-shipping-address.reducer.mjs +2 -6
- package/esm2020/state/reducers/cart-shipping-information/cart-shipping-information.reducer.mjs +2 -8
- package/esm2020/state/reducers/cart-shipping-methods/cart-shipping-methods.reducer.mjs +2 -2
- package/esm2020/state/reducers/public_api.mjs +3 -1
- package/esm2020/state/reducers/token/config.token.mjs +18 -0
- package/esm2020/state/reducers/token/meta.token.mjs +27 -0
- package/esm2020/state/reducers/token/public_api.mjs +2 -1
- package/esm2020/state/reducers/token/reducers.token.mjs +20 -6
- package/esm2020/state/selectors/cart/cart.selector.mjs +11 -11
- package/esm2020/state/testing/cart-testing.module.mjs +6 -6
- package/esm2020/state/testing/mock-cart-facade.mjs +2 -2
- package/esm2020/state/testing/public_api.mjs +2 -2
- package/esm2020/testing/factories/cart-shipping-information.factory.mjs +25 -0
- package/esm2020/testing/factories/cart-total.factory.mjs +97 -0
- package/esm2020/testing/factories/cart.factory.mjs +14 -50
- package/esm2020/testing/factories/public_api.mjs +3 -1
- package/fesm2015/daffodil-cart-driver-in-memory.mjs +44 -18
- package/fesm2015/daffodil-cart-driver-in-memory.mjs.map +1 -1
- package/fesm2015/daffodil-cart-driver-magento.mjs +22 -17
- package/fesm2015/daffodil-cart-driver-magento.mjs.map +1 -1
- package/fesm2015/daffodil-cart-state-testing.mjs +7 -7
- package/fesm2015/daffodil-cart-state-testing.mjs.map +1 -1
- package/fesm2015/daffodil-cart-state.mjs +326 -141
- package/fesm2015/daffodil-cart-state.mjs.map +1 -1
- package/fesm2015/daffodil-cart-testing.mjs +148 -75
- package/fesm2015/daffodil-cart-testing.mjs.map +1 -1
- package/fesm2015/daffodil-cart.mjs +1 -8
- package/fesm2015/daffodil-cart.mjs.map +1 -1
- package/fesm2020/daffodil-cart-driver-in-memory.mjs +81 -24
- package/fesm2020/daffodil-cart-driver-in-memory.mjs.map +1 -1
- package/fesm2020/daffodil-cart-driver-magento.mjs +22 -17
- package/fesm2020/daffodil-cart-driver-magento.mjs.map +1 -1
- package/fesm2020/daffodil-cart-state-testing.mjs +7 -7
- package/fesm2020/daffodil-cart-state-testing.mjs.map +1 -1
- package/fesm2020/daffodil-cart-state.mjs +330 -178
- package/fesm2020/daffodil-cart-state.mjs.map +1 -1
- package/fesm2020/daffodil-cart-testing.mjs +148 -75
- package/fesm2020/daffodil-cart-testing.mjs.map +1 -1
- package/fesm2020/daffodil-cart.mjs +1 -8
- package/fesm2020/daffodil-cart.mjs.map +1 -1
- package/injection-tokens/public_api.d.ts +0 -1
- package/models/cart-total.d.ts +4 -0
- package/models/cart.d.ts +1 -1
- package/package.json +1 -1
- package/state/actions/cart-address.actions.d.ts +6 -5
- package/state/actions/cart-billing-address.actions.d.ts +9 -8
- package/state/actions/cart-coupon.actions.d.ts +17 -16
- package/state/actions/cart-item.actions.d.ts +18 -17
- package/state/actions/cart-order.actions.d.ts +4 -4
- package/state/actions/cart-payment-methods.actions.d.ts +4 -4
- package/state/actions/cart-payment.actions.d.ts +16 -15
- package/state/actions/cart-retrieval.d.ts +5 -0
- package/state/actions/cart-shipping-address.actions.d.ts +9 -8
- package/state/actions/cart-shipping-information.actions.d.ts +13 -12
- package/state/actions/cart-shipping-methods.actions.d.ts +4 -4
- package/state/actions/cart.actions.d.ts +25 -28
- package/state/actions/public_api.d.ts +1 -0
- package/state/cart-retrieval/get-response.d.ts +8 -0
- package/state/cart-retrieval/public_api.d.ts +3 -0
- package/state/cart-retrieval/token.d.ts +10 -0
- package/state/cart-retrieval/type.d.ts +40 -0
- package/state/effects/cart-address.effects.d.ts +2 -16
- package/state/effects/cart-billing-address.effects.d.ts +3 -17
- package/state/effects/cart-coupon.effects.d.ts +5 -5
- package/state/effects/cart-item.effects.d.ts +7 -49
- package/state/effects/cart-order.effects.d.ts +2 -2
- package/state/effects/cart-payment-methods.effects.d.ts +2 -2
- package/state/effects/cart-payment-processor.effects.d.ts +1 -16
- package/state/effects/cart-payment.effects.d.ts +5 -19
- package/state/effects/cart-shipping-address.effects.d.ts +3 -17
- package/state/effects/cart-shipping-information.effects.d.ts +4 -32
- package/state/effects/cart-shipping-methods.effects.d.ts +2 -2
- package/state/effects/cart.effects.d.ts +5 -19
- package/state/injection-tokens/public_api.d.ts +1 -0
- package/state/models/public_api.d.ts +1 -0
- package/state/models/stateful-cart.d.ts +8 -0
- package/state/public_api.d.ts +1 -0
- package/state/reducers/cart/retrieval-actions.reducer.d.ts +9 -0
- package/state/reducers/cart-item-entities/retrieval-actions.reducer.d.ts +10 -0
- package/state/reducers/cart-item-entities/set-state.meta-reducer.d.ts +11 -0
- package/state/reducers/public_api.d.ts +2 -0
- package/state/reducers/token/config.token.d.ts +10 -0
- package/state/reducers/token/meta.token.d.ts +23 -0
- package/state/reducers/token/public_api.d.ts +1 -0
- package/state/selectors/cart/cart.selector.d.ts +1 -0
- package/state/testing/cart-testing.module.d.ts +4 -4
- package/state/testing/public_api.d.ts +1 -1
- package/testing/factories/cart-shipping-information.factory.d.ts +12 -0
- package/testing/factories/cart-total.factory.d.ts +23 -0
- package/testing/factories/cart.factory.d.ts +9 -8
- package/testing/factories/public_api.d.ts +2 -0
- package/esm2020/injection-tokens/error-matcher.token.mjs +0 -8
- /package/{injection-tokens → state/injection-tokens}/error-matcher.token.d.ts +0 -0
|
@@ -1,21 +1,20 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InjectionToken, Injectable, Inject, PLATFORM_ID, inject, NgModule } from '@angular/core';
|
|
1
3
|
import * as i1$1 from '@ngrx/store';
|
|
2
4
|
import { createFeatureSelector, createSelector, defaultMemoize, select, combineReducers, StoreModule } from '@ngrx/store';
|
|
3
5
|
import * as i2 from '@daffodil/cart';
|
|
4
|
-
import { DaffCartItemInputType, DaffCartTotalTypeEnum,
|
|
6
|
+
import { DaffCartItemInputType, DaffCartTotalTypeEnum, DaffCartResolutionError, DaffCartStorageResolutionError, DaffCartServerSideResolutionError, DaffCartPaymentMethodIdMap } from '@daffodil/cart';
|
|
5
7
|
import { daffComparePersonalAddresses } from '@daffodil/geography';
|
|
6
8
|
import { createEntityAdapter } from '@ngrx/entity';
|
|
7
|
-
import { daffComposeReducers } from '@daffodil/core/state';
|
|
9
|
+
import { daffComposeReducers, daffTransformErrorToStateError, daffIdentityReducer } from '@daffodil/core/state';
|
|
8
10
|
import * as i4 from '@daffodil/cart/driver';
|
|
9
11
|
import { DaffCartDriverErrorCodes, DaffCartAddressDriver, DaffCartBillingAddressDriver, DaffCartCouponDriver, daffCartDriverHandleCartNotFound, DaffCartItemDriver, DaffCartOrderDriver, DaffCartPaymentMethodsDriver, DaffCartPaymentDriver, DaffCartShippingAddressDriver, DaffCartShippingInformationDriver, DaffCartShippingMethodsDriver, DaffCartDriver } from '@daffodil/cart/driver';
|
|
10
|
-
import
|
|
11
|
-
import { InjectionToken, Injectable, Inject, PLATFORM_ID, inject, NgModule } from '@angular/core';
|
|
12
|
-
import { daffAdd, DaffStorageServiceError, DaffInheritableError, DaffServerSideStorageError } from '@daffodil/core';
|
|
12
|
+
import { daffAdd, catchAndArrayifyErrors, DAFF_STORAGE_SERVICE_ERROR_CODE, DaffInheritableError, DAFF_SERVER_STORAGE_SERVICE_ERROR_CODE } from '@daffodil/core';
|
|
13
13
|
import * as i1 from '@ngrx/effects';
|
|
14
14
|
import { createEffect, ofType, EffectsModule } from '@ngrx/effects';
|
|
15
|
-
import { DaffPaymentGenerateTokenFailure, DAFF_PAYMENT_PROCESSOR_COLLECTION, DaffPaymentStateReducerAdapter, daffPaymentInitialState, daffPaymentProvideExtraReducers } from '@daffodil/payment/state';
|
|
15
|
+
import { DaffPaymentGenerateTokenFailure, DAFF_PAYMENT_PROCESSOR_COLLECTION, DAFF_PAYMENT_ERROR_MATCHER, DaffPaymentStateReducerAdapter, daffPaymentInitialState, daffPaymentProvideExtraReducers } from '@daffodil/payment/state';
|
|
16
16
|
import { defer, of, combineLatest, iif, EMPTY } from 'rxjs';
|
|
17
|
-
import { switchMap, map,
|
|
18
|
-
import { DAFF_PAYMENT_ERROR_MATCHER } from '@daffodil/payment';
|
|
17
|
+
import { switchMap, map, concatMap, mergeMap, debounceTime, take, tap } from 'rxjs/operators';
|
|
19
18
|
import { isPlatformBrowser } from '@angular/common';
|
|
20
19
|
|
|
21
20
|
/**
|
|
@@ -1055,6 +1054,95 @@ class DaffCartCouponClearErrors {
|
|
|
1055
1054
|
}
|
|
1056
1055
|
}
|
|
1057
1056
|
|
|
1057
|
+
/**
|
|
1058
|
+
* A list of the Daffodil cart actions that are cart retrieval actions, in injection form.
|
|
1059
|
+
*/
|
|
1060
|
+
const daffCartRetrivalActions = [
|
|
1061
|
+
{
|
|
1062
|
+
type: DaffCartItemActionTypes.CartItemAddSuccessAction,
|
|
1063
|
+
},
|
|
1064
|
+
{
|
|
1065
|
+
type: DaffCartItemActionTypes.CartItemUpdateSuccessAction,
|
|
1066
|
+
},
|
|
1067
|
+
{
|
|
1068
|
+
type: DaffCartItemActionTypes.CartItemDeleteSuccessAction,
|
|
1069
|
+
},
|
|
1070
|
+
{
|
|
1071
|
+
type: DaffCartItemActionTypes.CartItemDeleteOutOfStockSuccessAction,
|
|
1072
|
+
},
|
|
1073
|
+
{
|
|
1074
|
+
type: DaffCartActionTypes.CartLoadSuccessAction,
|
|
1075
|
+
},
|
|
1076
|
+
{
|
|
1077
|
+
type: DaffCartActionTypes.ResolveCartSuccessAction,
|
|
1078
|
+
},
|
|
1079
|
+
{
|
|
1080
|
+
type: DaffCartActionTypes.CartLoadPartialSuccessAction,
|
|
1081
|
+
},
|
|
1082
|
+
{
|
|
1083
|
+
type: DaffCartActionTypes.ResolveCartPartialSuccessAction,
|
|
1084
|
+
},
|
|
1085
|
+
{
|
|
1086
|
+
type: DaffCartActionTypes.CartClearSuccessAction,
|
|
1087
|
+
},
|
|
1088
|
+
{
|
|
1089
|
+
type: DaffCartAddressActionTypes.CartAddressUpdateSuccessAction,
|
|
1090
|
+
},
|
|
1091
|
+
{
|
|
1092
|
+
type: DaffCartBillingAddressActionTypes.CartBillingAddressUpdateSuccessAction,
|
|
1093
|
+
},
|
|
1094
|
+
{
|
|
1095
|
+
type: DaffCartCouponActionTypes.CartCouponApplySuccessAction,
|
|
1096
|
+
},
|
|
1097
|
+
{
|
|
1098
|
+
type: DaffCartCouponActionTypes.CartCouponRemoveSuccessAction,
|
|
1099
|
+
},
|
|
1100
|
+
{
|
|
1101
|
+
type: DaffCartCouponActionTypes.CartCouponRemoveAllSuccessAction,
|
|
1102
|
+
},
|
|
1103
|
+
{
|
|
1104
|
+
type: DaffCartPaymentActionTypes.CartPaymentUpdateSuccessAction,
|
|
1105
|
+
},
|
|
1106
|
+
{
|
|
1107
|
+
type: DaffCartPaymentActionTypes.CartPaymentUpdateWithBillingSuccessAction,
|
|
1108
|
+
},
|
|
1109
|
+
{
|
|
1110
|
+
type: DaffCartShippingAddressActionTypes.CartShippingAddressUpdateSuccessAction,
|
|
1111
|
+
},
|
|
1112
|
+
{
|
|
1113
|
+
type: DaffCartShippingInformationActionTypes.CartShippingInformationUpdateSuccessAction,
|
|
1114
|
+
},
|
|
1115
|
+
{
|
|
1116
|
+
type: DaffCartShippingInformationActionTypes.CartShippingInformationDeleteSuccessAction,
|
|
1117
|
+
},
|
|
1118
|
+
];
|
|
1119
|
+
|
|
1120
|
+
/**
|
|
1121
|
+
* A token to hold {@link DaffCartRetrievalActionInjection}s.
|
|
1122
|
+
*/
|
|
1123
|
+
const DAFF_CART_RETRIEVAL_ACTIONS = new InjectionToken('DAFF_CART_RETRIEVAL_ACTIONS', { factory: () => [] });
|
|
1124
|
+
/**
|
|
1125
|
+
* A provider function for {@link DAFF_CART_RETRIEVAL_ACTIONS}.
|
|
1126
|
+
*/
|
|
1127
|
+
const daffCartProvideRetrievalActions = (...actions) => actions.map((action) => ({
|
|
1128
|
+
provide: DAFF_CART_RETRIEVAL_ACTIONS,
|
|
1129
|
+
useValue: action,
|
|
1130
|
+
multi: true,
|
|
1131
|
+
}));
|
|
1132
|
+
|
|
1133
|
+
/**
|
|
1134
|
+
* Gets the cart from the passed action if it is a recognized retrieval action and applies the transformation if needed.
|
|
1135
|
+
* If the action is not recognized as a retrieval action, returns `null`.
|
|
1136
|
+
*/
|
|
1137
|
+
function daffCartRetrievalGetResponse(action, retrievalActions) {
|
|
1138
|
+
var _a;
|
|
1139
|
+
const actionInjection = retrievalActions.find(({ type }) => type === action.type);
|
|
1140
|
+
if (actionInjection) {
|
|
1141
|
+
return ((_a = actionInjection.transform) === null || _a === void 0 ? void 0 : _a.call(actionInjection, action)) || action.payload;
|
|
1142
|
+
}
|
|
1143
|
+
return null;
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1058
1146
|
/**
|
|
1059
1147
|
* Cart Item Entities Adapter for changing/overwriting entity state.
|
|
1060
1148
|
*/
|
|
@@ -1087,22 +1175,10 @@ function daffCartItemEntitiesReducer(state = daffCartItemEntitiesAdapter().getIn
|
|
|
1087
1175
|
return adapter.setAll(action.payload.map(item => (Object.assign(Object.assign({}, item), { daffState: getDaffState(state.entities[item.id]) || DaffCartItemStateEnum.Default, daffErrors: [] }))), state);
|
|
1088
1176
|
case DaffCartItemActionTypes.CartItemLoadSuccessAction:
|
|
1089
1177
|
return adapter.upsertOne(Object.assign(Object.assign({}, action.payload), { daffState: getDaffState(state.entities[action.payload.id]) || DaffCartItemStateEnum.Default, daffErrors: [] }), state);
|
|
1090
|
-
case DaffCartItemActionTypes.CartItemAddSuccessAction:
|
|
1091
|
-
return adapter.setAll(updateAddedCartItemState(state.entities, action.payload.items), state);
|
|
1092
|
-
case DaffCartItemActionTypes.CartItemUpdateSuccessAction:
|
|
1093
|
-
return adapter.setAll(updateMutatedCartItemState(action.payload.items, state.entities, action.itemId), state);
|
|
1094
1178
|
case DaffCartItemActionTypes.CartItemDeleteFailureAction:
|
|
1095
1179
|
case DaffCartItemActionTypes.CartItemLoadFailureAction:
|
|
1096
1180
|
case DaffCartItemActionTypes.CartItemUpdateFailureAction:
|
|
1097
|
-
return adapter.upsertOne(Object.assign(Object.assign({}, state.entities[action.itemId]), { daffState: DaffCartItemStateEnum.Error, daffErrors: ((_b = (_a = state.entities[action.itemId]) === null || _a === void 0 ? void 0 : _a.daffErrors) === null || _b === void 0 ? void 0 : _b.concat(action.payload)) ||
|
|
1098
|
-
case DaffCartItemActionTypes.CartItemDeleteSuccessAction:
|
|
1099
|
-
case DaffCartItemActionTypes.CartItemDeleteOutOfStockSuccessAction:
|
|
1100
|
-
case DaffCartActionTypes.CartLoadSuccessAction:
|
|
1101
|
-
case DaffCartActionTypes.ResolveCartSuccessAction:
|
|
1102
|
-
case DaffCartActionTypes.CartLoadPartialSuccessAction:
|
|
1103
|
-
case DaffCartActionTypes.ResolveCartPartialSuccessAction:
|
|
1104
|
-
case DaffCartActionTypes.CartClearSuccessAction:
|
|
1105
|
-
return adapter.setAll(action.payload.items.map(item => (Object.assign(Object.assign({}, item), { daffState: getDaffState(state.entities[item.id]) || DaffCartItemStateEnum.Default }))), state);
|
|
1181
|
+
return adapter.upsertOne(Object.assign(Object.assign({}, state.entities[action.itemId]), { daffState: DaffCartItemStateEnum.Error, daffErrors: ((_b = (_a = state.entities[action.itemId]) === null || _a === void 0 ? void 0 : _a.daffErrors) === null || _b === void 0 ? void 0 : _b.concat(action.payload)) || action.payload }), state);
|
|
1106
1182
|
case DaffCartItemActionTypes.CartItemStateResetAction:
|
|
1107
1183
|
return adapter.setAll(Object.keys(state.entities).map(key => (Object.assign(Object.assign({}, state.entities[key]), { daffState: DaffCartItemStateEnum.Default }))), state);
|
|
1108
1184
|
case DaffCartItemActionTypes.CartItemUpdateAction:
|
|
@@ -1117,22 +1193,6 @@ function daffCartItemEntitiesReducer(state = daffCartItemEntitiesAdapter().getIn
|
|
|
1117
1193
|
function getDaffState(item) {
|
|
1118
1194
|
return item === null || item === void 0 ? void 0 : item.daffState;
|
|
1119
1195
|
}
|
|
1120
|
-
function updateAddedCartItemState(oldCartItems, newCartItems) {
|
|
1121
|
-
return newCartItems.map(newItem => {
|
|
1122
|
-
const oldItem = oldCartItems[newItem.id];
|
|
1123
|
-
switch (true) {
|
|
1124
|
-
case !oldItem:
|
|
1125
|
-
return Object.assign(Object.assign({}, newItem), { daffState: DaffCartItemStateEnum.New, daffErrors: [] });
|
|
1126
|
-
case (oldItem === null || oldItem === void 0 ? void 0 : oldItem.qty) !== newItem.qty:
|
|
1127
|
-
return Object.assign(Object.assign({}, newItem), { daffState: DaffCartItemStateEnum.Updated, daffErrors: [] });
|
|
1128
|
-
default:
|
|
1129
|
-
return newItem;
|
|
1130
|
-
}
|
|
1131
|
-
});
|
|
1132
|
-
}
|
|
1133
|
-
function updateMutatedCartItemState(responseItems, stateItems, itemId) {
|
|
1134
|
-
return responseItems.map(item => item.id === itemId ? Object.assign(Object.assign({}, item), { daffState: DaffCartItemStateEnum.Updated, daffErrors: [] }) : Object.assign(Object.assign({}, item), { daffState: getDaffState(stateItems[item.id]) || DaffCartItemStateEnum.Default }));
|
|
1135
|
-
}
|
|
1136
1196
|
|
|
1137
1197
|
const daffCartOrderInitialState = {
|
|
1138
1198
|
cartOrderResult: {
|
|
@@ -1151,10 +1211,7 @@ function daffCartOrderReducer(state = daffCartOrderInitialState, action) {
|
|
|
1151
1211
|
case DaffCartOrderActionTypes.CartPlaceOrderSuccessAction:
|
|
1152
1212
|
return Object.assign(Object.assign({}, state), { errors: [], loading: "Stable" /* DaffState.Complete */, cartOrderResult: action.payload });
|
|
1153
1213
|
case DaffCartOrderActionTypes.CartPlaceOrderFailureAction:
|
|
1154
|
-
return Object.assign(Object.assign({}, state), { loading: "Stable" /* DaffState.Complete */, errors:
|
|
1155
|
-
...state.errors,
|
|
1156
|
-
action.payload,
|
|
1157
|
-
] });
|
|
1214
|
+
return Object.assign(Object.assign({}, state), { loading: "Stable" /* DaffState.Complete */, errors: action.payload });
|
|
1158
1215
|
case DaffCartActionTypes.CartClearSuccessAction:
|
|
1159
1216
|
case DaffCartActionTypes.CartCreateSuccessAction:
|
|
1160
1217
|
case DaffCartActionTypes.AddToCartSuccessAction:
|
|
@@ -1274,20 +1331,19 @@ function cartReducer(state = daffCartReducerInitialState, action) {
|
|
|
1274
1331
|
case DaffCartActionTypes.CartClearSuccessAction:
|
|
1275
1332
|
case DaffCartActionTypes.AddToCartSuccessAction:
|
|
1276
1333
|
case DaffCartActionTypes.ResolveCartSuccessAction:
|
|
1277
|
-
return Object.assign(Object.assign(Object.assign(
|
|
1334
|
+
return Object.assign(Object.assign(Object.assign({}, state), resetErrors$8(state.errors)), setLoading$8(state.loading, "Stable" /* DaffState.Stable */));
|
|
1278
1335
|
case DaffCartActionTypes.CartCreateSuccessAction:
|
|
1279
|
-
return Object.assign(Object.assign(Object.assign(Object.assign({}, state), resetErrors$8(state.errors)), { cart: Object.assign(Object.assign({}, daffCartReducerInitialState.cart), action.payload) }), setLoading$8(state.loading, "Stable" /* DaffState.
|
|
1336
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, state), resetErrors$8(state.errors)), { cart: Object.assign(Object.assign({}, daffCartReducerInitialState.cart), action.payload) }), setLoading$8(state.loading, "Stable" /* DaffState.Stable */));
|
|
1280
1337
|
case DaffCartActionTypes.CartClearFailureAction:
|
|
1281
1338
|
case DaffCartActionTypes.AddToCartFailureAction:
|
|
1282
1339
|
case DaffCartActionTypes.CartCreateFailureAction:
|
|
1283
1340
|
case DaffCartActionTypes.CartStorageFailureAction:
|
|
1284
|
-
return Object.assign(Object.assign(Object.assign({}, state), addError$8(state.errors, action.payload)), setLoading$8(state.loading, "Stable" /* DaffState.Complete */));
|
|
1285
1341
|
case DaffCartActionTypes.CartLoadFailureAction:
|
|
1286
1342
|
case DaffCartActionTypes.ResolveCartFailureAction:
|
|
1287
1343
|
return Object.assign(Object.assign(Object.assign({}, state), addError$8(state.errors, ...action.payload)), setLoading$8(state.loading, "Stable" /* DaffState.Stable */));
|
|
1288
1344
|
case DaffCartActionTypes.ResolveCartPartialSuccessAction:
|
|
1289
1345
|
case DaffCartActionTypes.CartLoadPartialSuccessAction:
|
|
1290
|
-
return Object.assign(Object.assign(Object.assign(
|
|
1346
|
+
return Object.assign(Object.assign(Object.assign({}, state), addError$8(state.errors, ...action.errors)), setLoading$8(state.loading, "Stable" /* DaffState.Stable */));
|
|
1291
1347
|
default:
|
|
1292
1348
|
return state;
|
|
1293
1349
|
}
|
|
@@ -1307,11 +1363,11 @@ function cartBillingAddressReducer(state = daffCartReducerInitialState, action)
|
|
|
1307
1363
|
return Object.assign(Object.assign(Object.assign(Object.assign({}, state), resetErrors$7(state.errors)), { cart: Object.assign(Object.assign({}, state.cart), { billing_address: action.payload }) }), setLoading$7(state.loading, "Stable" /* DaffState.Complete */));
|
|
1308
1364
|
case DaffCartBillingAddressActionTypes.CartBillingAddressUpdateSuccessAction:
|
|
1309
1365
|
case DaffCartAddressActionTypes.CartAddressUpdateSuccessAction:
|
|
1310
|
-
return Object.assign(Object.assign(Object.assign(
|
|
1366
|
+
return Object.assign(Object.assign(Object.assign({}, state), resetErrors$7(state.errors)), setLoading$7(state.loading, "Stable" /* DaffState.Complete */));
|
|
1311
1367
|
case DaffCartBillingAddressActionTypes.CartBillingAddressLoadFailureAction:
|
|
1312
1368
|
case DaffCartBillingAddressActionTypes.CartBillingAddressUpdateFailureAction:
|
|
1313
1369
|
case DaffCartAddressActionTypes.CartAddressUpdateFailureAction:
|
|
1314
|
-
return Object.assign(Object.assign(Object.assign({}, state), addError$7(state.errors, action.payload)), setLoading$7(state.loading, "Stable" /* DaffState.Complete */));
|
|
1370
|
+
return Object.assign(Object.assign(Object.assign({}, state), addError$7(state.errors, ...action.payload)), setLoading$7(state.loading, "Stable" /* DaffState.Complete */));
|
|
1315
1371
|
default:
|
|
1316
1372
|
return state;
|
|
1317
1373
|
}
|
|
@@ -1331,7 +1387,7 @@ function cartCouponReducer(state = daffCartReducerInitialState, action) {
|
|
|
1331
1387
|
case DaffCartCouponActionTypes.CartCouponApplySuccessAction:
|
|
1332
1388
|
case DaffCartCouponActionTypes.CartCouponRemoveSuccessAction:
|
|
1333
1389
|
case DaffCartCouponActionTypes.CartCouponRemoveAllSuccessAction:
|
|
1334
|
-
return Object.assign(Object.assign(Object.assign(
|
|
1390
|
+
return Object.assign(Object.assign(Object.assign({}, state), resetErrors$6(state.errors)), setLoading$6(state.loading, "Stable" /* DaffState.Complete */));
|
|
1335
1391
|
case DaffCartCouponActionTypes.CartCouponClearErrorsAction:
|
|
1336
1392
|
return Object.assign(Object.assign({}, state), resetErrors$6(state.errors));
|
|
1337
1393
|
case DaffCartCouponActionTypes.CartCouponListSuccessAction:
|
|
@@ -1340,7 +1396,7 @@ function cartCouponReducer(state = daffCartReducerInitialState, action) {
|
|
|
1340
1396
|
case DaffCartCouponActionTypes.CartCouponListFailureAction:
|
|
1341
1397
|
case DaffCartCouponActionTypes.CartCouponRemoveAllFailureAction:
|
|
1342
1398
|
case DaffCartCouponActionTypes.CartCouponRemoveFailureAction:
|
|
1343
|
-
return Object.assign(Object.assign(Object.assign({}, state), addError$6(state.errors, action.payload)), setLoading$6(state.loading, "Stable" /* DaffState.Complete */));
|
|
1399
|
+
return Object.assign(Object.assign(Object.assign({}, state), addError$6(state.errors, ...action.payload)), setLoading$6(state.loading, "Stable" /* DaffState.Complete */));
|
|
1344
1400
|
default:
|
|
1345
1401
|
return state;
|
|
1346
1402
|
}
|
|
@@ -1369,16 +1425,16 @@ function cartItemReducer(state = daffCartReducerInitialState, action) {
|
|
|
1369
1425
|
case DaffCartItemActionTypes.CartItemUpdateSuccessAction:
|
|
1370
1426
|
case DaffCartItemActionTypes.CartItemAddSuccessAction:
|
|
1371
1427
|
case DaffCartItemActionTypes.CartItemDeleteSuccessAction:
|
|
1372
|
-
return Object.assign(Object.assign(Object.assign(
|
|
1428
|
+
return Object.assign(Object.assign(Object.assign({}, state), resetErrors$5(state.errors)), setLoading$5(state.loading, "Stable" /* DaffState.Complete */));
|
|
1373
1429
|
case DaffCartItemActionTypes.CartItemDeleteOutOfStockSuccessAction:
|
|
1374
1430
|
return Object.assign(Object.assign(Object.assign({}, state), { errors: Object.assign(Object.assign({}, state.errors), { [DaffCartOperationType.Item]: [],
|
|
1375
1431
|
// out of stock errors can be in the main cart, remove them here
|
|
1376
|
-
[DaffCartOperationType.Cart]: state.errors[DaffCartOperationType.Cart].filter(({ code }) => code !== DaffCartDriverErrorCodes.PRODUCT_OUT_OF_STOCK) })
|
|
1432
|
+
[DaffCartOperationType.Cart]: state.errors[DaffCartOperationType.Cart].filter(({ code }) => code !== DaffCartDriverErrorCodes.PRODUCT_OUT_OF_STOCK) }) }), setLoading$5(state.loading, "Stable" /* DaffState.Complete */));
|
|
1377
1433
|
case DaffCartItemActionTypes.CartItemListFailureAction:
|
|
1378
1434
|
case DaffCartItemActionTypes.CartItemLoadFailureAction:
|
|
1379
1435
|
case DaffCartItemActionTypes.CartItemAddFailureAction:
|
|
1380
1436
|
case DaffCartItemActionTypes.CartItemDeleteOutOfStockFailureAction:
|
|
1381
|
-
return Object.assign(Object.assign(Object.assign({}, state), addError$5(state.errors, action.payload)), setLoading$5(state.loading, "Stable" /* DaffState.Complete */));
|
|
1437
|
+
return Object.assign(Object.assign(Object.assign({}, state), addError$5(state.errors, ...action.payload)), setLoading$5(state.loading, "Stable" /* DaffState.Complete */));
|
|
1382
1438
|
case DaffCartItemActionTypes.CartItemUpdateFailureAction:
|
|
1383
1439
|
case DaffCartItemActionTypes.CartItemDeleteFailureAction:
|
|
1384
1440
|
return Object.assign(Object.assign({}, state), setLoading$5(state.loading, "Stable" /* DaffState.Complete */));
|
|
@@ -1404,12 +1460,12 @@ function cartPaymentReducer(state = daffCartReducerInitialState, action) {
|
|
|
1404
1460
|
return Object.assign(Object.assign(Object.assign(Object.assign({}, state), resetErrors$4(state.errors)), { cart: Object.assign(Object.assign({}, state.cart), { payment: null }) }), setLoading$4(state.loading, "Stable" /* DaffState.Complete */));
|
|
1405
1461
|
case DaffCartPaymentActionTypes.CartPaymentUpdateSuccessAction:
|
|
1406
1462
|
case DaffCartPaymentActionTypes.CartPaymentUpdateWithBillingSuccessAction:
|
|
1407
|
-
return Object.assign(Object.assign(Object.assign(
|
|
1463
|
+
return Object.assign(Object.assign(Object.assign({}, state), resetErrors$4(state.errors)), setLoading$4(state.loading, "Stable" /* DaffState.Complete */));
|
|
1408
1464
|
case DaffCartPaymentActionTypes.CartPaymentLoadFailureAction:
|
|
1409
1465
|
case DaffCartPaymentActionTypes.CartPaymentUpdateFailureAction:
|
|
1410
1466
|
case DaffCartPaymentActionTypes.CartPaymentUpdateWithBillingFailureAction:
|
|
1411
1467
|
case DaffCartPaymentActionTypes.CartPaymentRemoveFailureAction:
|
|
1412
|
-
return Object.assign(Object.assign(Object.assign({}, state), addError$4(state.errors, action.payload)), setLoading$4(state.loading, "Stable" /* DaffState.Complete */));
|
|
1468
|
+
return Object.assign(Object.assign(Object.assign({}, state), addError$4(state.errors, ...action.payload)), setLoading$4(state.loading, "Stable" /* DaffState.Complete */));
|
|
1413
1469
|
/**
|
|
1414
1470
|
* This reducer is temporary until custom reducers can be injected by the @daffodil/paymentSource modules. Right now,
|
|
1415
1471
|
* the payment modules need a way to update cart state with a payment token.
|
|
@@ -1433,7 +1489,7 @@ function cartPaymentMethodsReducer(state = daffCartReducerInitialState, action)
|
|
|
1433
1489
|
case DaffCartPaymentMethodsActionTypes.CartPaymentMethodsLoadSuccessAction:
|
|
1434
1490
|
return Object.assign(Object.assign(Object.assign(Object.assign({}, state), resetErrors$3(state.errors)), { cart: Object.assign(Object.assign({}, state.cart), { available_payment_methods: action.payload }) }), setLoading$3(state.loading, "Stable" /* DaffState.Complete */));
|
|
1435
1491
|
case DaffCartPaymentMethodsActionTypes.CartPaymentMethodsLoadFailureAction:
|
|
1436
|
-
return Object.assign(Object.assign(Object.assign({}, state), addError$3(state.errors, action.payload)), setLoading$3(state.loading, "Stable" /* DaffState.Complete */));
|
|
1492
|
+
return Object.assign(Object.assign(Object.assign({}, state), addError$3(state.errors, ...action.payload)), setLoading$3(state.loading, "Stable" /* DaffState.Complete */));
|
|
1437
1493
|
default:
|
|
1438
1494
|
return state;
|
|
1439
1495
|
}
|
|
@@ -1470,11 +1526,11 @@ function cartShippingAddressReducer(state = daffCartReducerInitialState, action)
|
|
|
1470
1526
|
return Object.assign(Object.assign(Object.assign(Object.assign({}, state), resetErrors$2(state.errors)), { cart: Object.assign(Object.assign({}, state.cart), { shipping_address: action.payload }) }), setLoading$2(state.loading, "Stable" /* DaffState.Complete */));
|
|
1471
1527
|
case DaffCartShippingAddressActionTypes.CartShippingAddressUpdateSuccessAction:
|
|
1472
1528
|
case DaffCartAddressActionTypes.CartAddressUpdateSuccessAction:
|
|
1473
|
-
return Object.assign(Object.assign(Object.assign(
|
|
1529
|
+
return Object.assign(Object.assign(Object.assign({}, state), resetErrors$2(state.errors)), setLoading$2(state.loading, "Stable" /* DaffState.Complete */));
|
|
1474
1530
|
case DaffCartShippingAddressActionTypes.CartShippingAddressLoadFailureAction:
|
|
1475
1531
|
case DaffCartShippingAddressActionTypes.CartShippingAddressUpdateFailureAction:
|
|
1476
1532
|
case DaffCartAddressActionTypes.CartAddressUpdateFailureAction:
|
|
1477
|
-
return Object.assign(Object.assign(Object.assign({}, state), addError$2(state.errors, action.payload)), setLoading$2(state.loading, "Stable" /* DaffState.Complete */));
|
|
1533
|
+
return Object.assign(Object.assign(Object.assign({}, state), addError$2(state.errors, ...action.payload)), setLoading$2(state.loading, "Stable" /* DaffState.Complete */));
|
|
1478
1534
|
default:
|
|
1479
1535
|
return state;
|
|
1480
1536
|
}
|
|
@@ -1496,13 +1552,11 @@ function cartShippingInformationReducer(state = daffCartReducerInitialState, act
|
|
|
1496
1552
|
shipping_information: Object.assign(Object.assign({}, action.payload), { address_id: null }) }) }), setLoading$1(state.loading, "Stable" /* DaffState.Complete */));
|
|
1497
1553
|
case DaffCartShippingInformationActionTypes.CartShippingInformationUpdateSuccessAction:
|
|
1498
1554
|
case DaffCartShippingInformationActionTypes.CartShippingInformationDeleteSuccessAction:
|
|
1499
|
-
return Object.assign(Object.assign(Object.assign(
|
|
1500
|
-
// ensure that shipping_information is set to null in case its not included in action.payload
|
|
1501
|
-
shipping_information: null }), action.payload) }), setLoading$1(state.loading, "Stable" /* DaffState.Complete */));
|
|
1555
|
+
return Object.assign(Object.assign(Object.assign({}, state), resetErrors$1(state.errors)), setLoading$1(state.loading, "Stable" /* DaffState.Complete */));
|
|
1502
1556
|
case DaffCartShippingInformationActionTypes.CartShippingInformationLoadFailureAction:
|
|
1503
1557
|
case DaffCartShippingInformationActionTypes.CartShippingInformationUpdateFailureAction:
|
|
1504
1558
|
case DaffCartShippingInformationActionTypes.CartShippingInformationDeleteFailureAction:
|
|
1505
|
-
return Object.assign(Object.assign(Object.assign({}, state), addError$1(state.errors, action.payload)), setLoading$1(state.loading, "Stable" /* DaffState.Complete */));
|
|
1559
|
+
return Object.assign(Object.assign(Object.assign({}, state), addError$1(state.errors, ...action.payload)), setLoading$1(state.loading, "Stable" /* DaffState.Complete */));
|
|
1506
1560
|
default:
|
|
1507
1561
|
return state;
|
|
1508
1562
|
}
|
|
@@ -1518,7 +1572,7 @@ function cartShippingMethodsReducer(state = daffCartReducerInitialState, action)
|
|
|
1518
1572
|
case DaffCartShippingMethodsActionTypes.CartShippingMethodsLoadSuccessAction:
|
|
1519
1573
|
return Object.assign(Object.assign(Object.assign(Object.assign({}, state), resetErrors(state.errors)), { cart: Object.assign(Object.assign({}, state.cart), { available_shipping_methods: action.payload }) }), setLoading(state.loading, "Stable" /* DaffState.Complete */));
|
|
1520
1574
|
case DaffCartShippingMethodsActionTypes.CartShippingMethodsLoadFailureAction:
|
|
1521
|
-
return Object.assign(Object.assign(Object.assign({}, state), addError(state.errors, action.payload)), setLoading(state.loading, "Stable" /* DaffState.Complete */));
|
|
1575
|
+
return Object.assign(Object.assign(Object.assign({}, state), addError(state.errors, ...action.payload)), setLoading(state.loading, "Stable" /* DaffState.Complete */));
|
|
1522
1576
|
default:
|
|
1523
1577
|
return state;
|
|
1524
1578
|
}
|
|
@@ -1552,6 +1606,35 @@ const daffCartReducers = {
|
|
|
1552
1606
|
|
|
1553
1607
|
const DAFF_CART_STORE_FEATURE_KEY = 'daffCart';
|
|
1554
1608
|
|
|
1609
|
+
/**
|
|
1610
|
+
* Reducer function factory that updates cart item entities according to a list of passed cart retrieval actions.
|
|
1611
|
+
* See {@link DaffCartRetrievalActionInjection}.
|
|
1612
|
+
*/
|
|
1613
|
+
function daffCartItemEntitiesRetrievalActionsReducerFactory(retrievalActions) {
|
|
1614
|
+
return (state = daffCartItemEntitiesAdapter().getInitialState(), action) => {
|
|
1615
|
+
const adapter = daffCartItemEntitiesAdapter();
|
|
1616
|
+
const cart = daffCartRetrievalGetResponse(action, retrievalActions);
|
|
1617
|
+
return (cart === null || cart === void 0 ? void 0 : cart.items)
|
|
1618
|
+
? adapter.setAll(cart.items.map((item) => {
|
|
1619
|
+
var _a;
|
|
1620
|
+
return (Object.assign(Object.assign({}, item), { daffState: item.daffState || ((_a = state.entities[item.id]) === null || _a === void 0 ? void 0 : _a.daffState) || DaffCartItemStateEnum.Default }));
|
|
1621
|
+
}), state)
|
|
1622
|
+
: state;
|
|
1623
|
+
};
|
|
1624
|
+
}
|
|
1625
|
+
|
|
1626
|
+
/**
|
|
1627
|
+
* Reducer function factory that updates cart state according to a list of passed cart retrieval actions.
|
|
1628
|
+
* See {@link DaffCartRetrievalActionInjection}.
|
|
1629
|
+
*/
|
|
1630
|
+
function daffCartRetrievalActionsReducerFactory(retrievalActions) {
|
|
1631
|
+
return (state = daffCartReducerInitialState, action) => {
|
|
1632
|
+
const cart = daffCartRetrievalGetResponse(action, retrievalActions);
|
|
1633
|
+
return cart
|
|
1634
|
+
? Object.assign(Object.assign({}, state), { cart: Object.assign(Object.assign({}, state.cart), cart) }) : state;
|
|
1635
|
+
};
|
|
1636
|
+
}
|
|
1637
|
+
|
|
1555
1638
|
/**
|
|
1556
1639
|
* A token to hold the injectable extra reducers.
|
|
1557
1640
|
*
|
|
@@ -1578,6 +1661,32 @@ function daffCartProvideExtraReducers(...reducers) {
|
|
|
1578
1661
|
}));
|
|
1579
1662
|
}
|
|
1580
1663
|
|
|
1664
|
+
/**
|
|
1665
|
+
* A token to hold the injectable extra meta-reducers.
|
|
1666
|
+
*
|
|
1667
|
+
* Prefer using {@link daffCartProvideMetaReducers}.
|
|
1668
|
+
*/
|
|
1669
|
+
const DAFF_CART_META_REDUCERS = new InjectionToken('DAFF_CART_META_REDUCERS', { factory: () => [] });
|
|
1670
|
+
/**
|
|
1671
|
+
* Provides additional meta-reducers that run after the standard Daffodil cart meta-reducers.
|
|
1672
|
+
*
|
|
1673
|
+
* ```ts
|
|
1674
|
+
* providers: [
|
|
1675
|
+
* ...daffCartProvideMetaReducers(
|
|
1676
|
+
* myMetaReducer1,
|
|
1677
|
+
* myMetaReducer2
|
|
1678
|
+
* )
|
|
1679
|
+
* ]
|
|
1680
|
+
* ```
|
|
1681
|
+
*/
|
|
1682
|
+
function daffCartProvideMetaReducers(...metaReducers) {
|
|
1683
|
+
return metaReducers.map(metaReducer => ({
|
|
1684
|
+
provide: DAFF_CART_META_REDUCERS,
|
|
1685
|
+
useValue: metaReducer,
|
|
1686
|
+
multi: true,
|
|
1687
|
+
}));
|
|
1688
|
+
}
|
|
1689
|
+
|
|
1581
1690
|
const getDaffCartFeatureSelector = (() => {
|
|
1582
1691
|
let cache;
|
|
1583
1692
|
return () => cache = cache
|
|
@@ -1754,39 +1863,39 @@ const createCartSelectors$1 = () => {
|
|
|
1754
1863
|
* @deprecated use selectCartSubtotalExcludingTax selector instead.
|
|
1755
1864
|
*/
|
|
1756
1865
|
const selectCartSubtotal = createSelector(selectCartValue, (state) => {
|
|
1757
|
-
const subtotalObject = state.totals
|
|
1866
|
+
const subtotalObject = state.totals[DaffCartTotalTypeEnum.subtotalExcludingTax];
|
|
1758
1867
|
return subtotalObject ? subtotalObject.value : null;
|
|
1759
1868
|
});
|
|
1760
1869
|
const selectCartGrandTotal = createSelector(selectCartValue, (state) => {
|
|
1761
|
-
const grandTotalObject = state.totals
|
|
1870
|
+
const grandTotalObject = state.totals[DaffCartTotalTypeEnum.grandTotal];
|
|
1762
1871
|
return grandTotalObject ? grandTotalObject.value : null;
|
|
1763
1872
|
});
|
|
1764
1873
|
const selectCartSubtotalExcludingTax = createSelector(selectCartValue, (state) => {
|
|
1765
|
-
const subtotalExcludingTaxObject = state.totals
|
|
1874
|
+
const subtotalExcludingTaxObject = state.totals[DaffCartTotalTypeEnum.subtotalExcludingTax];
|
|
1766
1875
|
return subtotalExcludingTaxObject ? subtotalExcludingTaxObject.value : null;
|
|
1767
1876
|
});
|
|
1768
1877
|
const selectCartSubtotalIncludingTax = createSelector(selectCartValue, (state) => {
|
|
1769
|
-
const subtotalIncludingTaxObject = state.totals
|
|
1878
|
+
const subtotalIncludingTaxObject = state.totals[DaffCartTotalTypeEnum.subtotalIncludingTax];
|
|
1770
1879
|
return subtotalIncludingTaxObject ? subtotalIncludingTaxObject.value : null;
|
|
1771
1880
|
});
|
|
1772
1881
|
const selectCartSubtotalWithDiscountExcludingTax = createSelector(selectCartValue, (state) => {
|
|
1773
|
-
const subtotalWithDiscountExcludingTaxObject = state.totals
|
|
1882
|
+
const subtotalWithDiscountExcludingTaxObject = state.totals[DaffCartTotalTypeEnum.subtotalWithDiscountExcludingTax];
|
|
1774
1883
|
return subtotalWithDiscountExcludingTaxObject ? subtotalWithDiscountExcludingTaxObject.value : null;
|
|
1775
1884
|
});
|
|
1776
1885
|
const selectCartSubtotalWithDiscountIncludingTax = createSelector(selectCartValue, (state) => {
|
|
1777
|
-
const subtotalWithDiscountIncludingTaxObject = state.totals
|
|
1886
|
+
const subtotalWithDiscountIncludingTaxObject = state.totals[DaffCartTotalTypeEnum.subtotalWithDiscountIncludingTax];
|
|
1778
1887
|
return subtotalWithDiscountIncludingTaxObject ? subtotalWithDiscountIncludingTaxObject.value : null;
|
|
1779
1888
|
});
|
|
1780
1889
|
const selectCartTotalTax = createSelector(selectCartValue, (state) => {
|
|
1781
|
-
const taxObject = state.totals
|
|
1890
|
+
const taxObject = state.totals[DaffCartTotalTypeEnum.tax];
|
|
1782
1891
|
return taxObject ? taxObject.value : null;
|
|
1783
1892
|
});
|
|
1784
1893
|
const selectCartDiscountTotals = createSelector(selectCartValue, (state) => {
|
|
1785
|
-
const
|
|
1786
|
-
return
|
|
1894
|
+
const discount = state.totals[DaffCartTotalTypeEnum.discount];
|
|
1895
|
+
return discount ? [discount] : [];
|
|
1787
1896
|
});
|
|
1788
1897
|
const selectCartShippingTotal = createSelector(selectCartValue, (state) => {
|
|
1789
|
-
const shippingTotalObject = state.totals
|
|
1898
|
+
const shippingTotalObject = state.totals[DaffCartTotalTypeEnum.shipping];
|
|
1790
1899
|
return shippingTotalObject ? shippingTotalObject.value : null;
|
|
1791
1900
|
});
|
|
1792
1901
|
const selectCartCoupons = createSelector(selectCartValue, (state) => state.coupons);
|
|
@@ -1935,15 +2044,21 @@ const getDaffCartSelectors = (() => {
|
|
|
1935
2044
|
*/
|
|
1936
2045
|
const DaffCartItemStateDebounceTime = new InjectionToken('DaffCartItemStateDebounceTime');
|
|
1937
2046
|
|
|
2047
|
+
/**
|
|
2048
|
+
* Transforms `DaffError`s into `DaffStateError`s before they are serialized into state.
|
|
2049
|
+
* Can be used to further refine Daffodil errors into more specific app errors.
|
|
2050
|
+
*/
|
|
2051
|
+
const DAFF_CART_ERROR_MATCHER = new InjectionToken('DAFF_CART_ERROR_MATCHER', { factory: () => daffTransformErrorToStateError });
|
|
2052
|
+
|
|
1938
2053
|
class DaffCartAddressEffects {
|
|
1939
2054
|
constructor(actions$, errorMatcher, driver, storage) {
|
|
1940
2055
|
this.actions$ = actions$;
|
|
1941
2056
|
this.errorMatcher = errorMatcher;
|
|
1942
2057
|
this.driver = driver;
|
|
1943
2058
|
this.storage = storage;
|
|
1944
|
-
this.update$ = createEffect(() => this.actions$.pipe(ofType(DaffCartAddressActionTypes.CartAddressUpdateAction), switchMap((action) => defer(() => of(this.storage.getCartId())).pipe(switchMap(cartId => this.driver.update(cartId, action.payload)), map((resp) => new DaffCartAddressUpdateSuccess(resp)),
|
|
1945
|
-
? new DaffCartStorageFailure(this.errorMatcher
|
|
1946
|
-
: new DaffCartAddressUpdateFailure(this.errorMatcher
|
|
2059
|
+
this.update$ = createEffect(() => this.actions$.pipe(ofType(DaffCartAddressActionTypes.CartAddressUpdateAction), switchMap((action) => defer(() => of(this.storage.getCartId())).pipe(switchMap(cartId => this.driver.update(cartId, action.payload)), map((resp) => new DaffCartAddressUpdateSuccess(resp)), catchAndArrayifyErrors(error => of(error.find((err) => err.code === DAFF_STORAGE_SERVICE_ERROR_CODE)
|
|
2060
|
+
? new DaffCartStorageFailure(error.map(this.errorMatcher))
|
|
2061
|
+
: new DaffCartAddressUpdateFailure(error.map(this.errorMatcher))))))));
|
|
1947
2062
|
}
|
|
1948
2063
|
}
|
|
1949
2064
|
/** @nocollapse */ DaffCartAddressEffects.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffCartAddressEffects, deps: [{ token: i1.Actions }, { token: DAFF_CART_ERROR_MATCHER }, { token: DaffCartAddressDriver }, { token: i2.DaffCartStorageService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
@@ -1966,8 +2081,8 @@ class DaffCartBillingAddressEffects {
|
|
|
1966
2081
|
this.errorMatcher = errorMatcher;
|
|
1967
2082
|
this.driver = driver;
|
|
1968
2083
|
this.storage = storage;
|
|
1969
|
-
this.get$ = createEffect(() => this.actions$.pipe(ofType(DaffCartBillingAddressActionTypes.CartBillingAddressLoadAction), switchMap((action) => this.driver.get(this.storage.getCartId()).pipe(map((resp) => new DaffCartBillingAddressLoadSuccess(resp)),
|
|
1970
|
-
this.update$ = createEffect(() => this.actions$.pipe(ofType(DaffCartBillingAddressActionTypes.CartBillingAddressUpdateAction), switchMap((action) => this.driver.update(this.storage.getCartId(), action.payload).pipe(map((resp) => new DaffCartBillingAddressUpdateSuccess(resp)),
|
|
2084
|
+
this.get$ = createEffect(() => this.actions$.pipe(ofType(DaffCartBillingAddressActionTypes.CartBillingAddressLoadAction), switchMap((action) => this.driver.get(this.storage.getCartId()).pipe(map((resp) => new DaffCartBillingAddressLoadSuccess(resp)), catchAndArrayifyErrors(error => of(new DaffCartBillingAddressLoadFailure(error.map(this.errorMatcher))))))));
|
|
2085
|
+
this.update$ = createEffect(() => this.actions$.pipe(ofType(DaffCartBillingAddressActionTypes.CartBillingAddressUpdateAction), switchMap((action) => this.driver.update(this.storage.getCartId(), action.payload).pipe(map((resp) => new DaffCartBillingAddressUpdateSuccess(resp)), catchAndArrayifyErrors(error => of(new DaffCartBillingAddressUpdateFailure(error.map(this.errorMatcher))))))));
|
|
1971
2086
|
}
|
|
1972
2087
|
}
|
|
1973
2088
|
/** @nocollapse */ DaffCartBillingAddressEffects.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffCartBillingAddressEffects, deps: [{ token: i1.Actions }, { token: DAFF_CART_ERROR_MATCHER }, { token: DaffCartBillingAddressDriver }, { token: i2.DaffCartStorageService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
@@ -1990,18 +2105,18 @@ class DaffCartCouponEffects {
|
|
|
1990
2105
|
this.errorMatcher = errorMatcher;
|
|
1991
2106
|
this.driver = driver;
|
|
1992
2107
|
this.storage = storage;
|
|
1993
|
-
this.apply$ = createEffect(() => this.actions$.pipe(ofType(DaffCartCouponActionTypes.CartCouponApplyAction), switchMap((action) => defer(() => of(this.storage.getCartId())).pipe(switchMap(cartId => this.driver.apply(cartId, action.payload)), map(resp => new DaffCartCouponApplySuccess(resp)),
|
|
1994
|
-
? new DaffCartStorageFailure(this.errorMatcher
|
|
1995
|
-
: new DaffCartCouponApplyFailure(this.errorMatcher
|
|
1996
|
-
this.list$ = createEffect(() => this.actions$.pipe(ofType(DaffCartCouponActionTypes.CartCouponListAction), switchMap((action) => defer(() => of(this.storage.getCartId())).pipe(switchMap(cartId => this.driver.list(cartId)), map(resp => new DaffCartCouponListSuccess(resp)),
|
|
1997
|
-
? new DaffCartStorageFailure(this.errorMatcher
|
|
1998
|
-
: new DaffCartCouponListFailure(this.errorMatcher
|
|
1999
|
-
this.remove$ = createEffect(() => this.actions$.pipe(ofType(DaffCartCouponActionTypes.CartCouponRemoveAction), switchMap((action) => defer(() => of(this.storage.getCartId())).pipe(switchMap(cartId => this.driver.remove(cartId, action.payload)), map(resp => new DaffCartCouponRemoveSuccess(resp)),
|
|
2000
|
-
? new DaffCartStorageFailure(this.errorMatcher
|
|
2001
|
-
: new DaffCartCouponRemoveFailure(this.errorMatcher
|
|
2002
|
-
this.removeAll$ = createEffect(() => this.actions$.pipe(ofType(DaffCartCouponActionTypes.CartCouponRemoveAllAction), switchMap((action) => defer(() => of(this.storage.getCartId())).pipe(switchMap(cartId => this.driver.removeAll(cartId)), map(resp => new DaffCartCouponRemoveAllSuccess(resp)),
|
|
2003
|
-
? new DaffCartStorageFailure(this.errorMatcher
|
|
2004
|
-
: new DaffCartCouponRemoveAllFailure(this.errorMatcher
|
|
2108
|
+
this.apply$ = createEffect(() => this.actions$.pipe(ofType(DaffCartCouponActionTypes.CartCouponApplyAction), switchMap((action) => defer(() => of(this.storage.getCartId())).pipe(switchMap(cartId => this.driver.apply(cartId, action.payload)), map(resp => new DaffCartCouponApplySuccess(resp)), catchAndArrayifyErrors(error => of(error.find((err) => err.code === DAFF_STORAGE_SERVICE_ERROR_CODE)
|
|
2109
|
+
? new DaffCartStorageFailure(error.map(this.errorMatcher))
|
|
2110
|
+
: new DaffCartCouponApplyFailure(error.map(this.errorMatcher))))))));
|
|
2111
|
+
this.list$ = createEffect(() => this.actions$.pipe(ofType(DaffCartCouponActionTypes.CartCouponListAction), switchMap((action) => defer(() => of(this.storage.getCartId())).pipe(switchMap(cartId => this.driver.list(cartId)), map(resp => new DaffCartCouponListSuccess(resp)), catchAndArrayifyErrors(error => of(error.find((err) => err.code === DAFF_STORAGE_SERVICE_ERROR_CODE)
|
|
2112
|
+
? new DaffCartStorageFailure(error.map(this.errorMatcher))
|
|
2113
|
+
: new DaffCartCouponListFailure(error.map(this.errorMatcher))))))));
|
|
2114
|
+
this.remove$ = createEffect(() => this.actions$.pipe(ofType(DaffCartCouponActionTypes.CartCouponRemoveAction), switchMap((action) => defer(() => of(this.storage.getCartId())).pipe(switchMap(cartId => this.driver.remove(cartId, action.payload)), map(resp => new DaffCartCouponRemoveSuccess(resp)), catchAndArrayifyErrors(error => of(error.find((err) => err.code === DAFF_STORAGE_SERVICE_ERROR_CODE)
|
|
2115
|
+
? new DaffCartStorageFailure(error.map(this.errorMatcher))
|
|
2116
|
+
: new DaffCartCouponRemoveFailure(error.map(this.errorMatcher))))))));
|
|
2117
|
+
this.removeAll$ = createEffect(() => this.actions$.pipe(ofType(DaffCartCouponActionTypes.CartCouponRemoveAllAction), switchMap((action) => defer(() => of(this.storage.getCartId())).pipe(switchMap(cartId => this.driver.removeAll(cartId)), map(resp => new DaffCartCouponRemoveAllSuccess(resp)), catchAndArrayifyErrors(error => of(error.find((err) => err.code === DAFF_STORAGE_SERVICE_ERROR_CODE)
|
|
2118
|
+
? new DaffCartStorageFailure(error.map(this.errorMatcher))
|
|
2119
|
+
: new DaffCartCouponRemoveAllFailure(error.map(this.errorMatcher))))))));
|
|
2005
2120
|
}
|
|
2006
2121
|
}
|
|
2007
2122
|
/** @nocollapse */ DaffCartCouponEffects.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffCartCouponEffects, deps: [{ token: i1.Actions }, { token: DAFF_CART_ERROR_MATCHER }, { token: DaffCartCouponDriver }, { token: i2.DaffCartStorageService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
@@ -2027,25 +2142,25 @@ class DaffCartItemEffects {
|
|
|
2027
2142
|
this.cartItemStateDebounceTime = cartItemStateDebounceTime;
|
|
2028
2143
|
this.store = store;
|
|
2029
2144
|
this.cartResolver = cartResolver;
|
|
2030
|
-
this.list$ = createEffect(() => this.actions$.pipe(ofType(DaffCartItemActionTypes.CartItemListAction), switchMap((action) => this.driver.list(this.storage.getCartId()).pipe(map((resp) => new DaffCartItemListSuccess(resp)),
|
|
2031
|
-
this.get$ = createEffect(() => this.actions$.pipe(ofType(DaffCartItemActionTypes.CartItemLoadAction), switchMap((action) => this.driver.get(this.storage.getCartId(), action.itemId).pipe(map((resp) => new DaffCartItemLoadSuccess(resp)),
|
|
2145
|
+
this.list$ = createEffect(() => this.actions$.pipe(ofType(DaffCartItemActionTypes.CartItemListAction), switchMap((action) => this.driver.list(this.storage.getCartId()).pipe(map((resp) => new DaffCartItemListSuccess(resp)), catchAndArrayifyErrors(error => of(new DaffCartItemListFailure(error.map(this.errorMatcher))))))));
|
|
2146
|
+
this.get$ = createEffect(() => this.actions$.pipe(ofType(DaffCartItemActionTypes.CartItemLoadAction), switchMap((action) => this.driver.get(this.storage.getCartId(), action.itemId).pipe(map((resp) => new DaffCartItemLoadSuccess(resp)), catchAndArrayifyErrors(error => of(new DaffCartItemLoadFailure(error.map(this.errorMatcher), action.itemId)))))));
|
|
2032
2147
|
this.add$ = createEffect(() => this.actions$.pipe(ofType(DaffCartItemActionTypes.CartItemAddAction), concatMap((action) => combineLatest([
|
|
2033
2148
|
of(action),
|
|
2034
2149
|
this.cartResolver.getCartIdOrFail(),
|
|
2035
|
-
])), mergeMap(([action, id]) => this.addCartItem$(id, action.input)), daffCartDriverHandleCartNotFound(this.storage),
|
|
2036
|
-
this.update$ = createEffect(() => this.actions$.pipe(ofType(DaffCartItemActionTypes.CartItemUpdateAction), mergeMap((action) => this.driver.update(this.storage.getCartId(), action.itemId, action.changes).pipe(map((resp) => new DaffCartItemUpdateSuccess(resp, action.itemId)),
|
|
2150
|
+
])), mergeMap(([action, id]) => this.addCartItem$(id, action.input)), daffCartDriverHandleCartNotFound(this.storage), catchAndArrayifyErrors(error => of(new DaffCartItemAddFailure(error.map(this.errorMatcher))))));
|
|
2151
|
+
this.update$ = createEffect(() => this.actions$.pipe(ofType(DaffCartItemActionTypes.CartItemUpdateAction), mergeMap((action) => this.driver.update(this.storage.getCartId(), action.itemId, action.changes).pipe(map((resp) => new DaffCartItemUpdateSuccess(resp, action.itemId)), catchAndArrayifyErrors(error => of(new DaffCartItemUpdateFailure(error.map(this.errorMatcher), action.itemId)))))));
|
|
2037
2152
|
this.resetCartItemStateAfterChange$ = createEffect(() => this.actions$.pipe(ofType(
|
|
2038
2153
|
// these actions will reset the debounce interval
|
|
2039
2154
|
DaffCartItemActionTypes.CartItemAddSuccessAction, DaffCartItemActionTypes.CartItemUpdateSuccessAction, DaffCartItemActionTypes.CartItemUpdateAction), debounceTime(this.cartItemStateDebounceTime), ofType(
|
|
2040
2155
|
// these actions will cause the cart item state reset
|
|
2041
2156
|
DaffCartItemActionTypes.CartItemAddSuccessAction, DaffCartItemActionTypes.CartItemUpdateSuccessAction), map(() => new DaffCartItemStateReset())));
|
|
2042
|
-
this.delete$ = createEffect(() => this.actions$.pipe(ofType(DaffCartItemActionTypes.CartItemDeleteAction), mergeMap((action) => this.driver.delete(this.storage.getCartId(), action.itemId).pipe(map((resp) => new DaffCartItemDeleteSuccess(resp)),
|
|
2157
|
+
this.delete$ = createEffect(() => this.actions$.pipe(ofType(DaffCartItemActionTypes.CartItemDeleteAction), mergeMap((action) => this.driver.delete(this.storage.getCartId(), action.itemId).pipe(map((resp) => new DaffCartItemDeleteSuccess(resp)), catchAndArrayifyErrors(error => of(new DaffCartItemDeleteFailure(error.map(this.errorMatcher), action.itemId)))))));
|
|
2043
2158
|
this.removeOutOfStock$ = createEffect(() => this.actions$.pipe(ofType(DaffCartItemActionTypes.CartItemDeleteOutOfStockAction), switchMap((action) => this.store.pipe(select(getDaffCartSelectors().selectOutOfStockCartItems), take(1))), switchMap(items => items.length > 0
|
|
2044
2159
|
? combineLatest(items.map(item => this.driver.delete(this.storage.getCartId(), item.id))).pipe(map(partialCarts => Object.assign({}, ...partialCarts)))
|
|
2045
|
-
: this.store.pipe(select(getDaffCartSelectors().selectCartValue), take(1))), map(cart => new DaffCartItemDeleteOutOfStockSuccess(cart)),
|
|
2160
|
+
: this.store.pipe(select(getDaffCartSelectors().selectCartValue), take(1))), map(cart => new DaffCartItemDeleteOutOfStockSuccess(cart)), catchAndArrayifyErrors(error => of(new DaffCartItemDeleteOutOfStockFailure(error.map(this.errorMatcher))))));
|
|
2046
2161
|
}
|
|
2047
2162
|
addCartItem$(cartId, input) {
|
|
2048
|
-
return this.driver.add(cartId, input).pipe(map((resp) => new DaffCartItemAddSuccess(resp)),
|
|
2163
|
+
return this.driver.add(cartId, input).pipe(map((resp) => new DaffCartItemAddSuccess(resp)), catchAndArrayifyErrors(error => of(new DaffCartItemAddFailure(error.map(this.errorMatcher)))));
|
|
2049
2164
|
}
|
|
2050
2165
|
}
|
|
2051
2166
|
/** @nocollapse */ DaffCartItemEffects.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffCartItemEffects, deps: [{ token: i1.Actions }, { token: DAFF_CART_ERROR_MATCHER }, { token: DaffCartItemDriver }, { token: i2.DaffCartStorageService }, { token: DaffCartItemStateDebounceTime }, { token: i1$1.Store }, { token: i4.DaffCartDriverResolveService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
@@ -2071,9 +2186,9 @@ class DaffCartOrderEffects {
|
|
|
2071
2186
|
this.errorMatcher = errorMatcher;
|
|
2072
2187
|
this.driver = driver;
|
|
2073
2188
|
this.storage = storage;
|
|
2074
|
-
this.placeOrder$ = createEffect(() => this.actions$.pipe(ofType(DaffCartOrderActionTypes.CartPlaceOrderAction), switchMap((action) => defer(() => of(this.storage.getCartId())).pipe(switchMap(cartId => this.driver.placeOrder(cartId, action.payload)), map((resp) => new DaffCartPlaceOrderSuccess(resp)),
|
|
2075
|
-
? new DaffCartStorageFailure(this.errorMatcher
|
|
2076
|
-
: new DaffCartPlaceOrderFailure(this.errorMatcher
|
|
2189
|
+
this.placeOrder$ = createEffect(() => this.actions$.pipe(ofType(DaffCartOrderActionTypes.CartPlaceOrderAction), switchMap((action) => defer(() => of(this.storage.getCartId())).pipe(switchMap(cartId => this.driver.placeOrder(cartId, action.payload)), map((resp) => new DaffCartPlaceOrderSuccess(resp)), catchAndArrayifyErrors(error => of(error.find((err) => err.code === DAFF_STORAGE_SERVICE_ERROR_CODE)
|
|
2190
|
+
? new DaffCartStorageFailure(error.map(this.errorMatcher))
|
|
2191
|
+
: new DaffCartPlaceOrderFailure(error.map(this.errorMatcher))))))));
|
|
2077
2192
|
this.resetCart$ = createEffect(() => this.actions$.pipe(ofType(DaffCartOrderActionTypes.CartPlaceOrderSuccessAction), map(() => new DaffCartCreate())));
|
|
2078
2193
|
}
|
|
2079
2194
|
}
|
|
@@ -2097,7 +2212,7 @@ class DaffCartPaymentMethodsEffects {
|
|
|
2097
2212
|
this.errorMatcher = errorMatcher;
|
|
2098
2213
|
this.driver = driver;
|
|
2099
2214
|
this.storage = storage;
|
|
2100
|
-
this.list$ = createEffect(() => this.actions$.pipe(ofType(DaffCartPaymentMethodsActionTypes.CartPaymentMethodsLoadAction), switchMap((action) => this.driver.list(this.storage.getCartId()).pipe(map((resp) => new DaffCartPaymentMethodsLoadSuccess(resp)),
|
|
2215
|
+
this.list$ = createEffect(() => this.actions$.pipe(ofType(DaffCartPaymentMethodsActionTypes.CartPaymentMethodsLoadAction), switchMap((action) => this.driver.list(this.storage.getCartId()).pipe(map((resp) => new DaffCartPaymentMethodsLoadSuccess(resp)), catchAndArrayifyErrors(error => of(new DaffCartPaymentMethodsLoadFailure(error.map(this.errorMatcher))))))));
|
|
2101
2216
|
}
|
|
2102
2217
|
}
|
|
2103
2218
|
/** @nocollapse */ DaffCartPaymentMethodsEffects.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffCartPaymentMethodsEffects, deps: [{ token: i1.Actions }, { token: DAFF_CART_ERROR_MATCHER }, { token: DaffCartPaymentMethodsDriver }, { token: i2.DaffCartStorageService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
@@ -2129,7 +2244,7 @@ class DaffCartPaymentProcessorEffects {
|
|
|
2129
2244
|
defer(() => this.injector.get(this.processors[action.request.kind].driver).generateToken(action.request).pipe(map(e => [e, action]), switchMap(([response, act]) => this.driver.update(this.storage.getCartId(), {
|
|
2130
2245
|
method: response.method,
|
|
2131
2246
|
payment_info: response.data,
|
|
2132
|
-
}, act.address).pipe(map((resp) => new DaffCartPaymentUpdateSuccess(resp)),
|
|
2247
|
+
}, act.address).pipe(map((resp) => new DaffCartPaymentUpdateSuccess(resp)), catchAndArrayifyErrors(error => of(new DaffCartPaymentUpdateFailure(error.map(this.errorMatcher)))))), catchAndArrayifyErrors(error => of(new DaffPaymentGenerateTokenFailure(this.paymentErrorMatcher(error[0])))))))));
|
|
2133
2248
|
}
|
|
2134
2249
|
}
|
|
2135
2250
|
/** @nocollapse */ DaffCartPaymentProcessorEffects.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffCartPaymentProcessorEffects, deps: [{ token: i1.Actions }, { token: DAFF_PAYMENT_PROCESSOR_COLLECTION }, { token: DAFF_CART_ERROR_MATCHER }, { token: DAFF_PAYMENT_ERROR_MATCHER }, { token: DaffCartPaymentDriver }, { token: i2.DaffCartStorageService }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
@@ -2158,10 +2273,10 @@ class DaffCartPaymentEffects {
|
|
|
2158
2273
|
this.errorMatcher = errorMatcher;
|
|
2159
2274
|
this.driver = driver;
|
|
2160
2275
|
this.storage = storage;
|
|
2161
|
-
this.get$ = createEffect(() => this.actions$.pipe(ofType(DaffCartPaymentActionTypes.CartPaymentLoadAction), switchMap((action) => this.driver.get(this.storage.getCartId()).pipe(map((resp) => new DaffCartPaymentLoadSuccess(resp)),
|
|
2162
|
-
this.update$ = createEffect(() => this.actions$.pipe(ofType(DaffCartPaymentActionTypes.CartPaymentUpdateAction), switchMap((action) => this.driver.update(this.storage.getCartId(), action.payload).pipe(map((resp) => new DaffCartPaymentUpdateSuccess(resp)),
|
|
2163
|
-
this.updateWithBilling$ = createEffect(() => this.actions$.pipe(ofType(DaffCartPaymentActionTypes.CartPaymentUpdateWithBillingAction), switchMap((action) => this.driver.updateWithBilling(this.storage.getCartId(), action.payment, action.address).pipe(map(resp => new DaffCartPaymentUpdateWithBillingSuccess(resp)),
|
|
2164
|
-
this.remove$ = createEffect(() => this.actions$.pipe(ofType(DaffCartPaymentActionTypes.CartPaymentRemoveAction), switchMap((action) => this.driver.remove(this.storage.getCartId()).pipe(map(() => new DaffCartPaymentRemoveSuccess()),
|
|
2276
|
+
this.get$ = createEffect(() => this.actions$.pipe(ofType(DaffCartPaymentActionTypes.CartPaymentLoadAction), switchMap((action) => this.driver.get(this.storage.getCartId()).pipe(map((resp) => new DaffCartPaymentLoadSuccess(resp)), catchAndArrayifyErrors(error => of(new DaffCartPaymentLoadFailure(error.map(this.errorMatcher))))))));
|
|
2277
|
+
this.update$ = createEffect(() => this.actions$.pipe(ofType(DaffCartPaymentActionTypes.CartPaymentUpdateAction), switchMap((action) => this.driver.update(this.storage.getCartId(), action.payload).pipe(map((resp) => new DaffCartPaymentUpdateSuccess(resp)), catchAndArrayifyErrors(error => of(new DaffCartPaymentUpdateFailure(error.map(this.errorMatcher))))))));
|
|
2278
|
+
this.updateWithBilling$ = createEffect(() => this.actions$.pipe(ofType(DaffCartPaymentActionTypes.CartPaymentUpdateWithBillingAction), switchMap((action) => this.driver.updateWithBilling(this.storage.getCartId(), action.payment, action.address).pipe(map(resp => new DaffCartPaymentUpdateWithBillingSuccess(resp)), catchAndArrayifyErrors(error => of(new DaffCartPaymentUpdateWithBillingFailure(error.map(this.errorMatcher))))))));
|
|
2279
|
+
this.remove$ = createEffect(() => this.actions$.pipe(ofType(DaffCartPaymentActionTypes.CartPaymentRemoveAction), switchMap((action) => this.driver.remove(this.storage.getCartId()).pipe(map(() => new DaffCartPaymentRemoveSuccess()), catchAndArrayifyErrors(error => of(new DaffCartPaymentRemoveFailure(error.map(this.errorMatcher))))))));
|
|
2165
2280
|
}
|
|
2166
2281
|
}
|
|
2167
2282
|
/** @nocollapse */ DaffCartPaymentEffects.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffCartPaymentEffects, deps: [{ token: i1.Actions }, { token: DAFF_CART_ERROR_MATCHER }, { token: DaffCartPaymentDriver }, { token: i2.DaffCartStorageService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
@@ -2197,19 +2312,23 @@ class DaffCartResolverEffects {
|
|
|
2197
2312
|
() => action.type === DaffCartActionTypes.ResolveCartSuccessAction,
|
|
2198
2313
|
// then just cancel the outstanding operation
|
|
2199
2314
|
EMPTY, this.cartResolver.getCartOrFail().pipe(map(({ response, errors }) => errors.length > 0
|
|
2200
|
-
? new DaffResolveCartPartialSuccess(response, errors.map(
|
|
2201
|
-
: new DaffResolveCartSuccess(response)), daffCartDriverHandleCartNotFound(this.cartStorage),
|
|
2315
|
+
? new DaffResolveCartPartialSuccess(response, errors.map(this.errorMatcher))
|
|
2316
|
+
: new DaffResolveCartSuccess(response)), daffCartDriverHandleCartNotFound(this.cartStorage), catchAndArrayifyErrors((error) => {
|
|
2202
2317
|
switch (true) {
|
|
2203
|
-
case error
|
|
2204
|
-
return of(new DaffResolveCartServerSide(
|
|
2205
|
-
|
|
2206
|
-
|
|
2318
|
+
case !!error.find((err) => err.code === DAFF_SERVER_STORAGE_SERVICE_ERROR_CODE):
|
|
2319
|
+
return of(new DaffResolveCartServerSide([
|
|
2320
|
+
this.errorMatcher(new DaffCartServerSideResolutionError(error[0].message)),
|
|
2321
|
+
]));
|
|
2322
|
+
case !!error.find((err) => err.code === DAFF_STORAGE_SERVICE_ERROR_CODE):
|
|
2323
|
+
return of(new DaffResolveCartFailure([
|
|
2324
|
+
this.errorMatcher(new DaffCartStorageResolutionError(error[0].message)),
|
|
2325
|
+
]));
|
|
2207
2326
|
default:
|
|
2208
|
-
return of(new DaffResolveCartFailure(
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2327
|
+
return of(new DaffResolveCartFailure(error.map((err) =>
|
|
2328
|
+
// I wish there was a better way to check this
|
|
2329
|
+
this.errorMatcher(err instanceof DaffInheritableError || !!err.code
|
|
2330
|
+
? err
|
|
2331
|
+
: new DaffCartResolutionError(err.message)))));
|
|
2213
2332
|
}
|
|
2214
2333
|
}))))));
|
|
2215
2334
|
}
|
|
@@ -2237,8 +2356,8 @@ class DaffCartShippingAddressEffects {
|
|
|
2237
2356
|
this.errorMatcher = errorMatcher;
|
|
2238
2357
|
this.driver = driver;
|
|
2239
2358
|
this.storage = storage;
|
|
2240
|
-
this.get$ = createEffect(() => this.actions$.pipe(ofType(DaffCartShippingAddressActionTypes.CartShippingAddressLoadAction), switchMap((action) => this.driver.get(this.storage.getCartId()).pipe(map((resp) => new DaffCartShippingAddressLoadSuccess(resp)),
|
|
2241
|
-
this.update$ = createEffect(() => this.actions$.pipe(ofType(DaffCartShippingAddressActionTypes.CartShippingAddressUpdateAction), switchMap((action) => this.driver.update(this.storage.getCartId(), action.payload).pipe(map((resp) => new DaffCartShippingAddressUpdateSuccess(resp)),
|
|
2359
|
+
this.get$ = createEffect(() => this.actions$.pipe(ofType(DaffCartShippingAddressActionTypes.CartShippingAddressLoadAction), switchMap((action) => this.driver.get(this.storage.getCartId()).pipe(map((resp) => new DaffCartShippingAddressLoadSuccess(resp)), catchAndArrayifyErrors(error => of(new DaffCartShippingAddressLoadFailure(error.map(this.errorMatcher))))))));
|
|
2360
|
+
this.update$ = createEffect(() => this.actions$.pipe(ofType(DaffCartShippingAddressActionTypes.CartShippingAddressUpdateAction), switchMap((action) => this.driver.update(this.storage.getCartId(), action.payload).pipe(map((resp) => new DaffCartShippingAddressUpdateSuccess(resp)), catchAndArrayifyErrors(error => of(new DaffCartShippingAddressUpdateFailure(error.map(this.errorMatcher))))))));
|
|
2242
2361
|
}
|
|
2243
2362
|
}
|
|
2244
2363
|
/** @nocollapse */ DaffCartShippingAddressEffects.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffCartShippingAddressEffects, deps: [{ token: i1.Actions }, { token: DAFF_CART_ERROR_MATCHER }, { token: DaffCartShippingAddressDriver }, { token: i2.DaffCartStorageService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
@@ -2261,9 +2380,9 @@ class DaffCartShippingInformationEffects {
|
|
|
2261
2380
|
this.errorMatcher = errorMatcher;
|
|
2262
2381
|
this.driver = driver;
|
|
2263
2382
|
this.storage = storage;
|
|
2264
|
-
this.get$ = createEffect(() => this.actions$.pipe(ofType(DaffCartShippingInformationActionTypes.CartShippingInformationLoadAction), switchMap((action) => this.driver.get(this.storage.getCartId()).pipe(map((resp) => new DaffCartShippingInformationLoadSuccess(resp)),
|
|
2265
|
-
this.update$ = createEffect(() => this.actions$.pipe(ofType(DaffCartShippingInformationActionTypes.CartShippingInformationUpdateAction), switchMap((action) => this.driver.update(this.storage.getCartId(), action.payload).pipe(map((resp) => new DaffCartShippingInformationUpdateSuccess(resp)),
|
|
2266
|
-
this.delete$ = createEffect(() => this.actions$.pipe(ofType(DaffCartShippingInformationActionTypes.CartShippingInformationDeleteAction), switchMap((action) => this.driver.delete(this.storage.getCartId()).pipe(map((resp) => new DaffCartShippingInformationDeleteSuccess(resp)),
|
|
2383
|
+
this.get$ = createEffect(() => this.actions$.pipe(ofType(DaffCartShippingInformationActionTypes.CartShippingInformationLoadAction), switchMap((action) => this.driver.get(this.storage.getCartId()).pipe(map((resp) => new DaffCartShippingInformationLoadSuccess(resp)), catchAndArrayifyErrors(error => of(new DaffCartShippingInformationLoadFailure(error.map(this.errorMatcher))))))));
|
|
2384
|
+
this.update$ = createEffect(() => this.actions$.pipe(ofType(DaffCartShippingInformationActionTypes.CartShippingInformationUpdateAction), switchMap((action) => this.driver.update(this.storage.getCartId(), action.payload).pipe(map((resp) => new DaffCartShippingInformationUpdateSuccess(resp)), catchAndArrayifyErrors(error => of(new DaffCartShippingInformationUpdateFailure(error.map(this.errorMatcher))))))));
|
|
2385
|
+
this.delete$ = createEffect(() => this.actions$.pipe(ofType(DaffCartShippingInformationActionTypes.CartShippingInformationDeleteAction), switchMap((action) => this.driver.delete(this.storage.getCartId()).pipe(map((resp) => new DaffCartShippingInformationDeleteSuccess(resp)), catchAndArrayifyErrors(error => of(new DaffCartShippingInformationDeleteFailure(error.map(this.errorMatcher))))))));
|
|
2267
2386
|
}
|
|
2268
2387
|
}
|
|
2269
2388
|
/** @nocollapse */ DaffCartShippingInformationEffects.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffCartShippingInformationEffects, deps: [{ token: i1.Actions }, { token: DAFF_CART_ERROR_MATCHER }, { token: DaffCartShippingInformationDriver }, { token: i2.DaffCartStorageService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
@@ -2286,7 +2405,7 @@ class DaffCartShippingMethodsEffects {
|
|
|
2286
2405
|
this.errorMatcher = errorMatcher;
|
|
2287
2406
|
this.driver = driver;
|
|
2288
2407
|
this.storage = storage;
|
|
2289
|
-
this.list$ = createEffect(() => this.actions$.pipe(ofType(DaffCartShippingMethodsActionTypes.CartShippingMethodsLoadAction), switchMap((action) => this.driver.list(this.storage.getCartId()).pipe(map((resp) => new DaffCartShippingMethodsLoadSuccess(resp)),
|
|
2408
|
+
this.list$ = createEffect(() => this.actions$.pipe(ofType(DaffCartShippingMethodsActionTypes.CartShippingMethodsLoadAction), switchMap((action) => this.driver.list(this.storage.getCartId()).pipe(map((resp) => new DaffCartShippingMethodsLoadSuccess(resp)), catchAndArrayifyErrors(error => of(new DaffCartShippingMethodsLoadFailure(error.map(this.errorMatcher))))))));
|
|
2290
2409
|
}
|
|
2291
2410
|
}
|
|
2292
2411
|
/** @nocollapse */ DaffCartShippingMethodsEffects.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffCartShippingMethodsEffects, deps: [{ token: i1.Actions }, { token: DAFF_CART_ERROR_MATCHER }, { token: DaffCartShippingMethodsDriver }, { token: i2.DaffCartStorageService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
@@ -2309,26 +2428,26 @@ class DaffCartEffects {
|
|
|
2309
2428
|
this.errorMatcher = errorMatcher;
|
|
2310
2429
|
this.driver = driver;
|
|
2311
2430
|
this.storage = storage;
|
|
2312
|
-
this.create$ = createEffect(() => this.actions$.pipe(ofType(DaffCartActionTypes.CartCreateAction), switchMap((action) => this.driver.create().pipe(map((resp) => new DaffCartCreateSuccess(resp)),
|
|
2431
|
+
this.create$ = createEffect(() => this.actions$.pipe(ofType(DaffCartActionTypes.CartCreateAction), switchMap((action) => this.driver.create().pipe(map((resp) => new DaffCartCreateSuccess(resp)), catchAndArrayifyErrors(error => of(new DaffCartCreateFailure(error.map(this.errorMatcher))))))));
|
|
2313
2432
|
this.storeId$ = createEffect(() => this.actions$.pipe(ofType(DaffCartActionTypes.CartCreateSuccessAction, DaffCartActionTypes.ResolveCartSuccessAction), switchMap((action) => of(null).pipe(tap(() => {
|
|
2314
2433
|
this.storage.setCartId(action.payload.id);
|
|
2315
|
-
}), switchMap(() => EMPTY),
|
|
2434
|
+
}), switchMap(() => EMPTY), catchAndArrayifyErrors(error => of(new DaffCartStorageFailure(error.map(this.errorMatcher))))))));
|
|
2316
2435
|
this.get$ = createEffect(() => this.actions$.pipe(ofType(DaffCartActionTypes.CartLoadAction), switchMap((action) => defer(() => of(this.storage.getCartId())).pipe(switchMap(cartId => this.driver.get(cartId)), map(({ response, errors }) => {
|
|
2317
2436
|
if (errors.length === 0) {
|
|
2318
2437
|
return new DaffCartLoadSuccess(response);
|
|
2319
2438
|
}
|
|
2320
2439
|
const hasOnlyRecoverableErrors = errors.reduce((acc, error) => acc && error.recoverable, true);
|
|
2321
2440
|
if (hasOnlyRecoverableErrors) {
|
|
2322
|
-
return new DaffCartLoadPartialSuccess(response, errors.map(
|
|
2441
|
+
return new DaffCartLoadPartialSuccess(response, errors.map(this.errorMatcher));
|
|
2323
2442
|
}
|
|
2324
|
-
return new DaffCartLoadFailure(errors.map(
|
|
2325
|
-
}),
|
|
2326
|
-
? new DaffCartStorageFailure(this.errorMatcher
|
|
2327
|
-
: new DaffCartLoadFailure(
|
|
2328
|
-
this.addToCart$ = createEffect(() => this.actions$.pipe(ofType(DaffCartActionTypes.AddToCartAction), switchMap((action) => this.driver.addToCart(action.payload.productId, action.payload.qty).pipe(map((resp) => new DaffAddToCartSuccess(resp)),
|
|
2329
|
-
this.clear$ = createEffect(() => this.actions$.pipe(ofType(DaffCartActionTypes.CartClearAction), switchMap((action) => defer(() => of(this.storage.getCartId())).pipe(switchMap(cartId => this.driver.clear(cartId)), map((resp) => new DaffCartClearSuccess(resp)),
|
|
2330
|
-
? new DaffCartStorageFailure(this.errorMatcher
|
|
2331
|
-
: new DaffCartClearFailure(this.errorMatcher
|
|
2443
|
+
return new DaffCartLoadFailure(errors.map(this.errorMatcher));
|
|
2444
|
+
}), catchAndArrayifyErrors(error => of(error.find((err) => err.code === DAFF_STORAGE_SERVICE_ERROR_CODE)
|
|
2445
|
+
? new DaffCartStorageFailure(error.map(this.errorMatcher))
|
|
2446
|
+
: new DaffCartLoadFailure(error.map(this.errorMatcher))))))));
|
|
2447
|
+
this.addToCart$ = createEffect(() => this.actions$.pipe(ofType(DaffCartActionTypes.AddToCartAction), switchMap((action) => this.driver.addToCart(action.payload.productId, action.payload.qty).pipe(map((resp) => new DaffAddToCartSuccess(resp)), catchAndArrayifyErrors(error => of(new DaffAddToCartFailure(error.map(this.errorMatcher))))))));
|
|
2448
|
+
this.clear$ = createEffect(() => this.actions$.pipe(ofType(DaffCartActionTypes.CartClearAction), switchMap((action) => defer(() => of(this.storage.getCartId())).pipe(switchMap(cartId => this.driver.clear(cartId)), map((resp) => new DaffCartClearSuccess(resp)), catchAndArrayifyErrors(error => of(error.find((err) => err.code === DAFF_STORAGE_SERVICE_ERROR_CODE)
|
|
2449
|
+
? new DaffCartStorageFailure(error.map(this.errorMatcher))
|
|
2450
|
+
: new DaffCartClearFailure(error.map(this.errorMatcher))))))));
|
|
2332
2451
|
}
|
|
2333
2452
|
}
|
|
2334
2453
|
/** @nocollapse */ DaffCartEffects.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffCartEffects, deps: [{ token: i1.Actions }, { token: DAFF_CART_ERROR_MATCHER }, { token: DaffCartDriver }, { token: i2.DaffCartStorageService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
@@ -2353,12 +2472,65 @@ const daffCartPaymentReducer = (state = daffPaymentInitialState, action) => {
|
|
|
2353
2472
|
return adapter.tokenGenerated(state);
|
|
2354
2473
|
case DaffCartPaymentActionTypes.CartPaymentUpdateFailureAction:
|
|
2355
2474
|
case DaffCartPaymentActionTypes.CartPaymentUpdateWithBillingFailureAction:
|
|
2356
|
-
return adapter.storeError(
|
|
2475
|
+
return adapter.storeError(action.payload, state);
|
|
2357
2476
|
default:
|
|
2358
2477
|
return state;
|
|
2359
2478
|
}
|
|
2360
2479
|
};
|
|
2361
2480
|
|
|
2481
|
+
/**
|
|
2482
|
+
* A meta reducer for determining and setting the correct `daffState` values on cart items.
|
|
2483
|
+
*/
|
|
2484
|
+
function daffCartSetItemStateMetaReducer(reducer) {
|
|
2485
|
+
return (state, action) => {
|
|
2486
|
+
switch (action.type) {
|
|
2487
|
+
case DaffCartItemActionTypes.CartItemAddSuccessAction:
|
|
2488
|
+
action.payload.items = updateAddedCartItemState(state.cartItems.entities, action.payload.items.map((item) => (Object.assign(Object.assign({}, item), { daffErrors: [] }))));
|
|
2489
|
+
return reducer(state, action);
|
|
2490
|
+
case DaffCartItemActionTypes.CartItemUpdateSuccessAction:
|
|
2491
|
+
action.payload.items = updateMutatedCartItemState(action.payload.items.map((item) => item.id === action.itemId
|
|
2492
|
+
? Object.assign(Object.assign({}, item), { daffErrors: [] }) : item), state.cartItems.entities, action.itemId);
|
|
2493
|
+
return reducer(state, action);
|
|
2494
|
+
default:
|
|
2495
|
+
return reducer(state, action);
|
|
2496
|
+
}
|
|
2497
|
+
};
|
|
2498
|
+
}
|
|
2499
|
+
function updateAddedCartItemState(oldCartItems, newCartItems) {
|
|
2500
|
+
return newCartItems.map(newItem => {
|
|
2501
|
+
const oldItem = oldCartItems[newItem.id];
|
|
2502
|
+
switch (true) {
|
|
2503
|
+
case !oldItem:
|
|
2504
|
+
return Object.assign(Object.assign({}, newItem), { daffState: DaffCartItemStateEnum.New, daffErrors: [] });
|
|
2505
|
+
case (oldItem === null || oldItem === void 0 ? void 0 : oldItem.qty) !== newItem.qty:
|
|
2506
|
+
return Object.assign(Object.assign({}, newItem), { daffState: DaffCartItemStateEnum.Updated, daffErrors: [] });
|
|
2507
|
+
default:
|
|
2508
|
+
return newItem;
|
|
2509
|
+
}
|
|
2510
|
+
});
|
|
2511
|
+
}
|
|
2512
|
+
function updateMutatedCartItemState(responseItems, stateItems, itemId) {
|
|
2513
|
+
return responseItems.map(item => {
|
|
2514
|
+
var _a;
|
|
2515
|
+
return item.id === itemId ? Object.assign(Object.assign({}, item), { daffState: DaffCartItemStateEnum.Updated, daffErrors: [] }) : Object.assign(Object.assign({}, item), { daffState: ((_a = stateItems[item.id]) === null || _a === void 0 ? void 0 : _a.daffState) || DaffCartItemStateEnum.Default });
|
|
2516
|
+
});
|
|
2517
|
+
}
|
|
2518
|
+
|
|
2519
|
+
/**
|
|
2520
|
+
* An internal token to hold the Daffodil cart feature store config.
|
|
2521
|
+
*
|
|
2522
|
+
* @docs-private
|
|
2523
|
+
*/
|
|
2524
|
+
const DAFF_CART_STORE_CONFIG = new InjectionToken('DAFF_CART_STORE_CONFIG', {
|
|
2525
|
+
providedIn: 'any',
|
|
2526
|
+
factory: () => ({
|
|
2527
|
+
metaReducers: [
|
|
2528
|
+
daffCartSetItemStateMetaReducer,
|
|
2529
|
+
...inject(DAFF_CART_META_REDUCERS),
|
|
2530
|
+
],
|
|
2531
|
+
}),
|
|
2532
|
+
});
|
|
2533
|
+
|
|
2362
2534
|
/**
|
|
2363
2535
|
* An internal token to hold the Daffodil cart reducers.
|
|
2364
2536
|
* Includes the extra and standard reducers.
|
|
@@ -2366,10 +2538,21 @@ const daffCartPaymentReducer = (state = daffPaymentInitialState, action) => {
|
|
|
2366
2538
|
* @docs-private
|
|
2367
2539
|
*/
|
|
2368
2540
|
const DAFF_CART_REDUCERS = new InjectionToken('DAFF_CART_REDUCERS', {
|
|
2369
|
-
factory: () =>
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2541
|
+
factory: () => {
|
|
2542
|
+
const retrievalActions = inject(DAFF_CART_RETRIEVAL_ACTIONS);
|
|
2543
|
+
return daffComposeReducers([
|
|
2544
|
+
// daffodil reducers should run first, don't change this
|
|
2545
|
+
// TODO: enforce this somehow (meta-reducers?)
|
|
2546
|
+
combineReducers(daffCartReducers),
|
|
2547
|
+
//
|
|
2548
|
+
combineReducers({
|
|
2549
|
+
cart: daffCartRetrievalActionsReducerFactory(retrievalActions),
|
|
2550
|
+
cartItems: daffCartItemEntitiesRetrievalActionsReducerFactory(retrievalActions),
|
|
2551
|
+
order: daffIdentityReducer,
|
|
2552
|
+
}),
|
|
2553
|
+
...inject(DAFF_CART_EXTRA_REDUCERS),
|
|
2554
|
+
]);
|
|
2555
|
+
},
|
|
2373
2556
|
});
|
|
2374
2557
|
|
|
2375
2558
|
class DaffCartStateModule {
|
|
@@ -2381,7 +2564,8 @@ class DaffCartStateModule {
|
|
|
2381
2564
|
...daffPaymentProvideExtraReducers(combineReducers({
|
|
2382
2565
|
payment: daffCartPaymentReducer,
|
|
2383
2566
|
})),
|
|
2384
|
-
|
|
2567
|
+
daffCartProvideRetrievalActions(...daffCartRetrivalActions),
|
|
2568
|
+
], imports: [StoreModule.forFeature(DAFF_CART_STORE_FEATURE_KEY, DAFF_CART_REDUCERS, DAFF_CART_STORE_CONFIG),
|
|
2385
2569
|
EffectsModule.forFeature([
|
|
2386
2570
|
DaffCartEffects,
|
|
2387
2571
|
DaffCartItemEffects,
|
|
@@ -2401,7 +2585,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
2401
2585
|
type: NgModule,
|
|
2402
2586
|
args: [{
|
|
2403
2587
|
imports: [
|
|
2404
|
-
StoreModule.forFeature(DAFF_CART_STORE_FEATURE_KEY, DAFF_CART_REDUCERS),
|
|
2588
|
+
StoreModule.forFeature(DAFF_CART_STORE_FEATURE_KEY, DAFF_CART_REDUCERS, DAFF_CART_STORE_CONFIG),
|
|
2405
2589
|
EffectsModule.forFeature([
|
|
2406
2590
|
DaffCartEffects,
|
|
2407
2591
|
DaffCartItemEffects,
|
|
@@ -2423,6 +2607,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
2423
2607
|
...daffPaymentProvideExtraReducers(combineReducers({
|
|
2424
2608
|
payment: daffCartPaymentReducer,
|
|
2425
2609
|
})),
|
|
2610
|
+
daffCartProvideRetrievalActions(...daffCartRetrivalActions),
|
|
2426
2611
|
],
|
|
2427
2612
|
}]
|
|
2428
2613
|
}] });
|
|
@@ -2588,5 +2773,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
2588
2773
|
* Generated bundle index. Do not edit.
|
|
2589
2774
|
*/
|
|
2590
2775
|
|
|
2591
|
-
export { DAFF_CART_EXTRA_REDUCERS, DAFF_CART_STORE_FEATURE_KEY, DaffAddToCart, DaffAddToCartFailure, DaffAddToCartSuccess, DaffCartActionTypes, DaffCartAddressActionTypes, DaffCartAddressUpdate, DaffCartAddressUpdateFailure, DaffCartAddressUpdateSuccess, DaffCartBillingAddressActionTypes, DaffCartBillingAddressLoad, DaffCartBillingAddressLoadFailure, DaffCartBillingAddressLoadSuccess, DaffCartBillingAddressUpdate, DaffCartBillingAddressUpdateFailure, DaffCartBillingAddressUpdateSuccess, DaffCartClear, DaffCartClearFailure, DaffCartClearSuccess, DaffCartCouponActionTypes, DaffCartCouponApply, DaffCartCouponApplyFailure, DaffCartCouponApplySuccess, DaffCartCouponClearErrors, DaffCartCouponList, DaffCartCouponListFailure, DaffCartCouponListSuccess, DaffCartCouponRemove, DaffCartCouponRemoveAll, DaffCartCouponRemoveAllFailure, DaffCartCouponRemoveAllSuccess, DaffCartCouponRemoveFailure, DaffCartCouponRemoveSuccess, DaffCartCreate, DaffCartCreateFailure, DaffCartCreateSuccess, DaffCartFacade, DaffCartItemActionTypes, DaffCartItemAdd, DaffCartItemAddFailure, DaffCartItemAddSuccess, DaffCartItemDelete, DaffCartItemDeleteFailure, DaffCartItemDeleteOutOfStock, DaffCartItemDeleteOutOfStockFailure, DaffCartItemDeleteOutOfStockSuccess, DaffCartItemDeleteSuccess, DaffCartItemList, DaffCartItemListFailure, DaffCartItemListSuccess, DaffCartItemLoad, DaffCartItemLoadFailure, DaffCartItemLoadSuccess, DaffCartItemStateDebounceTime, DaffCartItemStateEnum, DaffCartItemStateReset, DaffCartItemUpdate, DaffCartItemUpdateFailure, DaffCartItemUpdateSuccess, DaffCartLoad, DaffCartLoadFailure, DaffCartLoadPartialSuccess, DaffCartLoadSuccess, DaffCartOperationType, DaffCartOrderActionTypes, DaffCartPaymentActionTypes, DaffCartPaymentLoad, DaffCartPaymentLoadFailure, DaffCartPaymentLoadSuccess, DaffCartPaymentMethodAdd, DaffCartPaymentMethodsActionTypes, DaffCartPaymentMethodsLoad, DaffCartPaymentMethodsLoadFailure, DaffCartPaymentMethodsLoadSuccess, DaffCartPaymentRemove, DaffCartPaymentRemoveFailure, DaffCartPaymentRemoveSuccess, DaffCartPaymentUpdate, DaffCartPaymentUpdateFailure, DaffCartPaymentUpdateSuccess, DaffCartPaymentUpdateWithBilling, DaffCartPaymentUpdateWithBillingFailure, DaffCartPaymentUpdateWithBillingSuccess, DaffCartPlaceOrder, DaffCartPlaceOrderFailure, DaffCartPlaceOrderSuccess, DaffCartResolveState, DaffCartShippingAddressActionTypes, DaffCartShippingAddressLoad, DaffCartShippingAddressLoadFailure, DaffCartShippingAddressLoadSuccess, DaffCartShippingAddressUpdate, DaffCartShippingAddressUpdateFailure, DaffCartShippingAddressUpdateSuccess, DaffCartShippingInformationActionTypes, DaffCartShippingInformationDelete, DaffCartShippingInformationDeleteFailure, DaffCartShippingInformationDeleteSuccess, DaffCartShippingInformationLoad, DaffCartShippingInformationLoadFailure, DaffCartShippingInformationLoadSuccess, DaffCartShippingInformationUpdate, DaffCartShippingInformationUpdateFailure, DaffCartShippingInformationUpdateSuccess, DaffCartShippingMethodsActionTypes, DaffCartShippingMethodsLoad, DaffCartShippingMethodsLoadFailure, DaffCartShippingMethodsLoadSuccess, DaffCartStateModule, DaffCartStorageFailure, DaffResolveCart, DaffResolveCartFailure, DaffResolveCartPartialSuccess, DaffResolveCartServerSide, DaffResolveCartSuccess, daffCartItemEntitiesAdapter, daffCartOrderInitialState, daffCartOrderReducer, daffCartProvideExtraReducers, daffCartReducer, daffCartReducerInitialState, daffCartReducers, getDaffCartSelectors, initializeLoadingSetter };
|
|
2776
|
+
export { DAFF_CART_ERROR_MATCHER, DAFF_CART_EXTRA_REDUCERS, DAFF_CART_META_REDUCERS, DAFF_CART_RETRIEVAL_ACTIONS, DAFF_CART_STORE_FEATURE_KEY, DaffAddToCart, DaffAddToCartFailure, DaffAddToCartSuccess, DaffCartActionTypes, DaffCartAddressActionTypes, DaffCartAddressUpdate, DaffCartAddressUpdateFailure, DaffCartAddressUpdateSuccess, DaffCartBillingAddressActionTypes, DaffCartBillingAddressLoad, DaffCartBillingAddressLoadFailure, DaffCartBillingAddressLoadSuccess, DaffCartBillingAddressUpdate, DaffCartBillingAddressUpdateFailure, DaffCartBillingAddressUpdateSuccess, DaffCartClear, DaffCartClearFailure, DaffCartClearSuccess, DaffCartCouponActionTypes, DaffCartCouponApply, DaffCartCouponApplyFailure, DaffCartCouponApplySuccess, DaffCartCouponClearErrors, DaffCartCouponList, DaffCartCouponListFailure, DaffCartCouponListSuccess, DaffCartCouponRemove, DaffCartCouponRemoveAll, DaffCartCouponRemoveAllFailure, DaffCartCouponRemoveAllSuccess, DaffCartCouponRemoveFailure, DaffCartCouponRemoveSuccess, DaffCartCreate, DaffCartCreateFailure, DaffCartCreateSuccess, DaffCartFacade, DaffCartItemActionTypes, DaffCartItemAdd, DaffCartItemAddFailure, DaffCartItemAddSuccess, DaffCartItemDelete, DaffCartItemDeleteFailure, DaffCartItemDeleteOutOfStock, DaffCartItemDeleteOutOfStockFailure, DaffCartItemDeleteOutOfStockSuccess, DaffCartItemDeleteSuccess, DaffCartItemList, DaffCartItemListFailure, DaffCartItemListSuccess, DaffCartItemLoad, DaffCartItemLoadFailure, DaffCartItemLoadSuccess, DaffCartItemStateDebounceTime, DaffCartItemStateEnum, DaffCartItemStateReset, DaffCartItemUpdate, DaffCartItemUpdateFailure, DaffCartItemUpdateSuccess, DaffCartLoad, DaffCartLoadFailure, DaffCartLoadPartialSuccess, DaffCartLoadSuccess, DaffCartOperationType, DaffCartOrderActionTypes, DaffCartPaymentActionTypes, DaffCartPaymentLoad, DaffCartPaymentLoadFailure, DaffCartPaymentLoadSuccess, DaffCartPaymentMethodAdd, DaffCartPaymentMethodsActionTypes, DaffCartPaymentMethodsLoad, DaffCartPaymentMethodsLoadFailure, DaffCartPaymentMethodsLoadSuccess, DaffCartPaymentRemove, DaffCartPaymentRemoveFailure, DaffCartPaymentRemoveSuccess, DaffCartPaymentUpdate, DaffCartPaymentUpdateFailure, DaffCartPaymentUpdateSuccess, DaffCartPaymentUpdateWithBilling, DaffCartPaymentUpdateWithBillingFailure, DaffCartPaymentUpdateWithBillingSuccess, DaffCartPlaceOrder, DaffCartPlaceOrderFailure, DaffCartPlaceOrderSuccess, DaffCartResolveState, DaffCartShippingAddressActionTypes, DaffCartShippingAddressLoad, DaffCartShippingAddressLoadFailure, DaffCartShippingAddressLoadSuccess, DaffCartShippingAddressUpdate, DaffCartShippingAddressUpdateFailure, DaffCartShippingAddressUpdateSuccess, DaffCartShippingInformationActionTypes, DaffCartShippingInformationDelete, DaffCartShippingInformationDeleteFailure, DaffCartShippingInformationDeleteSuccess, DaffCartShippingInformationLoad, DaffCartShippingInformationLoadFailure, DaffCartShippingInformationLoadSuccess, DaffCartShippingInformationUpdate, DaffCartShippingInformationUpdateFailure, DaffCartShippingInformationUpdateSuccess, DaffCartShippingMethodsActionTypes, DaffCartShippingMethodsLoad, DaffCartShippingMethodsLoadFailure, DaffCartShippingMethodsLoadSuccess, DaffCartStateModule, DaffCartStorageFailure, DaffResolveCart, DaffResolveCartFailure, DaffResolveCartPartialSuccess, DaffResolveCartServerSide, DaffResolveCartSuccess, daffCartItemEntitiesAdapter, daffCartItemEntitiesRetrievalActionsReducerFactory, daffCartOrderInitialState, daffCartOrderReducer, daffCartProvideExtraReducers, daffCartProvideMetaReducers, daffCartProvideRetrievalActions, daffCartReducer, daffCartReducerInitialState, daffCartReducers, daffCartRetrievalActionsReducerFactory, daffCartRetrievalGetResponse, daffCartRetrivalActions, getDaffCartSelectors, initializeLoadingSetter };
|
|
2592
2777
|
//# sourceMappingURL=daffodil-cart-state.mjs.map
|