Commit f12e32bb authored by chencheng's avatar chencheng

9. Handle user delete

parent 156220ce
......@@ -6,7 +6,10 @@ import { PAGE_SIZE } from '../constants';
function Users({ dispatch, list: dataSource, loading, total, page: current }) {
function deleteHandler(id) {
console.warn(`TODO: ${id}`);
dispatch({
type: 'users/remove',
payload: id,
});
}
function pageChangeHandler(page) {
......
......@@ -24,6 +24,11 @@ export default {
},
});
},
*remove({ payload: id }, { call, put, select }) {
yield call(usersService.remove, id);
const page = yield select(state => state.users.page);
yield put({ type: 'fetch', payload: { page } });
},
},
subscriptions: {
setup({ dispatch, history }) {
......
......@@ -4,3 +4,9 @@ import request from '../../../utils/request';
export function fetch({ page = 1 }) {
return request(`/api/users?_page=${page}&_limit=${PAGE_SIZE}`);
}
export function remove(id) {
return request(`/api/users/${id}`, {
method: 'DELETE',
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment