/**
 * React Native Full App (https://store.enappd.com/product/react-native-full-app)
 *
 * Copyright © 2019-present Enappd. All rights reserved.
 *
 * This source code is licensed as per the terms found in the
 * LICENSE.md file in the root directory of this source tree.
 */
import React from 'react';
import MycartView from './MyCartView';
import { NavigationStackScreenProps } from 'react-navigation-stack';
import { connect } from 'react-redux';
import { AppReduxState } from '../../../redux/reducers';
import { bindActionCreators } from 'redux';

interface Iprops extends NavigationStackScreenProps, AppReduxState {
}

interface Istates {
}

class MycartContainer extends React.Component<Iprops,Istates> {
    
    state = {};

    goForDeliver = () => {
        this.props.navigation.navigate('DeliveryDetails')
    }

    goBack = () => {
        const { navigation } = this.props;
        navigation.pop();
    }

    render() {
        return (
            <MycartView
                actualPrice={this.props.cart.cartValue}
                deliveryCharge={49}
                goForDeliver={this.goForDeliver}
                cartItems={this.props.cart.cartProducts}
                goBack={this.goBack}
            />
        )
    }
}

const mapStateToProps = (state:AppReduxState) => {
    return{
      cart: state.cart
    };
  }
  const matchDispatchToProps = (dispatch:any) => ({
      actions: bindActionCreators({},dispatch)
  })


export default connect(mapStateToProps,matchDispatchToProps)(MycartContainer);
