parent
ab08b4cacd
commit
64f995c2e5
7 changed files with 77 additions and 15 deletions
@ -0,0 +1,11 @@ |
||||
import proxy from "../proxy"; |
||||
const vote = { |
||||
add: |
||||
(data = {}, data2) => |
||||
async (dispatch) => { |
||||
await proxy.post("userVote/add", data, { dispatch }); |
||||
}, |
||||
|
||||
}; |
||||
|
||||
export default vote; |
@ -0,0 +1,24 @@ |
||||
import { asyncApiAwesomeAlert } from "../../utils/AsyncWrappers"; |
||||
|
||||
const initialState = { |
||||
loading: false, |
||||
error: null, |
||||
}; |
||||
|
||||
export default function vote(state = initialState, action) { |
||||
let { type, data } = action; |
||||
switch (type) { |
||||
case "userVote/add": |
||||
asyncAwesomeAlert("نتیجه", "رای شما با موفقیت ثبت شد.", { |
||||
showCancelButton: false, |
||||
}); |
||||
return { ...state, loading: false, error: null }; |
||||
case "userVote/loading": |
||||
return { ...state, loading: true }; |
||||
case "userVote/error": |
||||
toast.error(data.message); |
||||
return { ...state, loading: false, error: data.message }; |
||||
default: |
||||
return state; |
||||
} |
||||
} |
Loading…
Reference in new issue