Implement shop search and refactor

This commit is contained in:
Almira Krdzic
2018-10-17 00:36:19 +02:00
parent afab22a30b
commit 8769606a4b
24 changed files with 379 additions and 182 deletions

View File

@@ -42,7 +42,7 @@ export const fetchPackageDetails = (params) => {
return dispatch => {
dispatch(requestPackageDetails());
return client.fetch({
url: `${API_SERVER}/wp-json/wc/v2/products/${params.idPackage}?cl_id=${params.shopId}`,
url: `${API_SERVER}/wp-json/wc/v2/products/${params.idPackage}?shop_id=${params.shopId}`,
method: 'get'
})
.then(response => {

View File

@@ -29,7 +29,7 @@ export const fetchShopPackages = (shop, search) => {
let searchParam = search ? '?search=' +search : ''
return client.fetch({
url: `${API_SERVER}/wp-json/wc/v2/products?cl_id=${shop.id}` + searchParam,
url: `${API_SERVER}/wp-json/wc/v2/products?shop_id=${shop.id}` + searchParam,
})
.then(response => {
if (response.data) {
@@ -59,10 +59,11 @@ const generateShopOptions = (shops) => {
return shops;
}
export const fetchShops = () => {
export const fetchShops = (userId) => {
return dispatch => {
dispatch(requestShops());
return client.fetch({url: `${API_SERVER}/wp-json/wiaas/customer/0/shops` })
return client.fetch({url: `${API_SERVER}/wp-json/wiaas/customer/${userId}/shops` })
.then(response => {
if(response.data){

View File

@@ -16,7 +16,7 @@ class CoMarketCatalogSelect extends Component {
}
componentDidMount() {
this.props.dispatch(fetchShops());
this.props.dispatch(fetchShops(this.props.userInfo.wiaas_id_user));
if(this.props.shops && this.props.cartItems && this.props.activeModule==='cart'){
const cartShop = this.props.shops.find( shop => { return shop.id===this.props.cartItems[0].idCommercialLead });
@@ -80,7 +80,8 @@ const mapStateToProps = (state) => ({
selectedShop: state.coMarketPackagesReducer.selectedShop,
idPackage: state.coMarketReducer.idPackage,
cartItems: state.cartReducer.cartItems,
activeSubmodule: state.pageReducer.activeSubmodule
activeSubmodule: state.pageReducer.activeSubmodule,
userInfo: state.auth.userInfo
});
export default connect(mapStateToProps)(CoMarketCatalogSelect);