Skip to content

Commit

Permalink
Merge branch 'epic/product-configuration' into feature/GH-8835-move-c…
Browse files Browse the repository at this point in the history
…onnectors-adapters
  • Loading branch information
ChristophHi committed Sep 11, 2020
2 parents 18d65f1 + e6c3f95 commit 6e0b5f7
Show file tree
Hide file tree
Showing 71 changed files with 246 additions and 1,161 deletions.
2 changes: 1 addition & 1 deletion projects/core/public_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export * from './src/global-message/index';
export * from './src/i18n/index';
export * from './src/kyma/index';
export * from './src/model/index';
export * from './src/organization/index';
export * from './src/cost-center/index';
export * from './src/occ/index';
export * from './src/personalization/index';
export * from './src/process/index';
Expand Down
8 changes: 3 additions & 5 deletions projects/core/src/checkout/store/effects/checkout.effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { GlobalMessageActions } from '../../../global-message/store/actions/inde
import { OCC_USER_ID_ANONYMOUS } from '../../../occ/utils/occ-constants';
import { SiteContextActions } from '../../../site-context/store/actions/index';
import { UserActions } from '../../../user/store/actions/index';
import { normalizeHttpError } from '../../../util/normalize-http-error';
import { makeErrorSerializable } from '../../../util/serialization-utils';
import { withdrawOn } from '../../../util/withdraw-on';
import { CheckoutConnector } from '../../connectors/checkout/checkout.connector';
Expand Down Expand Up @@ -430,6 +431,7 @@ export class CheckoutEffects {
.setCostCenter(payload.userId, payload.cartId, payload.costCenterId)
.pipe(
mergeMap((data) => [
// TODO(#8877): We should trigger load cart not already assign the data. We might have misconfiguration between this cart model and load cart model
new CartActions.LoadCartSuccess({
cart: data,
cartId: payload.cartId,
Expand All @@ -446,11 +448,7 @@ export class CheckoutEffects {
}),
]),
catchError((error) =>
of(
new CheckoutActions.SetCostCenterFail(
makeErrorSerializable(error)
)
)
of(new CheckoutActions.SetCostCenterFail(normalizeHttpError(error)))
)
);
}),
Expand Down
10 changes: 3 additions & 7 deletions projects/core/src/checkout/store/effects/payment-types.effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Actions, Effect, ofType } from '@ngrx/effects';
import { Observable, of } from 'rxjs';
import { catchError, map, mergeMap, switchMap } from 'rxjs/operators';
import { CartActions } from '../../../cart/store/actions/index';
import { makeErrorSerializable } from '../../../util/serialization-utils';
import { normalizeHttpError } from '../../../util/normalize-http-error';
import { PaymentTypeConnector } from '../../connectors/payment-type/payment-type.connector';
import { CheckoutActions } from '../actions/index';

Expand All @@ -23,9 +23,7 @@ export class PaymentTypesEffects {
),
catchError((error) =>
of(
new CheckoutActions.LoadPaymentTypesFail(
makeErrorSerializable(error)
)
new CheckoutActions.LoadPaymentTypesFail(normalizeHttpError(error))
)
)
);
Expand Down Expand Up @@ -63,9 +61,7 @@ export class PaymentTypesEffects {
}),
catchError((error) =>
of(
new CheckoutActions.SetPaymentTypeFail(
makeErrorSerializable(error)
)
new CheckoutActions.SetPaymentTypeFail(normalizeHttpError(error))
)
)
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from './budget/index';
export * from './cost-center/index';
11 changes: 11 additions & 0 deletions projects/core/src/cost-center/cost-center.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { ModuleWithProviders, NgModule } from '@angular/core';

@NgModule({})
export class CostCenterModule {
static forRoot(): ModuleWithProviders<CostCenterModule> {
return {
ngModule: CostCenterModule,
providers: [],
};
}
}
2 changes: 2 additions & 0 deletions projects/core/src/cost-center/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './connectors/index';
export * from './cost-center.module';
15 changes: 0 additions & 15 deletions projects/core/src/model/budget.model.ts

This file was deleted.

9 changes: 2 additions & 7 deletions projects/core/src/model/cart.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
PickupOrderEntryGroup,
PromotionOrderEntryConsumed,
} from './order.model';
import { Price, Promotion } from './product.model';
import { CostCenter } from './org-unit.model';
import { Price, Promotion } from './product.model';

export interface PromotionResult {
consumedEntries?: PromotionOrderEntryConsumed[];
Expand Down Expand Up @@ -82,11 +82,6 @@ export interface SaveCartResult {
savedCartData?: Cart;
}

export interface B2BPaymentType {
code?: string;
displayName?: string;
}

export interface Cart {
appliedOrderPromotions?: PromotionResult[];
appliedProductPromotions?: PromotionResult[];
Expand All @@ -107,7 +102,7 @@ export interface Cart {
net?: boolean;
orderDiscounts?: Price;
paymentInfo?: PaymentDetails;
paymentType?: B2BPaymentType;
paymentType?: PaymentType;
pickupItemsQuantity?: number;
pickupOrderGroups?: PickupOrderEntryGroup[];
potentialOrderPromotions?: PromotionResult[];
Expand Down
7 changes: 1 addition & 6 deletions projects/core/src/model/misc.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,7 @@ export interface User {
uid?: string;
}

export interface ListModel {
ids: string[];
pagination?: PaginationModel;
sorts?: SortModel[];
}

// TODO(#8875): Do we need it here?
export interface EntitiesModel<T> {
values: T[];
pagination?: PaginationModel;
Expand Down
9 changes: 1 addition & 8 deletions projects/core/src/model/org-unit.model.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Currency, User } from './misc.model';

// TODO(#8876): Should we simplify the models only for the fields required by the B2B checkout?
export interface CostCenter {
active?: string;
activeFlag?: boolean;
Expand All @@ -10,14 +11,6 @@ export interface CostCenter {
currency?: Currency;
}

export interface B2BUnitNode {
active?: boolean;
children?: B2BUnitNode[];
id?: string;
name?: string;
parent?: string;
}

export interface B2BUnit {
active?: boolean;
addresses?: B2BAddress[];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { HttpClient, HttpParams } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { Cart } from '../../../model/cart.model';
import { CART_NORMALIZER } from '../../../cart/connectors/cart/converters';
import { CheckoutCostCenterAdapter } from '../../../checkout/connectors/cost-center/checkout-cost-center.adapter';
import { Cart } from '../../../model/cart.model';
import { ConverterService } from '../../../util/converter.service';
import { OccEndpointsService } from '../../services/occ-endpoints.service';
import { CART_NORMALIZER } from '../../../cart/connectors/cart/converters';

@Injectable()
export class OccCheckoutCostCenterAdapter implements CheckoutCostCenterAdapter {
Expand All @@ -26,6 +26,7 @@ export class OccCheckoutCostCenterAdapter implements CheckoutCostCenterAdapter {
'fields',
'DEFAULT,potentialProductPromotions,appliedProductPromotions,potentialOrderPromotions,appliedOrderPromotions,entries(totalPrice(formattedValue),product(images(FULL),stock(FULL)),basePrice(formattedValue,value),updateable),totalPrice(formattedValue),totalItems,totalPriceWithTax(formattedValue),totalDiscounts(value,formattedValue),subTotal(formattedValue),deliveryItemsQuantity,deliveryCost(formattedValue),totalTax(formattedValue, value),pickupItemsQuantity,net,appliedVouchers,productDiscounts(formattedValue),user'
);
// TODO(#8877): Should we improve configurable endpoints for this use case?

return this.http
.put(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { HttpClient, HttpParams } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { PaymentTypeAdapter } from '../../../checkout/connectors/payment-type/payment-type.adapter';
import { CART_NORMALIZER } from '../../../cart/connectors/cart/converters';
import { PAYMENT_TYPE_NORMALIZER } from '../../../checkout/connectors/payment-type/converters';
import { PaymentType, Cart } from '../../../model/cart.model';
import { PaymentTypeAdapter } from '../../../checkout/connectors/payment-type/payment-type.adapter';
import { Cart, PaymentType } from '../../../model/cart.model';
import { ConverterService } from '../../../util/converter.service';
import { Occ } from '../../occ-models';
import { OccEndpointsService } from '../../services/occ-endpoints.service';
import { CART_NORMALIZER } from '../../../cart/connectors/cart/converters';

const ENDPOINT_PAYMENT_TYPES = 'paymenttypes';

Expand Down Expand Up @@ -46,6 +46,7 @@ export class OccCheckoutPaymentTypeAdapter implements PaymentTypeAdapter {
'fields',
'DEFAULT,potentialProductPromotions,appliedProductPromotions,potentialOrderPromotions,appliedOrderPromotions,entries(totalPrice(formattedValue),product(images(FULL),stock(FULL)),basePrice(formattedValue,value),updateable),totalPrice(formattedValue),totalItems,totalPriceWithTax(formattedValue),totalDiscounts(value,formattedValue),subTotal(formattedValue),deliveryItemsQuantity,deliveryCost(formattedValue),totalTax(formattedValue, value),pickupItemsQuantity,net,appliedVouchers,productDiscounts(formattedValue),user'
);
// TODO(#8877): Should we improve configurable endpoints for this use case?

return this.http
.put(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Injectable } from '@angular/core';
import { Occ } from '../../../occ-models/occ.models';
import { COST_CENTER_NORMALIZER } from '../../../../cost-center/connectors/cost-center/converters';
import { EntitiesModel } from '../../../../model/misc.model';
import { CostCenter } from '../../../../model/org-unit.model';
import {
Converter,
ConverterService,
} from '../../../../util/converter.service';
import { COST_CENTER_NORMALIZER } from '../../../../organization/connectors/cost-center/converters';
import { EntitiesModel } from '../../../../model/misc.model';
import { CostCenter } from '../../../../model/org-unit.model';
import { Occ } from '../../../occ-models/occ.models';

@Injectable()
export class OccCostCenterListNormalizer
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { ConfigModule } from '../../../config/config.module';
import { COST_CENTERS_NORMALIZER } from '../../../cost-center/connectors/cost-center/converters';
import { OccCostCenterListNormalizer } from './converters/occ-cost-center-list-normalizer';
import { defaultOccCostCentersConfig } from './default-occ-cost-centers-config';

@NgModule({
imports: [CommonModule, ConfigModule.withConfig(defaultOccCostCentersConfig)],
providers: [
{
provide: COST_CENTERS_NORMALIZER,
useClass: OccCostCenterListNormalizer,
multi: true,
},
],
})
export class CostCenterOccModule {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { OccConfig } from '../../config/occ-config';

export const defaultOccCostCentersConfig: OccConfig = {
backend: {
occ: {
endpoints: {
costCenters: '/costcenters',
},
},
},
};
2 changes: 2 additions & 0 deletions projects/core/src/occ/adapters/cost-center/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './converters/index';
export * from './cost-center-occ.module';
1 change: 1 addition & 0 deletions projects/core/src/occ/adapters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export * from './asm/index';
export * from './cart/index';
export * from './checkout/index';
export * from './cms/index';
export * from './cost-center/index';
export * from './product/index';
export * from './site-context/index';
export * from './store-finder/index';
Expand Down

This file was deleted.

3 changes: 0 additions & 3 deletions projects/core/src/occ/adapters/organization/index.ts

This file was deleted.

Loading

0 comments on commit 6e0b5f7

Please sign in to comment.