import { BI } from 'app/modules/reports/store/bi.constants'; import { BiStoreState } from 'app/modules/reports/store/bi.types'; import { AnyAction } from 'redux'; export const defaultBiState: BiStoreState = { reports: { collection: [], year: null, filters: { years: [], }, finance: {}, }, }; const biReducer = (state = defaultBiState, action: AnyAction = { type: '' }) => { switch (action.type) { case BI.SET_REPORTS: return { ...state, reports: { ...state.reports, collection: action.payload }, }; case BI.SET_REPORTS_FILTERS: return { ...state, reports: { ...state.reports, filters: action.payload }, }; case BI.SET_FINANCE_REPORT: return { ...state, reports: { ...state.reports, finance: action.payload }, }; case BI.SET_FINANCE_REPORT_TOKEN: return { ...state, reports: { ...state.reports, finance: { ...state.reports.finance, token: action.payload }, }, }; case BI.SET_FINANCE_REPORT_YEAR: return { ...state, reports: { ...state.reports, year: action.payload }, }; default: return state; } }; export { biReducer };