2019-09-25 17:26:19 +09:00
|
|
|
import { createReducer, on } from '@ngrx/store';
|
|
|
|
import { initialState } from './state';
|
2019-10-22 17:05:29 +09:00
|
|
|
import {
|
|
|
|
authSuccess,
|
|
|
|
deptSuccess,
|
|
|
|
deptUserSuccess,
|
|
|
|
deptUser,
|
2019-12-26 17:34:52 +09:00
|
|
|
deptUserFailure,
|
|
|
|
myDeptUserSuccess
|
2019-10-22 17:05:29 +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
|
|
|
}),
|
|
|
|
|
2019-10-22 17:05:29 +09:00
|
|
|
on(deptUser, (state, action) => {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
selectedDepartmentProcessing: true
|
|
|
|
};
|
|
|
|
}),
|
|
|
|
|
2019-10-07 13:07:52 +09:00
|
|
|
on(deptUserSuccess, (state, action) => {
|
2019-12-27 16:34:38 +09:00
|
|
|
const userList = action.userInfos.sort((a, b) =>
|
|
|
|
a.order < b.order
|
|
|
|
? -1
|
|
|
|
: a.order > b.order
|
|
|
|
? 1
|
|
|
|
: a.name < b.name
|
|
|
|
? -1
|
|
|
|
: a.name > b.name
|
|
|
|
? 1
|
|
|
|
: 0
|
|
|
|
);
|
2019-10-07 13:07:52 +09:00
|
|
|
return {
|
|
|
|
...state,
|
2019-12-27 16:34:38 +09:00
|
|
|
selectedDepartmentUserInfoList: userList,
|
2019-10-22 17:05:29 +09:00
|
|
|
selectedDepartmentStatus: action.res,
|
|
|
|
selectedDepartmentProcessing: false
|
2019-10-07 13:07:52 +09:00
|
|
|
};
|
2019-10-11 13:11:48 +09:00
|
|
|
}),
|
2019-10-22 17:05:29 +09:00
|
|
|
|
|
|
|
on(deptUserFailure, (state, action) => {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
selectedDepartmentProcessing: false
|
|
|
|
};
|
|
|
|
}),
|
|
|
|
|
2019-12-26 17:34:52 +09:00
|
|
|
on(myDeptUserSuccess, (state, action) => {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
myDepartmentUserInfoList: action.userInfos
|
|
|
|
};
|
|
|
|
}),
|
|
|
|
|
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
|
|
|
})
|
|
|
|
);
|