From 4d87551fef608008fec9d58cd9443301102be154 Mon Sep 17 00:00:00 2001 From: Almira Krdzic Date: Sat, 20 Oct 2018 00:08:48 +0200 Subject: [PATCH] test --- .../wiaas/includes/api/class-wiaas-rest-customer.php | 2 +- frontend/src/actions/coMarket/coMarketPackagesActions.js | 1 - .../containers/coMarket/CoMarketPackagesContainer.jsx | 9 ++++++++- .../coMarket/components/CoMarketCatalogSelect.jsx | 8 ++++---- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/backend/app/plugins/wiaas/includes/api/class-wiaas-rest-customer.php b/backend/app/plugins/wiaas/includes/api/class-wiaas-rest-customer.php index 79bffe7..5d85152 100644 --- a/backend/app/plugins/wiaas/includes/api/class-wiaas-rest-customer.php +++ b/backend/app/plugins/wiaas/includes/api/class-wiaas-rest-customer.php @@ -73,7 +73,7 @@ class Wiaas_REST_Customer_API { $customer_shops = array_map(function($customer_shop) { return array( - 'id' => $customer_shop['owner_id'], + 'id' => absint($customer_shop['owner_id']), 'type' => $customer_shop['order_type'], 'name' => wiaas_get_organization_name($customer_shop['owner_id']) ); diff --git a/frontend/src/actions/coMarket/coMarketPackagesActions.js b/frontend/src/actions/coMarket/coMarketPackagesActions.js index 45b1a6e..a4a0a9d 100644 --- a/frontend/src/actions/coMarket/coMarketPackagesActions.js +++ b/frontend/src/actions/coMarket/coMarketPackagesActions.js @@ -74,7 +74,6 @@ export const fetchShops = (userId) => { if (shopOptions.length) { dispatch(selectShop(shopOptions[0])); - dispatch(fetchShopPackages(shopOptions[0])); } } }) diff --git a/frontend/src/containers/coMarket/CoMarketPackagesContainer.jsx b/frontend/src/containers/coMarket/CoMarketPackagesContainer.jsx index d847c15..08bc0e2 100644 --- a/frontend/src/containers/coMarket/CoMarketPackagesContainer.jsx +++ b/frontend/src/containers/coMarket/CoMarketPackagesContainer.jsx @@ -8,7 +8,7 @@ import { import ShopItem from './components/ShopItem.jsx'; import WiaasBox from '../../mainComponents/box/WiaasBox.jsx'; import CoMarketNavContainer from './CoMarketNavContainer.jsx'; -import {fetchShopPackages} from '../../actions/coMarket/coMarketPackagesActions'; +import {fetchShopPackages, selectShop} from '../../actions/coMarket/coMarketPackagesActions'; class CoMarketPackagesContainer extends Component { componentDidMount() { @@ -17,6 +17,13 @@ class CoMarketPackagesContainer extends Component { } } + componentWillReceiveProps(nextProps){ + if (nextProps.selectedShop && + (!this.props.selectedShop || this.props.selectedShop.id !== nextProps.selectedShop.id)) { + this.props.dispatch(fetchShopPackages(nextProps.selectedShop)); + } + } + render() { const {shopPackages, selectedShop, isLoading} = this.props; diff --git a/frontend/src/containers/coMarket/components/CoMarketCatalogSelect.jsx b/frontend/src/containers/coMarket/components/CoMarketCatalogSelect.jsx index 4f519cf..19c63fc 100644 --- a/frontend/src/containers/coMarket/components/CoMarketCatalogSelect.jsx +++ b/frontend/src/containers/coMarket/components/CoMarketCatalogSelect.jsx @@ -25,10 +25,10 @@ class CoMarketCatalogSelect extends Component { } componentWillReceiveProps(nextProps){ - // if(nextProps.activeModule==='cart' && nextProps.shops && nextProps.cartItems && nextProps.cartItems.length > 0){ - // const cartShop = this.props.shops.find( shop => { return shop.id === this.props.cartItems[0].idCommercialLead }); - // nextProps.dispatch(selectShop(cartShop)); - // } + if(nextProps.activeModule==='cart' && nextProps.shops && nextProps.cartItems && nextProps.cartItems.length > 0){ + const cartShop = nextProps.shops.find( shop => { return shop.id === nextProps.cartItems[0].idCommercialLead }); + nextProps.dispatch(selectShop(cartShop)); + } if(nextProps.shops && nextProps.idCommercialLead && nextProps.activeModule === 'co-market'){ const shop = nextProps.shops.find( shop => {return shop.id === nextProps.idCommercialLead });