+ client: handle per-client settings
This commit is contained in:
committed by
Simon Zolin
parent
22c7efd2d1
commit
22d3c38df2
63
client/src/reducers/clients.js
Normal file
63
client/src/reducers/clients.js
Normal file
@@ -0,0 +1,63 @@
|
||||
import { handleActions } from 'redux-actions';
|
||||
|
||||
import * as actions from '../actions/clients';
|
||||
|
||||
const clients = handleActions({
|
||||
[actions.addClientRequest]: state => ({ ...state, processingAdding: true }),
|
||||
[actions.addClientFailure]: state => ({ ...state, processingAdding: false }),
|
||||
[actions.addClientSuccess]: (state) => {
|
||||
const newState = {
|
||||
...state,
|
||||
processingAdding: false,
|
||||
};
|
||||
return newState;
|
||||
},
|
||||
|
||||
[actions.deleteClientRequest]: state => ({ ...state, processingDeleting: true }),
|
||||
[actions.deleteClientFailure]: state => ({ ...state, processingDeleting: false }),
|
||||
[actions.deleteClientSuccess]: (state) => {
|
||||
const newState = {
|
||||
...state,
|
||||
processingDeleting: false,
|
||||
};
|
||||
return newState;
|
||||
},
|
||||
|
||||
[actions.updateClientRequest]: state => ({ ...state, processingUpdating: true }),
|
||||
[actions.updateClientFailure]: state => ({ ...state, processingUpdating: false }),
|
||||
[actions.updateClientSuccess]: (state) => {
|
||||
const newState = {
|
||||
...state,
|
||||
processingUpdating: false,
|
||||
};
|
||||
return newState;
|
||||
},
|
||||
|
||||
[actions.toggleClientModal]: (state, { payload }) => {
|
||||
if (payload) {
|
||||
const newState = {
|
||||
...state,
|
||||
modalType: payload.type || '',
|
||||
modalClientName: payload.name || '',
|
||||
isModalOpen: !state.isModalOpen,
|
||||
};
|
||||
return newState;
|
||||
}
|
||||
|
||||
const newState = {
|
||||
...state,
|
||||
isModalOpen: !state.isModalOpen,
|
||||
};
|
||||
return newState;
|
||||
},
|
||||
}, {
|
||||
processing: true,
|
||||
processingAdding: false,
|
||||
processingDeleting: false,
|
||||
processingUpdating: false,
|
||||
isModalOpen: false,
|
||||
modalClientName: '',
|
||||
modalType: '',
|
||||
});
|
||||
|
||||
export default clients;
|
||||
Reference in New Issue
Block a user