154 lines
3.1 KiB
TypeScript
Raw Normal View History

2019-09-25 17:26:19 +09:00
import { createReducer, on } from '@ngrx/store';
import { initialState } from './state';
2020-03-03 17:44:02 +09:00
import {
authSuccess,
deptSuccess,
myDeptUserSuccess,
deptUserSuccess,
selectedDept,
selectedDeptSuccess,
searchDeptUser,
searchDeptUserSuccess,
searchDeptUserFailure,
deptUserFailure,
2020-03-06 16:42:14 +09:00
clearSearchDeptUser,
myDeptUserFailure,
integrateSearchDeptUser,
integrateSearchDeptUserSuccess,
integrateSearchDeptUserFailure,
integrateClearSearchDeptUser,
selectedTree
2020-03-03 17:44:02 +09:00
} from './actions';
2019-09-25 17:26:19 +09:00
2019-10-11 13:11:48 +09:00
import * as AuthenticationStore from '@app/store/account/authentication';
2019-09-25 17:26:19 +09:00
export const reducer = createReducer(
initialState,
on(authSuccess, (state, action) => {
return {
...state,
auth: action.res
};
2019-10-04 13:45:02 +09:00
}),
on(deptSuccess, (state, action) => {
return {
...state,
departmentInfoList: action.departmentInfoList
};
2019-10-07 13:07:52 +09:00
}),
on(selectedTree, (state, action) => {
return {
...state,
selectedTree: action.deptSeq
};
}),
2020-03-03 17:44:02 +09:00
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
};
}),
2020-03-03 17:44:02 +09:00
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
};
}),
2020-03-06 16:42:14 +09:00
on(clearSearchDeptUser, (state, action) => {
2020-03-03 17:44:02 +09:00
return {
...state,
isSearch: false,
searchDepartmentUserInfoList: null
};
}),
2020-03-06 16:42:14 +09:00
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
};
}),
2019-11-19 18:43:49 +09:00
on(AuthenticationStore.logoutInitialize, (state, action) => {
2019-10-11 13:11:48 +09:00
return {
...initialState
};
2019-09-25 17:26:19 +09:00
})
);