You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.1 KiB
39 lines
1.1 KiB
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, |
|
}); |
|
return { ...state, loading: false, error: null }; |
|
case "activation/delete": |
|
return { ...state, loading: false, error: null }; |
|
case "loading": |
|
return { ...state, loading: true }; |
|
case "error": |
|
asyncAwesomeAlert("خطا", data.message, { |
|
showCancelButton: false, |
|
confirmText: "باشه" |
|
}); |
|
return { |
|
...state, |
|
loading: false, |
|
error: data.message, |
|
message: data.message, |
|
}; |
|
default: |
|
return state; |
|
} |
|
}
|
|
|