parent
c30b10857e
commit
221101f2a5
17 changed files with 137 additions and 58 deletions
@ -0,0 +1,31 @@ |
||||
import proxy from "../proxy"; |
||||
const transport = { |
||||
list: |
||||
(data = {}) => |
||||
async (dispatch) => |
||||
await proxy.get("transport/list", data, { dispatch }), |
||||
info: |
||||
(data = {}) => |
||||
async (dispatch) => |
||||
await proxy.get("transport/info", data, { dispatch }), |
||||
update: |
||||
(data = {}, data2 = {}) => |
||||
async (dispatch) => { |
||||
await proxy.put("transport/update", data); |
||||
await proxy.get("transport/list", data2, { dispatch }); |
||||
}, |
||||
add: |
||||
(data = {}, data2 = {}) => |
||||
async (dispatch) => { |
||||
await proxy.post("transport/add", data); |
||||
await proxy.get("transport/list", data2, { dispatch }); |
||||
}, |
||||
del: |
||||
(data = {}, data2 = {}) => |
||||
async (dispatch) => { |
||||
await proxy.delete("transport/delete", data); |
||||
await proxy.get("transport/list", data2, { dispatch }); |
||||
}, |
||||
}; |
||||
|
||||
export default transport; |
@ -0,0 +1,27 @@ |
||||
const initialState = { |
||||
loading: true, |
||||
error: null, |
||||
list: [], |
||||
info: null, |
||||
}; |
||||
export default function transport(state = initialState, action) { |
||||
let { type, data } = action; |
||||
switch (type) { |
||||
case "transport/list": |
||||
return { ...state, loading: false, list: data, error: null }; |
||||
case "transport/info": |
||||
return { ...state, loading: false, list: null, info: data, error: null }; |
||||
case "transport/update": |
||||
return { ...state, loading: false, error: null }; |
||||
case "transport/add": |
||||
return { ...state, loading: false, error: null }; |
||||
case "transport/delete": |
||||
return { ...state, loading: false, error: null }; |
||||
case "loading": |
||||
return { ...state, loading: true }; |
||||
case "error": |
||||
return { ...state, loading: false, error: data.message }; |
||||
default: |
||||
return state; |
||||
} |
||||
} |
Loading…
Reference in new issue