Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 4x 4x 4x 4x 4x 1x 1x | import { Injectable } from '@angular/core'; import { Actions, createEffect, ofType } from '@ngrx/effects'; import { concatMap, mergeMap } from 'rxjs/operators'; import { v4 as uuid } from 'uuid'; import { FeatureToggleService } from 'ish-core/feature-toggle.module'; import { SsoRegistrationType } from 'ish-core/models/customer/customer.model'; import { UserService } from 'ish-core/services/user/user.service'; import { userNewsletterActions } from 'ish-core/store/customer/user'; import { mapErrorToAction, mapToPayload } from 'ish-core/utils/operators'; import { registerFailure, registerSuccess, setRegistrationInfo } from './sso-registration.actions'; @Injectable() export class SsoRegistrationEffects { constructor( private actions$: Actions, private userService: UserService, private featureToggleService: FeatureToggleService ) {} registerUser$ = createEffect(() => this.actions$.pipe( ofType(setRegistrationInfo), mapToPayload(), mergeMap((data: SsoRegistrationType) => this.userService .createUser({ address: data.address, customer: { customerNo: uuid(), companyName: data.companyInfo.companyName1, companyName2: data.companyInfo.companyName2, isBusinessCustomer: this.featureToggleService.enabled('businessCustomerRegistration'), taxationID: data.companyInfo.taxationID, }, userId: data.userId, }) .pipe( concatMap(createUserResponse => [ registerSuccess, ...(data.subscribedToNewsletter ? [ userNewsletterActions.updateUserNewsletterSubscription({ subscriptionStatus: true, userEmail: createUserResponse.user.email, }), ] : []), ]), mapErrorToAction(registerFailure) ) ) ) ); } |