aboutsummaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/shared/storeUtil/utils/main.reducer.ts
blob: 2166c81a02ff7b5da4422bdb33f7a1c58e98adb1 (plain)
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
58
59
60
61
62
63
64
65
66
67
import {LcpRegionsAndTenants} from "../../models/lcpRegionsAndTenants";
import {CategoryParams} from "../../models/categoryParams";
import {Action} from "redux";
import {ServiceActions} from "./service/service.actions";
import {GeneralActions} from "./general/general.actions";
import {NetworkActions} from "./network/network.actions";
import {VfModuleActions} from "./vfModule/vfModule.actions";
import {VNFActions} from "./vnf/vnf.actions";
import {vnfReducer} from "./vnf/vnf.reducers";
import {generalReducer} from "./general/general.reducers";
import {serviceReducer} from "./service/service.reducers";
import {networkReducer} from "./network/network.reducers";
import {vfModuleReducer} from "./vfModule/vfModule.reducers";
import {ServiceInstance} from "../../models/serviceInstance";
import {SelectOptionInterface} from "../../models/selectOption";
import {ServiceType} from "../../models/serviceType";
import {VnfGroupActions} from "./vnfGroup/vnfGroup.actions";
import {vnfGroupReducer} from "./vnfGroup/vnfGroup.reducers";
import {RelatedVnfActions} from "./relatedVnfMember/relatedVnfMember.actions";
import {relatedVnfMemeberReducer} from "./relatedVnfMember/relatedVnfMember.reducers";

export let initialState: ServiceState = {
  serviceHierarchy: {},
  serviceInstance: {},
  lcpRegionsAndTenants: new LcpRegionsAndTenants(),
  subscribers: null,
  productFamilies: null,
  serviceTypes: {},
  aicZones: null,
  categoryParameters: new CategoryParams()
};


export interface ServiceState {
  serviceHierarchy: any;
  serviceInstance: { [uuid: string]: ServiceInstance; };
  lcpRegionsAndTenants: LcpRegionsAndTenants;
  subscribers: SelectOptionInterface[];
  productFamilies: any;
  serviceTypes: { [subscriberId: string]: ServiceType[]; };
  aicZones: SelectOptionInterface[];
  categoryParameters: CategoryParams;
}

export const MainReducer = function (state: ServiceState = initialState, action: Action): ServiceState {
  console.info("action name", action.type);
  if(Object.values(ServiceActions).includes(action.type)){
    return serviceReducer(state, action);
  }else if (Object.values(GeneralActions).includes(action.type)){
    return generalReducer(state, action);
  }else if (Object.values(NetworkActions).includes(action.type)){
    return networkReducer(state, action);
  }else if (Object.values(VfModuleActions).includes(action.type)){
    return vfModuleReducer(state, action);
  }else if (Object.values(VNFActions).includes(action.type)){
    return vnfReducer(state, action);
  }else if (Object.values(VnfGroupActions).includes(action.type)){
    return vnfGroupReducer(state, action);
  }else if(Object.values(RelatedVnfActions).includes(action.type)){
    return relatedVnfMemeberReducer(state, action);
  } else {
    return Object.assign({}, state);
  }
};