44 lines
929 B
TypeScript
Raw Normal View History

2019-10-08 13:18:05 +09:00
import { createReducer, on } from '@ngrx/store';
import { initialState } from './state';
2019-10-08 15:25:00 +09:00
import { infoSuccess, appendInfoList, info, infoFailure } from './actions';
2019-10-11 13:11:48 +09:00
import * as AuthenticationStore from '@app/store/account/authentication';
2019-10-08 13:18:05 +09:00
export const reducer = createReducer(
initialState,
2019-10-08 15:25:00 +09:00
on(info, (state, action) => {
return {
...state,
infoListProcessing: true
};
}),
2019-10-08 13:18:05 +09:00
on(infoSuccess, (state, action) => {
return {
...state,
infoList: action.infoList,
2019-10-08 15:25:00 +09:00
infoStatus: action.res,
infoListProcessing: false
};
}),
on(infoFailure, (state, action) => {
return {
...state,
infoListProcessing: false
2019-10-08 13:18:05 +09:00
};
2019-10-08 14:59:22 +09:00
}),
on(appendInfoList, (state, action) => {
return {
...state,
infoList: [...state.infoList, action.info]
};
2019-10-11 13:11:48 +09:00
}),
on(AuthenticationStore.logout, (state, action) => {
return {
...initialState
};
2019-10-08 13:18:05 +09:00
})
);