37 lines
979 B
JavaScript
37 lines
979 B
JavaScript
import ReportingActionTypes from "./reporting.types";
|
|
const INITIAL_STATE = {
|
|
dates: { startDate: null, endDate: null },
|
|
data: [],
|
|
scoreCard: null,
|
|
error: null,
|
|
loading: false,
|
|
};
|
|
|
|
const applicationReducer = (state = INITIAL_STATE, action) => {
|
|
switch (action.type) {
|
|
case ReportingActionTypes.QUERY_REPORTING_DATA:
|
|
return {
|
|
...state,
|
|
loading: true,
|
|
error: null,
|
|
dates: {
|
|
startDate: action.payload.startDate.toISOString(),
|
|
endDate: action.payload.endDate.toISOString(),
|
|
},
|
|
};
|
|
case ReportingActionTypes.SET_REPORTING_ERROR:
|
|
return {
|
|
...state,
|
|
error: action.payload,
|
|
};
|
|
case ReportingActionTypes.SET_REPORTING_DATA:
|
|
return { ...state, data: action.payload };
|
|
case ReportingActionTypes.SET_SCORE_CARD:
|
|
return { ...state, loading: false, scoreCard: action.payload };
|
|
default:
|
|
return state;
|
|
}
|
|
};
|
|
|
|
export default applicationReducer;
|