Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export const setLoader = (loader) => dispatch => {
- dispatch({ type: SET_LOADER, payload: loader });
- };
- export const fetchCategory = (setLoader) => async dispatch => {
- setLoader(true);
- try {
- const instance = axios.create();
- instance.defaults.headers.common['Authorization'] = AUTHORIZATION_TOKEN;
- const response = await instance.get(API_PATHS.SERVICE_CATEGORY_API);
- dispatch({ type: FETCH_CATEGORY, payload: response.data });
- } catch (e) {
- setLoader(false);
- }
- };
- export default (state = INITIAL_STATE, action) => {
- switch (action.type) {
- case FETCH_CATEGORY:
- return { ...state, categoryList: action.payload };
- case SET_LOADER:
- return { ...state, isLoading: action.payload };
- default:
- return state;
- }
- };
- const mapStateToProps = state => {
- return ({
- categoryList: state.locator.categoryList
- });
- }
- export default connect(
- mapStateToProps,
- { fetchCategory, setLoader }
- )(ServiceLocator);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement