54 lines
1.3 KiB
JavaScript
54 lines
1.3 KiB
JavaScript
import ModalsActionTypes from "./modals.types";
|
|
|
|
const baseModal = {
|
|
visible: false,
|
|
context: {},
|
|
actions: {
|
|
refetch: null,
|
|
},
|
|
};
|
|
|
|
const INITIAL_STATE = {
|
|
jobLineEdit: { ...baseModal },
|
|
billEnter: { ...baseModal },
|
|
courtesyCarReturn: { ...baseModal },
|
|
noteUpsert: { ...baseModal },
|
|
schedule: { ...baseModal },
|
|
partsOrder: { ...baseModal },
|
|
timeTicket: { ...baseModal },
|
|
printCenter: { ...baseModal },
|
|
reconciliation: { ...baseModal },
|
|
payment: { ...baseModal },
|
|
jobCosting: { ...baseModal },
|
|
reportCenter: { ...baseModal },
|
|
partsReceive: { ...baseModal },
|
|
contractFinder: { ...baseModal },
|
|
ca_bc_eftTableConvert: { ...baseModal },
|
|
};
|
|
|
|
const modalsReducer = (state = INITIAL_STATE, action) => {
|
|
switch (action.type) {
|
|
case ModalsActionTypes.TOGGLE_MODAL_VISIBLE:
|
|
return {
|
|
...state,
|
|
[action.payload]: {
|
|
...state[action.payload],
|
|
visible: !state[action.payload].visible,
|
|
},
|
|
};
|
|
case ModalsActionTypes.SET_MODAL_CONTEXT:
|
|
return {
|
|
...state,
|
|
[action.payload.modal]: {
|
|
...state[action.payload.modal],
|
|
...action.payload.context,
|
|
visible: true,
|
|
},
|
|
};
|
|
default:
|
|
return state;
|
|
}
|
|
};
|
|
|
|
export default modalsReducer;
|