reseller to customer

This commit is contained in:
Almira Krdzic
2018-10-16 06:45:28 +02:00
parent b7ac53d195
commit afab22a30b
37 changed files with 852 additions and 152 deletions

View File

@@ -1,5 +1,4 @@
import React, {Component} from 'react';
import {cartTexts} from '../../../constants/cartConstants';
class CartIcon extends Component {
render() {

View File

@@ -1,10 +1,9 @@
@import '../../../styleConstants.scss';
#cart-count {
vertical-align: middle;
vertical-align: sub;
color: $accentColor;
font-size: 1.5rem;
border-radius: 1rem;
font-size: 1.6rem;
font-family: arial,sans-serif;
}

View File

@@ -17,7 +17,7 @@ class CoMarketContainer extends Component {
return (<Container fluid={true} id="co-market-container">
{
urlParams.idPackage ?
<CoMarketPackageDetailsContainer idPackage={urlParams.idPackage} idCommercialLead={urlParams.idCommercialLead}/> :
<CoMarketPackageDetailsContainer idPackage={urlParams.idPackage} shopId={urlParams.shopId}/> :
<CoMarketPackagesContainer/>
}
</Container>);

View File

@@ -16,8 +16,8 @@ class CoMarketNavContainer extends Component {
handleSearchChange(event) {
this.setState({searchValue: event.target.value});
if (this.props.selectedCommercialLead) {
this.props.dispatch(fetchShopPackages(this.props.selectedCommercialLead, event.target.value));
if (this.props.selectedShop) {
this.props.dispatch(fetchShopPackages(this.props.selectedShop, event.target.value));
}
}
@@ -42,7 +42,7 @@ class CoMarketNavContainer extends Component {
}
const mapStateToProps = (state) => ({
selectedCommercialLead: state.coMarketPackagesReducer.selectedCommercialLead
selectedShop: state.coMarketPackagesReducer.selectedShop
});
export default connect(mapStateToProps)(CoMarketNavContainer);

View File

@@ -26,14 +26,15 @@ class CoMarketPackageDetailsContainer extends Component {
selectedPackage: this.props.selectedPackage,
selectedAgreement: this.props.selectedAgreement,
selectedOptions: this.props.selectedOptions,
selectedAdditionals: this.props.selectedAdditionals
selectedAdditionals: this.props.selectedAdditionals,
shopId: this.props.shopId,
};
this.props.dispatch(addToCart(addParams));
}
componentDidMount() {
const {idPackage, idCommercialLead} = this.props;
this.props.dispatch(fetchPackageDetails({idPackage, idCommercialLead}));
const {idPackage, shopId} = this.props;
this.props.dispatch(fetchPackageDetails({idPackage, shopId}));
}
render() {

View File

@@ -1,6 +1,10 @@
import React, {Component} from 'react';
import {connect} from 'react-redux';
import {Row, Col} from 'reactstrap';
import {
Navbar,
Row,
Col
} from 'reactstrap';
import ShopItem from './components/ShopItem.jsx';
import WiaasBox from '../../mainComponents/box/WiaasBox.jsx';
import CoMarketNavContainer from './CoMarketNavContainer.jsx';
@@ -8,16 +12,19 @@ import {fetchShopPackages} from '../../actions/coMarket/coMarketPackagesActions'
class CoMarketPackagesContainer extends Component {
componentDidMount() {
if (this.props.selectedCommercialLead) {
this.props.dispatch(fetchShopPackages(this.props.selectedCommercialLead));
if (this.props.selectedShop) {
this.props.dispatch(fetchShopPackages(this.props.selectedShop));
}
}
render() {
const {shopPackages, selectedCommercialLead, isLoading} = this.props;
const {shopPackages, selectedShop, isLoading} = this.props;
return (
<div id="co-market-shop">
<Col>
<Navbar></Navbar>
</Col>
<Row>
<Col xl="8" lg="8" md="8" sm="12" xs="12">
<WiaasBox id="co-market-big-commercial">
@@ -43,7 +50,7 @@ class CoMarketPackagesContainer extends Component {
{
(shopPackages && !isLoading) &&
shopPackages.map((shopPackage, mapKey) => <ShopItem key={shopPackage.id}
idCommercialLead={selectedCommercialLead.value}
shopId={selectedShop.id}
shopPackage={shopPackage}/>)
}
</Row>
@@ -57,7 +64,7 @@ class CoMarketPackagesContainer extends Component {
const mapStateToProps = (state) => ({
shopPackages: state.coMarketPackagesReducer.shopPackages,
selectedCommercialLead: state.coMarketPackagesReducer.selectedCommercialLead,
selectedShop: state.coMarketPackagesReducer.selectedShop,
isLoading: state.coMarketPackagesReducer.isLoading
});

View File

@@ -1,14 +1,14 @@
import React, {Component} from 'react';
import {connect} from 'react-redux';
import Select from 'react-select';
import {fetchShopPackages, fetchShopCommercialLeads, selectCommercialLead} from '../../../actions/coMarket/coMarketPackagesActions';
import {fetchShopPackages, fetchShops, selectShop} from '../../../actions/coMarket/coMarketPackagesActions';
import {coMarketTexts} from '../../../constants/coMarketConstants';
class CoMarketCatalogSelect extends Component {
constructor(props) {
super(props);
this.handleClChange = this.handleClChange.bind(this);
this.handleShopChange = this.handleShopChange.bind(this);
this.handleSearchChange = this.handleSearchChange.bind(this);
this.state = {
searchValue : ''
@@ -16,56 +16,57 @@ class CoMarketCatalogSelect extends Component {
}
componentDidMount() {
this.props.dispatch(fetchShopCommercialLeads());
this.props.dispatch(fetchShops());
if(this.props.commercialLeads && this.props.cartItems && this.props.activeModule==='cart'){
const cl = this.props.commercialLeads.find((cl) => {return cl.idCommercialLead===this.props.cartItems[0].idCommercialLead});
this.props.dispatch(selectCommercialLead(cl));
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 });
this.props.dispatch(selectShop(cartShop));
}
}
componentWillReceiveProps(nextProps){
if(nextProps.activeModule==='cart' && nextProps.commercialLeads && nextProps.cartItems && nextProps.cartItems.length > 0){
const cl = nextProps.commercialLeads.find((cl) => {return cl.idCommercialLead===nextProps.cartItems[0].idCommercialLead});
nextProps.dispatch(selectCommercialLead(cl));
}
// 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.commercialLeads && nextProps.idCommercialLead && nextProps.activeModule === 'co-market'){
const cl = nextProps.commercialLeads.find((cl) => {return cl.idCommercialLead===nextProps.idCommercialLead});
nextProps.dispatch(selectCommercialLead(cl));
if(nextProps.shops && nextProps.idCommercialLead && nextProps.activeModule === 'co-market'){
const shop = nextProps.shops.find( shop => {return shop.id === nextProps.idCommercialLead });
nextProps.dispatch(selectShop(shop));
}
}
handleClChange(cl) {
this.props.dispatch(selectCommercialLead(cl));
this.props.dispatch(fetchShopPackages(cl));
handleShopChange(shop) {
this.props.dispatch(selectShop(shop));
this.props.dispatch(fetchShopPackages(shop));
}
handleSearchChange(event) {
this.setState({searchValue: event.target.value});
if (this.props.selectedCommercialLead) {
this.props.dispatch(fetchShopPackages(this.props.selectedCommercialLead, event.target.value));
if (this.props.selectedShop) {
this.props.dispatch(fetchShopPackages(this.props.selectedShop, event.target.value));
}
}
render() {
const {commercialLeads, selectedCommercialLead, idPackage, activeSubmodule} = this.props;
const {shops, selectedShop, idPackage, activeSubmodule} = this.props;
const isDisabled = (idPackage || this.props.activeModule === 'cart') ? true : false;
return (
<div id="co-market-catalog">
{
commercialLeads && activeSubmodule !== 'orders' &&
shops && activeSubmodule !== 'orders' &&
<div className="filters co-market-nav-div">
<div className="filter-name">{coMarketTexts.labels.CATALOGUE}:</div>
<Select value={selectedCommercialLead}
<Select value={selectedShop}
name="commercialLead"
className="filter-select"
placeholder={coMarketTexts.labels.SELECT_CL}
options={commercialLeads}
options={shops}
disabled={isDisabled}
clearable={false}
onChange={(cl) => {this.handleClChange(cl)}}
onChange={shop => {this.handleShopChange(shop)}}
/>
</div>
}
@@ -75,8 +76,8 @@ class CoMarketCatalogSelect extends Component {
}
const mapStateToProps = (state) => ({
commercialLeads: state.coMarketPackagesReducer.commercialLeads,
selectedCommercialLead: state.coMarketPackagesReducer.selectedCommercialLead,
shops: state.coMarketPackagesReducer.shops,
selectedShop: state.coMarketPackagesReducer.selectedShop,
idPackage: state.coMarketReducer.idPackage,
cartItems: state.cartReducer.cartItems,
activeSubmodule: state.pageReducer.activeSubmodule

View File

@@ -9,7 +9,7 @@ class ShopItem extends Component {
}
render() {
const {shopPackage, idCommercialLead} = this.props;
const {shopPackage, shopId} = this.props;
return (
@@ -21,7 +21,7 @@ class ShopItem extends Component {
alt="Card image cap"/>
<CardBody>
<CardTitle className="shop-package-title">
<Link to={`/co-market/${idCommercialLead}/${shopPackage.id}`}>
<Link to={`/co-market/${shopId}/${shopPackage.id}`}>
{this.getShopItemPackageTitle(shopPackage.name)}
</Link>
</CardTitle>
@@ -34,7 +34,7 @@ class ShopItem extends Component {
<span className={'flag-icon flag-icon-' + shopPackage.countryCode}></span>
</div>
<div className="shop-package-details-btn-layer">
<Link id={'shop-package-details-' + shopPackage.id} to={`/co-market/${idCommercialLead}/${shopPackage.id}`}>
<Link id={'shop-package-details-' + shopPackage.id} to={`/co-market/${shopId}/${shopPackage.id}`}>
<Button className="shop-package-details-btn">{coMarketTexts.buttons.DETAILS}</Button>
</Link>
</div>