2020-11-15 18:48:32 +00:00
|
|
|
|
2020-07-09 01:36:50 +01:00
|
|
|
import axios from 'axios'
|
2020-11-15 18:48:32 +00:00
|
|
|
import api from '../api'
|
2020-07-02 02:33:10 +01:00
|
|
|
import { me } from '../initial_state'
|
|
|
|
|
|
|
|
export const SHOP_FEATURED_PRODUCTS_FETCH_REQUEST = 'SHOP_FEATURED_PRODUCTS_FETCH_REQUEST'
|
|
|
|
export const SHOP_FEATURED_PRODUCTS_FETCH_SUCCESS = 'SHOP_FEATURED_PRODUCTS_FETCH_SUCCESS'
|
|
|
|
export const SHOP_FEATURED_PRODUCTS_FETCH_FAIL = 'SHOP_FEATURED_PRODUCTS_FETCH_FAIL'
|
|
|
|
|
2020-11-15 18:48:32 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
export const fetchFeaturedProducts = () => (dispatch, getState) => {
|
|
|
|
if (!me) return
|
2020-07-02 02:33:10 +01:00
|
|
|
|
2020-11-15 18:48:32 +00:00
|
|
|
dispatch(fetchFeaturedProductsRequest('featured'))
|
2020-07-02 02:33:10 +01:00
|
|
|
|
2020-11-15 18:48:32 +00:00
|
|
|
axios.get('https://dissenter-shop.gab.com/product/group/json').then((response) => {
|
|
|
|
try {
|
|
|
|
dispatch(fetchFeaturedProductsSuccess(response.data.data, 'featured'))
|
|
|
|
} catch (error) {
|
|
|
|
//
|
|
|
|
}
|
|
|
|
}).catch((error) => {
|
|
|
|
dispatch(fetchFeaturedProductsFail(error, 'featured'))
|
|
|
|
})
|
2020-07-02 02:33:10 +01:00
|
|
|
}
|
|
|
|
|
2020-11-15 18:48:32 +00:00
|
|
|
const fetchFeaturedProductsRequest = (listType) => ({
|
|
|
|
type: SHOP_FEATURED_PRODUCTS_FETCH_REQUEST,
|
|
|
|
listType,
|
|
|
|
})
|
|
|
|
|
|
|
|
const fetchFeaturedProductsSuccess = (items, listType) => ({
|
|
|
|
type: SHOP_FEATURED_PRODUCTS_FETCH_SUCCESS,
|
|
|
|
items,
|
|
|
|
listType,
|
|
|
|
})
|
|
|
|
|
|
|
|
const fetchFeaturedProductsFail = (error, listType) => ({
|
|
|
|
type: SHOP_FEATURED_PRODUCTS_FETCH_FAIL,
|
|
|
|
error,
|
|
|
|
listType,
|
|
|
|
})
|