import { INQUIRY } from '../../../actions/actionsTypes';
const initialState = {
enabled: false,
queued: [],
error: {}
};
export default function inquiry(state = initialState, action) {
switch (action.type) {
case INQUIRY.SUCCESS:
return {
...state,
queued: action.inquiries
case INQUIRY.FAILURE:
error: action.error
case INQUIRY.SET_ENABLED:
enabled: action.enabled
case INQUIRY.QUEUE_ADD:
queued: [...state.queued, action.inquiry]
case INQUIRY.QUEUE_UPDATE:
queued: state.queued.map((item) => {
if (item._id === action.inquiry._id) {
return action.inquiry;
}
return item;
})
case INQUIRY.QUEUE_REMOVE:
queued: state.queued.filter(({ _id }) => _id !== action.inquiryId)
case INQUIRY.RESET:
return initialState;
default:
return state;