parent
7ec9df4452
commit
7b16deabe0
16 changed files with 202 additions and 98 deletions
@ -0,0 +1,29 @@ |
||||
import proxy from "../proxy"; |
||||
|
||||
const userFavorite = { |
||||
list: |
||||
(data = {}) => |
||||
async (dispatch) => { |
||||
await proxy.get("userFavorite/list", data, { dispatch }); |
||||
}, |
||||
update: |
||||
(data = {}, data2 = {}) => |
||||
async (dispatch) => { |
||||
await proxy.put("userFavorite/update", data); |
||||
await proxy.get("userFavorite/list", data2, { dispatch }); |
||||
}, |
||||
add: |
||||
(data = {}, data2 = {}, data3 = {}) => |
||||
async (dispatch) => { |
||||
await proxy.post("userFavorite/add", data, { dispatch }); |
||||
await proxy.get("userFavorite/list", data2, { dispatch }); |
||||
}, |
||||
del: |
||||
(data = {}, data2 = {}) => |
||||
async (dispatch) => { |
||||
await proxy.delete("userFavorite/delete", data); |
||||
await proxy.get("userFavorite/list", data2, { dispatch }); |
||||
}, |
||||
}; |
||||
|
||||
export default userFavorite; |
@ -0,0 +1,29 @@ |
||||
const initialState = { |
||||
loading: false, |
||||
error: null, |
||||
list: [], |
||||
}; |
||||
export default function userAddress(state = initialState, action) { |
||||
let { type, data } = action; |
||||
switch (type) { |
||||
case "userAddress/list": |
||||
return { |
||||
...state, |
||||
loading: false, |
||||
list: data, |
||||
error: null, |
||||
}; |
||||
case "userAddress/update": |
||||
return { ...state, loading: false, error: null }; |
||||
case "userAddress/add": |
||||
return { ...state, loading: false, error: null }; |
||||
case "userAddress/delete": |
||||
return { ...state, loading: false, error: null }; |
||||
case "userAddress/loading": |
||||
return { ...state, loading: true }; |
||||
case "userAddress/error": |
||||
return { ...state, loading: false, error: data.message }; |
||||
default: |
||||
return state; |
||||
} |
||||
} |
Loading…
Reference in new issue