parent
26f18dc08e
commit
d13297bd6f
9 changed files with 155 additions and 53 deletions
@ -0,0 +1,27 @@ |
||||
import proxy from "../proxy"; |
||||
|
||||
const activation = { |
||||
list: |
||||
(data = {}) => |
||||
async (dispatch) => |
||||
await proxy.get("activation/list", data, { dispatch }), |
||||
update: |
||||
(data = {}, data2 = {}) => |
||||
async (dispatch) => { |
||||
await proxy.put("activation/update", data); |
||||
await proxy.get("activation/list", data2, { dispatch }); |
||||
}, |
||||
add: |
||||
(data = {}) => |
||||
async (dispatch) => { |
||||
await proxy.post("activation/add", data); |
||||
}, |
||||
del: |
||||
(data = {}, data2 = {}) => |
||||
async (dispatch) => { |
||||
await proxy.delete("activation/delete", data); |
||||
await proxy.get("activation/list", data2, { dispatch }); |
||||
}, |
||||
}; |
||||
|
||||
export default activation; |
@ -0,0 +1,40 @@ |
||||
import { asyncAwesomeAlert } from "../../utils/AsyncWrappers"; |
||||
|
||||
const initialState = { |
||||
loading: false, |
||||
error: null, |
||||
list: [], |
||||
message: null, |
||||
}; |
||||
export default function activation(state = initialState, action) { |
||||
let { type, data } = action; |
||||
switch (type) { |
||||
case "activation/list": |
||||
return { ...state, loading: false, list: data, error: null }; |
||||
case "activation/update": |
||||
return { ...state, loading: false, error: null, message: data.message }; |
||||
case "activation/add": |
||||
asyncAwesomeAlert("نتیجه", data.message, { |
||||
showCancelButton: false, |
||||
}); |
||||
console.log(data.message); |
||||
return { ...state, loading: false, error: null }; |
||||
case "activation/delete": |
||||
return { ...state, loading: false, error: null }; |
||||
case "loading": |
||||
return { ...state, loading: true }; |
||||
case "error": |
||||
console.log(data.message); |
||||
asyncAwesomeAlert("خطا", data.message, { |
||||
showCancelButton: false, |
||||
}); |
||||
return { |
||||
...state, |
||||
loading: false, |
||||
error: data.message, |
||||
message: data.message, |
||||
}; |
||||
default: |
||||
return state; |
||||
} |
||||
} |
Before Width: | Height: | Size: 684 B |
Before Width: | Height: | Size: 3.5 KiB |
File diff suppressed because one or more lines are too long
Loading…
Reference in new issue