import { createReducer, on } from '@ngrx/store'; import { initialState } from './state'; import { authSuccess, deptSuccess, myDeptUserSuccess, deptUserSuccess, selectedDept, selectedDeptSuccess, searchDeptUser, searchDeptUserSuccess, searchDeptUserFailure, deptUserFailure, clearSearchDeptUser, myDeptUserFailure, integrateSearchDeptUser, integrateSearchDeptUserSuccess, integrateSearchDeptUserFailure, integrateClearSearchDeptUser, selectedTree } from './actions'; import * as AuthenticationStore from '@app/store/account/authentication'; export const reducer = createReducer( initialState, on(authSuccess, (state, action) => { return { ...state, auth: action.res }; }), on(deptSuccess, (state, action) => { return { ...state, departmentInfoList: action.departmentInfoList }; }), on(selectedTree, (state, action) => { return { ...state, selectedTree: action.deptSeq }; }), on(selectedDept, (state, action) => { return { ...state, selectedDepartment: action, selectedDepartmentProcessing: true }; }), on(selectedDeptSuccess, (state, action) => { return { ...state, selectedDepartmentProcessing: false }; }), on(deptUserSuccess, (state, action) => { return { ...state, departmentUserInfoList: action.userInfos }; }), on(deptUserFailure, state => { return { ...state, selectedDepartmentProcessing: false }; }), on(myDeptUserSuccess, (state, action) => { return { ...state, myDepartmentUserInfoList: action.userInfos }; }), on(myDeptUserFailure, state => { return { ...state, selectedDepartmentProcessing: false }; }), on(searchDeptUser, (state, action) => { return { ...state, isSearch: true, selectedDepartmentProcessing: true }; }), on(searchDeptUserSuccess, (state, action) => { return { ...state, searchDepartmentUserInfoList: action.userInfos, selectedDepartmentProcessing: false }; }), on(searchDeptUserFailure, (state, action) => { return { ...state, selectedDepartmentProcessing: false }; }), on(clearSearchDeptUser, (state, action) => { return { ...state, isSearch: false, searchDepartmentUserInfoList: null }; }), on(integrateSearchDeptUser, (state, action) => { return { ...state, integrateSearchDepartmentProcessing: true }; }), on(integrateSearchDeptUserSuccess, (state, action) => { return { ...state, integrateSearchDepartmentUserInfoList: action.userInfos, integrateSearchDepartmentProcessing: false }; }), on(integrateSearchDeptUserFailure, (state, action) => { return { ...state, integrateSearchDepartmentProcessing: false }; }), on(integrateClearSearchDeptUser, (state, action) => { return { ...state, integrateSearchDepartmentUserInfoList: null }; }), on(AuthenticationStore.logoutInitialize, (state, action) => { return { ...initialState }; }) );