/**
 * 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, { Component } from 'react';
import { Root } from 'native-base';
import ViewmorelistView from './viewmoreListView';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { selectProduct } from '../../../redux/actions/Product'
import { NavigationStackScreenProps } from 'react-navigation-stack';
import { AppReduxState } from '../../../redux/reducers';


interface Iprops extends NavigationStackScreenProps, AppReduxState {
    actions: any
  }
  
  interface Istates {
  }

class ViewmoreListContainer extends Component<Iprops,Istates> {
    constructor(props:Iprops) {
        super(props)
        this.state = {
        }
    }

    goBack = () => {
        this.props.navigation.goBack()
    }

    goforProductDetailPage = (items:any) =>  {
        const { navigation , actions } = this.props;
        actions.selectProduct(items)
        navigation.push('Productdetails');
    }

    goToMyCart = () => {
        this.props.navigation.navigate('Mycart')
    }

    render() {
        const name = 'arrow-left'
        const type = 'FontAwesome';
        const textTitle = 'Product List';
        const { product, cart } = this.props;
        return (
                <ViewmorelistView
                    cartItemLength={cart.cartItemNumber}
                    textTitle={textTitle}
                    type={type}
                    name={name}
                    goBack={this.goBack}
                    details={product.seeMoreProductList}
                    goforProductDetailPage={(items:any) => this.goforProductDetailPage(items)}
                    goToMyCart={this.goToMyCart}
                />
        )
    }
}

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

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