onnet-portal
Version:
Ant Design Pro based test2
52 lines (43 loc) • 989 B
text/typescript
import { AnyAction, Reducer } from 'redux';
import { EffectsCommandMap } from 'dva';
import { AccountCallflows } from '../services/kazoo-telephony';
export type Effect = (
action: AnyAction,
effects: EffectsCommandMap & { select: <T>(func: (state: {}) => T) => T },
) => void;
export interface ModelType {
namespace: string;
state: {};
effects: {
refreshAccountState: Effect;
};
reducers: {
update: Reducer<{}>;
flush: Reducer<{}>;
};
}
const Model: ModelType = {
namespace: 'kz_cf_list',
state: {},
effects: {
*refresh({ payload }, { call, put }) {
const response = yield call(AccountCallflows, { ...payload, method: 'GET' });
yield put({
type: 'update',
payload: response,
});
},
*flush(_, { put }) {
yield put({
type: 'update',
payload: {},
});
},
},
reducers: {
update(state, { payload }) {
return { ...payload };
},
},
};
export default Model;