import { fakeChartData } from '../services/api'; export default { namespace: 'chart', state: { visitData: [], salesData: [], searchData: [], offlineData: [], offlineChartData: [], salesTypeData: [], salesTypeDataOnline: [], salesTypeDataOffline: [], radarData: [], }, effects: { *fetch({ payload }, { call, put }) { const response = yield call(fakeChartData); yield put({ type: 'save', payload: response, }); }, *fetchSalesData({ payload }, { call, put }) { const response = yield call(fakeChartData); yield put({ type: 'save', payload: { salesData: response.salesData, }, }); }, }, reducers: { save(state, { payload }) { return { ...state, ...payload, }; }, setter(state, { payload }) { return { ...state, ...payload, }; }, clear() { return { visitData: [], salesData: [], searchData: [], offlineData: [], offlineChartData: [], salesTypeData: [], salesTypeDataOnline: [], salesTypeDataOffline: [], radarData: [], }; }, }, };