Skip to content

Commit

Permalink
refactor: perform action creator migration
Browse files Browse the repository at this point in the history
BREAKING CHANGE: NgRx code artifacts are transformed to a new pattern, follow the instructions in the migration guide.
  • Loading branch information
ISSupport authored and dhhyi committed Jun 15, 2020
1 parent 6324ebe commit 31acf5d
Show file tree
Hide file tree
Showing 190 changed files with 7,180 additions and 8,021 deletions.
4 changes: 2 additions & 2 deletions src/app/core/configurations/configuration.meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Params } from '@angular/router';
import { RouterNavigationPayload, routerNavigationAction } from '@ngrx/router-store';
import { ActionReducer } from '@ngrx/store';

import { ApplyConfiguration } from 'ish-core/store/core/configuration';
import { applyConfiguration } from 'ish-core/store/core/configuration';
import { ConfigurationState, configurationReducer } from 'ish-core/store/core/configuration/configuration.reducer';
import { CoreState } from 'ish-core/store/core/core-store';
import { RouterState } from 'ish-core/store/core/router/router.reducer';
Expand Down Expand Up @@ -42,7 +42,7 @@ function extractConfigurationParameters(state: ConfigurationState, paramMap: Sim
}

if (Object.keys(properties).length) {
return configurationReducer(state, new ApplyConfiguration(properties));
return configurationReducer(state, applyConfiguration(properties));
}
return state;
}
Expand Down
70 changes: 35 additions & 35 deletions src/app/core/facades/account.facade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,17 @@ import { PasswordReminderUpdate } from 'ish-core/models/password-reminder-update
import { PasswordReminder } from 'ish-core/models/password-reminder/password-reminder.model';
import { User } from 'ish-core/models/user/user.model';
import {
CreateCustomerAddress,
DeleteCustomerAddress,
LoadAddresses,
createCustomerAddress,
deleteCustomerAddress,
getAddressesError,
getAddressesLoading,
getAllAddresses,
loadAddresses,
} from 'ish-core/store/customer/addresses';
import { LoadOrders, getOrders, getOrdersLoading, getSelectedOrder } from 'ish-core/store/customer/orders';
import { getOrders, getOrdersLoading, getSelectedOrder, loadOrders } from 'ish-core/store/customer/orders';
import {
CreateUser,
DeleteUserPaymentInstrument,
LoadUserPaymentMethods,
LoginUser,
RequestPasswordReminder,
ResetPasswordReminder,
UpdateCustomer,
UpdateUser,
UpdateUserPassword,
UpdateUserPasswordByPasswordReminder,
createUser,
deleteUserPaymentInstrument,
getLoggedInCustomer,
getLoggedInUser,
getPasswordReminderError,
Expand All @@ -39,13 +31,21 @@ import {
getUserLoading,
getUserPaymentMethods,
isBusinessCustomer,
loadUserPaymentMethods,
loginUser,
requestPasswordReminder,
resetPasswordReminder,
updateCustomer,
updateUser,
updateUserPassword,
updateUserPasswordByPasswordReminder,
} from 'ish-core/store/customer/user';
import {
CreateContact,
LoadContact,
createContact,
getContactLoading,
getContactSubjects,
getContactSuccess,
loadContact,
} from 'ish-core/store/general/contact';
import { whenTruthy } from 'ish-core/utils/operators';

Expand All @@ -62,20 +62,20 @@ export class AccountFacade {
isLoggedIn$ = this.store.pipe(select(getUserAuthorized));

loginUser(credentials: Credentials) {
this.store.dispatch(new LoginUser({ credentials }));
this.store.dispatch(loginUser({ credentials }));
}

createUser(body: CustomerRegistrationType) {
this.store.dispatch(new CreateUser(body));
this.store.dispatch(createUser(body));
}

updateUser(user: User, successMessage?: string, successRouterLink?: string) {
this.store.dispatch(new UpdateUser({ user, successMessage, successRouterLink }));
this.store.dispatch(updateUser({ user, successMessage, successRouterLink }));
}

updateUserEmail(user: User) {
this.store.dispatch(
new UpdateUser({
updateUser({
user,
successMessage: 'account.profile.update_email.message',
successRouterLink: '/account/profile',
Expand All @@ -84,12 +84,12 @@ export class AccountFacade {
}

updateUserPassword(data: { password: string; currentPassword: string }) {
this.store.dispatch(new UpdateUserPassword(data));
this.store.dispatch(updateUserPassword(data));
}

updateUserProfile(user: User) {
this.store.dispatch(
new UpdateUser({
updateUser({
user,
successMessage: 'account.profile.update_profile.message',
successRouterLink: '/account/profile',
Expand All @@ -105,7 +105,7 @@ export class AccountFacade {

updateCustomerProfile(customer: Customer, message?: string) {
this.store.dispatch(
new UpdateCustomer({
updateCustomer({
customer,
successMessage: message ? message : 'account.profile.update_profile.message',
successRouterLink: '/account/profile',
Expand All @@ -119,21 +119,21 @@ export class AccountFacade {
passwordReminderError$ = this.store.pipe(select(getPasswordReminderError));

resetPasswordReminder() {
this.store.dispatch(new ResetPasswordReminder());
this.store.dispatch(resetPasswordReminder());
}

requestPasswordReminder(data: PasswordReminder) {
this.store.dispatch(new RequestPasswordReminder({ data }));
this.store.dispatch(requestPasswordReminder({ data }));
}

requestPasswordReminderUpdate(data: PasswordReminderUpdate) {
this.store.dispatch(new UpdateUserPasswordByPasswordReminder(data));
this.store.dispatch(updateUserPasswordByPasswordReminder(data));
}

// ORDERS

orders$() {
this.store.dispatch(new LoadOrders());
this.store.dispatch(loadOrders());
return this.store.pipe(select(getOrders));
}

Expand All @@ -145,12 +145,12 @@ export class AccountFacade {
private eligiblePaymentMethods$ = this.store.pipe(select(getUserPaymentMethods));

paymentMethods$() {
this.store.dispatch(new LoadUserPaymentMethods());
this.store.dispatch(loadUserPaymentMethods());
return this.eligiblePaymentMethods$;
}

deletePaymentInstrument(paymentInstrumentId: string) {
this.store.dispatch(new DeleteUserPaymentInstrument({ id: paymentInstrumentId }));
this.store.dispatch(deleteUserPaymentInstrument({ id: paymentInstrumentId }));
}

// ADDRESSES
Expand All @@ -159,34 +159,34 @@ export class AccountFacade {
return this.user$.pipe(
whenTruthy(),
take(1),
tap(() => this.store.dispatch(new LoadAddresses())),
tap(() => this.store.dispatch(loadAddresses())),
switchMap(() => this.store.pipe(select(getAllAddresses)))
);
}
addressesLoading$ = this.store.pipe(select(getAddressesLoading));
addressesError$ = this.store.pipe(select(getAddressesError));

createCustomerAddress(address: Address) {
this.store.dispatch(new CreateCustomerAddress({ address }));
this.store.dispatch(createCustomerAddress({ address }));
}

deleteCustomerAddress(addressId: string) {
this.store.dispatch(new DeleteCustomerAddress({ addressId }));
this.store.dispatch(deleteCustomerAddress({ addressId }));
}

// CONTACT US

contactSubjects$() {
this.store.dispatch(new LoadContact());
this.store.dispatch(loadContact());
return this.store.pipe(select(getContactSubjects));
}
contactLoading$ = this.store.pipe(select(getContactLoading));
contactSuccess$ = this.store.pipe(select(getContactSuccess));

resetContactState() {
this.store.dispatch(new LoadContact());
this.store.dispatch(loadContact());
}
createContact(contact: Contact) {
this.store.dispatch(new CreateContact({ contact }));
this.store.dispatch(createContact({ contact }));
}
}
8 changes: 4 additions & 4 deletions src/app/core/facades/app.facade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { filter, map, mapTo, shareReplay, startWith } from 'rxjs/operators';
import { getAvailableLocales, getCurrentLocale, getDeviceType, getICMBaseURL } from 'ish-core/store/core/configuration';
import { getGeneralError, getGeneralErrorType } from 'ish-core/store/core/error';
import { getBreadcrumbData, getHeaderType, getWrapperClass, isStickyHeader } from 'ish-core/store/core/viewconf';
import { LoadCountries, getAllCountries, getCountriesLoading } from 'ish-core/store/general/countries';
import { LoadRegions, getRegionsByCountryCode } from 'ish-core/store/general/regions';
import { getAllCountries, getCountriesLoading, loadCountries } from 'ish-core/store/general/countries';
import { getRegionsByCountryCode, loadRegions } from 'ish-core/store/general/regions';

@Injectable({ providedIn: 'root' })
export class AppFacade {
Expand Down Expand Up @@ -64,12 +64,12 @@ export class AppFacade {
).pipe(startWith(true), shareReplay(1));

countries$() {
this.store.dispatch(new LoadCountries());
this.store.dispatch(loadCountries());
return this.store.pipe(select(getAllCountries));
}

regions$(countryCode: string) {
this.store.dispatch(new LoadRegions({ countryCode }));
this.store.dispatch(loadRegions({ countryCode }));
return this.store.pipe(select(getRegionsByCountryCode, { countryCode }));
}
}
60 changes: 30 additions & 30 deletions src/app/core/facades/checkout.facade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,14 @@ import { PaymentInstrument } from 'ish-core/models/payment-instrument/payment-in
import { selectRouteData } from 'ish-core/store/core/router';
import { getAllAddresses } from 'ish-core/store/customer/addresses';
import {
AddPromotionCodeToBasket,
AssignBasketAddress,
ContinueCheckout,
CreateBasketAddress,
CreateBasketPayment,
DeleteBasketItem,
DeleteBasketPayment,
DeleteBasketShippingAddress,
LoadBasketEligiblePaymentMethods,
LoadBasketEligibleShippingMethods,
RemovePromotionCodeFromBasket,
SetBasketPayment,
UpdateBasketAddress,
UpdateBasketItems,
UpdateBasketShippingMethod,
addPromotionCodeToBasket,
assignBasketAddress,
continueCheckout,
createBasketAddress,
createBasketPayment,
deleteBasketItem,
deleteBasketPayment,
deleteBasketShippingAddress,
getBasketEligiblePaymentMethods,
getBasketEligibleShippingMethods,
getBasketError,
Expand All @@ -36,6 +29,13 @@ import {
getBasketValidationResults,
getCurrentBasket,
isBasketInvoiceAndShippingAddressEqual,
loadBasketEligiblePaymentMethods,
loadBasketEligibleShippingMethods,
removePromotionCodeFromBasket,
setBasketPayment,
updateBasketAddress,
updateBasketItems,
updateBasketShippingMethod,
} from 'ish-core/store/customer/basket';
import { getOrdersError, getSelectedOrder } from 'ish-core/store/customer/orders';
import { getLoggedInUser } from 'ish-core/store/customer/user';
Expand All @@ -50,7 +50,7 @@ export class CheckoutFacade {
checkoutStep$ = this.store.pipe(select(selectRouteData<number>('checkoutStep')));

continue(targetStep: number) {
this.store.dispatch(new ContinueCheckout({ targetStep }));
this.store.dispatch(continueCheckout({ targetStep }));
}

// BASKET
Expand All @@ -68,15 +68,15 @@ export class CheckoutFacade {
);

deleteBasketItem(itemId: string) {
this.store.dispatch(new DeleteBasketItem({ itemId }));
this.store.dispatch(deleteBasketItem({ itemId }));
}

updateBasketItem(update: LineItemUpdate) {
this.store.dispatch(new UpdateBasketItems({ lineItemUpdates: [update] }));
this.store.dispatch(updateBasketItems({ lineItemUpdates: [update] }));
}

updateBasketShippingMethod(shippingId: string) {
this.store.dispatch(new UpdateBasketShippingMethod({ shippingId }));
this.store.dispatch(updateBasketShippingMethod({ shippingId }));
}

// ORDERS
Expand All @@ -91,7 +91,7 @@ export class CheckoutFacade {
return this.basket$.pipe(
whenTruthy(),
take(1),
tap(() => this.store.dispatch(new LoadBasketEligibleShippingMethods())),
tap(() => this.store.dispatch(loadBasketEligibleShippingMethods())),
switchMap(() => this.store.pipe(select(getBasketEligibleShippingMethods)))
);
}
Expand All @@ -102,22 +102,22 @@ export class CheckoutFacade {
return this.basket$.pipe(
whenTruthy(),
take(1),
tap(() => this.store.dispatch(new LoadBasketEligiblePaymentMethods())),
tap(() => this.store.dispatch(loadBasketEligiblePaymentMethods())),
switchMap(() => this.store.pipe(select(getBasketEligiblePaymentMethods)))
);
}
priceType$ = this.store.pipe(select(getServerConfigParameter<'gross' | 'net'>('pricing.priceType')));

setBasketPayment(paymentName: string) {
this.store.dispatch(new SetBasketPayment({ id: paymentName }));
this.store.dispatch(setBasketPayment({ id: paymentName }));
}

createBasketPayment(paymentInstrument: PaymentInstrument, saveForLater = false) {
this.store.dispatch(new CreateBasketPayment({ paymentInstrument, saveForLater }));
this.store.dispatch(createBasketPayment({ paymentInstrument, saveForLater }));
}

deleteBasketPayment(paymentInstrument: PaymentInstrument) {
this.store.dispatch(new DeleteBasketPayment({ paymentInstrument }));
this.store.dispatch(deleteBasketPayment({ paymentInstrument }));
}

// ADDRESSES
Expand All @@ -142,34 +142,34 @@ export class CheckoutFacade {
);

assignBasketAddress(addressId: string, scope: 'invoice' | 'shipping' | 'any') {
this.store.dispatch(new AssignBasketAddress({ addressId, scope }));
this.store.dispatch(assignBasketAddress({ addressId, scope }));
}

createBasketAddress(address: Address, scope: 'invoice' | 'shipping' | 'any') {
if (!address || !scope) {
return;
}

this.store.dispatch(new CreateBasketAddress({ address, scope }));
this.store.dispatch(createBasketAddress({ address, scope }));
}

updateBasketAddress(address: Address) {
this.store.dispatch(new UpdateBasketAddress({ address }));
this.store.dispatch(updateBasketAddress({ address }));
}

deleteBasketAddress(addressId: string) {
this.store.dispatch(new DeleteBasketShippingAddress({ addressId }));
this.store.dispatch(deleteBasketShippingAddress({ addressId }));
}

// PROMOTIONS

promotionError$ = this.store.pipe(select(getBasketPromotionError));

addPromotionCodeToBasket(code: string) {
this.store.dispatch(new AddPromotionCodeToBasket({ code }));
this.store.dispatch(addPromotionCodeToBasket({ code }));
}

removePromotionCodeFromBasket(code: string) {
this.store.dispatch(new RemovePromotionCodeFromBasket({ code }));
this.store.dispatch(removePromotionCodeFromBasket({ code }));
}
}
4 changes: 2 additions & 2 deletions src/app/core/facades/cms.facade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Store, select } from '@ngrx/store';
import { Observable } from 'rxjs';
import { filter, map, switchMap, switchMapTo, tap } from 'rxjs/operators';

import { LoadContentInclude, getContentInclude } from 'ish-core/store/content/includes';
import { getContentInclude, loadContentInclude } from 'ish-core/store/content/includes';
import { getContentPagelet } from 'ish-core/store/content/pagelets';
import { getContentPageLoading, getSelectedContentPage } from 'ish-core/store/content/pages';
import { getPGID } from 'ish-core/store/customer/user';
Expand All @@ -22,7 +22,7 @@ export class CMSFacade {
return this.store.pipe(select(getPGID)).pipe(
switchMapTo(includeId$),
whenTruthy(),
tap(includeId => this.store.dispatch(new LoadContentInclude({ includeId }))),
tap(includeId => this.store.dispatch(loadContentInclude({ includeId }))),
switchMap(includeId => this.store.pipe(select(getContentInclude, includeId)))
);
}
Expand Down
Loading

0 comments on commit 31acf5d

Please sign in to comment.