import React, {Component} from 'react';
import {connect} from 'react-redux';
import OrderDocumentsGroup from './OrderDocumentsGroup.jsx';
import {orderTexts} from '../../../constants/ordersConstants';

class OrderDocuments extends Component {
    render() {
        const {orderInfo} = this.props;

        return (
            <div id="order-documents" className="order-documents">
                {
                    orderInfo.packages.map(orderPackage => <OrderDocumentsGroup key={'order-package-' + orderPackage.idPackage} documentsGroup={orderPackage} />)
                }
                {
                    orderInfo.orderDocuments && <OrderDocumentsGroup key={'order-package-0'} documentsGroup={{documents: orderInfo.orderDocuments, packageName: orderTexts.labels.OTHER_DOCS}} />
                }
            </div>
        );
    }
}

const mapStateToProps = (state) => ({
    orderInfo: state.processReducer.orderInfo
});
export default connect(mapStateToProps)(OrderDocuments);
