Added ShopPanel to home sidebar
• Added: - ShopPanel to home sidebar - DIssenter shop redux, api route/controller
This commit is contained in:
47
app/javascript/gabsocial/actions/shop.js
Normal file
47
app/javascript/gabsocial/actions/shop.js
Normal file
@@ -0,0 +1,47 @@
|
||||
import api from '../api'
|
||||
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'
|
||||
|
||||
export const fetchFeaturedProducts = () => {
|
||||
return function (dispatch, getState) {
|
||||
if (!me) return
|
||||
|
||||
dispatch(fetchFeaturedProductsRequest('featured'))
|
||||
|
||||
api(getState).get(`/api/v1/shop?type=featured_products`).then((response) => {
|
||||
try {
|
||||
dispatch(fetchFeaturedProductsSuccess(response.data.data, 'featured'))
|
||||
} catch (error) {
|
||||
//
|
||||
}
|
||||
}).catch(function (error) {
|
||||
dispatch(fetchFeaturedProductsFail(error, 'featured'))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function fetchFeaturedProductsRequest(listType) {
|
||||
return {
|
||||
type: SHOP_FEATURED_PRODUCTS_FETCH_REQUEST,
|
||||
listType,
|
||||
}
|
||||
}
|
||||
|
||||
function fetchFeaturedProductsSuccess(items, listType) {
|
||||
return {
|
||||
type: SHOP_FEATURED_PRODUCTS_FETCH_SUCCESS,
|
||||
items,
|
||||
listType,
|
||||
}
|
||||
}
|
||||
|
||||
function fetchFeaturedProductsFail(error, listType) {
|
||||
return {
|
||||
type: SHOP_FEATURED_PRODUCTS_FETCH_FAIL,
|
||||
error,
|
||||
listType,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user