Skip to content

Commit

Permalink
feat: display loading overlay for basket merge
Browse files Browse the repository at this point in the history
  • Loading branch information
dhhyi authored and SGrueber committed Apr 21, 2022
1 parent 722e760 commit 811b540
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/app/core/store/customer/basket/basket.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ export const addItemsToBasketSuccess = createAction(
payload<{ info: BasketInfo[]; items: SkuQuantityType[] }>()
);

export const mergeBasketInProgress = createAction('[Basket API] Merge two baskets in progress');

export const mergeBasketFail = createAction('[Basket API] Merge two baskets Fail', httpError());

export const mergeBasketSuccess = createAction('[Basket API] Merge two baskets Success', payload<{ basket: Basket }>());
Expand Down
4 changes: 3 additions & 1 deletion src/app/core/store/customer/basket/basket.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import {
loadBasketSuccess,
loadBasketWithId,
mergeBasketFail,
mergeBasketInProgress,
mergeBasketSuccess,
resetBasketErrors,
setBasketAttribute,
Expand Down Expand Up @@ -278,7 +279,8 @@ export class BasketEffects {
.mergeBasket(sourceBasketId, sourceApiToken, newOrCurrentUserBasket.id)
.pipe(map(basket => mergeBasketSuccess({ basket })))
),
mapErrorToAction(mergeBasketFail)
mapErrorToAction(mergeBasketFail),
startWith(mergeBasketInProgress())
);
} else if (baskets.length) {
// no anonymous basket exists and user already has a basket -> load it
Expand Down
4 changes: 3 additions & 1 deletion src/app/core/store/customer/basket/basket.reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import {
loadBasketSuccess,
loadBasketWithId,
mergeBasketFail,
mergeBasketInProgress,
mergeBasketSuccess,
removePromotionCodeFromBasket,
removePromotionCodeFromBasketFail,
Expand Down Expand Up @@ -134,7 +135,8 @@ export const basketReducer = createReducer(
deleteBasketPayment,
submitBasket,
updateConcardisCvcLastUpdated,
startCheckout
startCheckout,
mergeBasketInProgress
),
unsetLoadingOn(addPromotionCodeToBasketSuccess, addPromotionCodeToBasketFail),
unsetLoadingAndErrorOn(
Expand Down
4 changes: 2 additions & 2 deletions src/app/core/store/customer/customer-store.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { UserService } from 'ish-core/services/user/user.service';
import { CoreStoreModule } from 'ish-core/store/core/core-store.module';
import { CustomerStoreModule } from 'ish-core/store/customer/customer-store.module';
import { loadProductSuccess } from 'ish-core/store/shopping/products';
import { SHOPPING_STORE_CONFIG, ShoppingStoreModule } from 'ish-core/store/shopping/shopping-store.module';
import { ShoppingStoreModule } from 'ish-core/store/shopping/shopping-store.module';
import { CookiesService } from 'ish-core/utils/cookies/cookies.service';
import { StoreWithSnapshots, provideStoreSnapshots } from 'ish-core/utils/dev/ngrx-testing';
import { categoryTree } from 'ish-core/utils/dev/test-data-utils';
Expand Down Expand Up @@ -179,7 +179,6 @@ describe('Customer Store', () => {
{ provide: PricesService, useFactory: () => instance(productPriceServiceMock) },
{ provide: ProductsService, useFactory: () => instance(productsServiceMock) },
{ provide: PromotionsService, useFactory: () => instance(promotionsServiceMock) },
{ provide: SHOPPING_STORE_CONFIG, useValue: {} },
{ provide: SuggestService, useFactory: () => instance(mock(SuggestService)) },
{ provide: UserService, useFactory: () => instance(userServiceMock) },
provideStoreSnapshots(),
Expand Down Expand Up @@ -225,6 +224,7 @@ describe('Customer Store', () => {
[User API] Login User Success:
customer: {"isBusinessCustomer":false,"customerNo":"test"}
user: {"title":"","firstName":"test","lastName":"test","phoneHome"...
[Basket API] Merge two baskets in progress
[Basket API] Merge two baskets Success:
basket: {"id":"test","lineItems":[1]}
`);
Expand Down

0 comments on commit 811b540

Please sign in to comment.