All files / src/app/extensions/tacton/store/product-configuration product-configuration.reducer.ts

71.42% Statements 5/7
100% Branches 0/0
0% Functions 0/2
71.42% Lines 5/7

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 493x   3x       3x                                 3x         3x                                        
import { createReducer, on } from '@ngrx/store';
 
import { setLoadingOn, unsetLoadingOn } from 'ish-core/utils/ngrx-creators';
 
import { TactonProductConfiguration } from '../../models/tacton-product-configuration/tacton-product-configuration.model';
 
import {
  changeTactonConfigurationStep,
  clearTactonConfiguration,
  commitTactonConfigurationValue,
  continueConfigureTactonProduct,
  setCurrentConfiguration,
  startConfigureTactonProduct,
  submitTactonConfiguration,
  submitTactonConfigurationSuccess,
  uncommitTactonConfigurationValue,
} from './product-configuration.actions';
 
export interface ProductConfigurationState {
  loading: boolean;
  current: TactonProductConfiguration;
}
 
const initialState: ProductConfigurationState = {
  loading: false,
  current: undefined,
};
 
export const productConfigurationReducer = createReducer(
  initialState,
  setLoadingOn(
    startConfigureTactonProduct,
    continueConfigureTactonProduct,
    commitTactonConfigurationValue,
    uncommitTactonConfigurationValue,
    changeTactonConfigurationStep,
    submitTactonConfiguration
  ),
  unsetLoadingOn(setCurrentConfiguration),
  on(
    setCurrentConfiguration,
    (state, action): ProductConfigurationState => ({
      ...state,
      current: action.payload.configuration,
    })
  ),
  on(clearTactonConfiguration, submitTactonConfigurationSuccess, (): ProductConfigurationState => initialState)
);