import React, {Component} from 'react';
import {connect} from 'react-redux';
import {Container} from 'reactstrap';
import CoMarketPackagesContainer from './CoMarketPackagesContainer.jsx';
import CoMarketPackageDetailsContainer from './CoMarketPackageDetailsContainer.jsx';
import {setPackageFromUrl} from '../../actions/coMarket/coMarketActions';
import './style/CoMarket.css'

class CoMarketContainer extends Component {
    componentDidMount(){
        this.props.dispatch(setPackageFromUrl(this.props.match.params.idPackage));
    }

    render() {
        const urlParams = this.props.match.params;

        return (<Container fluid={true} id="co-market-container">
            {
                urlParams.idPackage ?
                <CoMarketPackageDetailsContainer idPackage={urlParams.idPackage} shopId={urlParams.shopId}/> :
                <CoMarketPackagesContainer/>
            }
        </Container>);
    }
}

export default connect()(CoMarketContainer);
