All files / src/app/extensions/tacton/store/saved-tacton-configuration saved-tacton-configuration.effects.ts

62.5% Statements 10/16
75% Branches 6/8
0% Functions 0/4
66.66% Lines 10/15

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 323x 3x 3x 3x   3x 3x   3x 3x   3x     3x                                  
import { Injectable } from '@angular/core';
import { Actions, concatLatestFrom, createEffect, ofType } from '@ngrx/effects';
import { Store, select } from '@ngrx/store';
import { map } from 'rxjs/operators';
 
import { getLoggedInUser } from 'ish-core/store/customer/user';
import { mapToPayloadProperty } from 'ish-core/utils/operators';
 
import { setCurrentConfiguration } from '../product-configuration';
import { getTactonProductForSelectedProduct } from '../tacton-config';
 
import { saveTactonConfigurationReference } from './saved-tacton-configuration.actions';
 
@Injectable()
export class SavedTactonConfigurationEffects {
  constructor(private actions$: Actions, private store: Store) {}
 
  saveCurrentConfigurationReference$ = createEffect(() =>
    this.actions$.pipe(
      ofType(setCurrentConfiguration),
      mapToPayloadProperty('configuration'),
      concatLatestFrom(() => [
        this.store.pipe(select(getTactonProductForSelectedProduct)),
        this.store.pipe(select(getLoggedInUser)),
      ]),
      map(([configuration, tactonProduct, user]) =>
        saveTactonConfigurationReference({ configuration, tactonProduct, user: user?.login })
      )
    )
  );
}