import React from 'react';
import style from './attributes.module.sass';
import {connect} from 'react-redux';
import {dynamicSearchGoodsConstants} from "../../../../../constants/typesComponents";
import DynamicSearchGoods from "../../../../inputs/dynamicSearchGoods/dynamicSearchGoods";
import GoodsAttributeElement from '../goods/goodsAttributeElement/goodsAttributeElement';
import {typesGoodsAttributeElement} from "../../../../../constants/goods";

const Attributes = (props) => {
    const {goodsData} = props;
    const {GoodsAttributes} = goodsData;


    return (
        <div className={style.mainContainer}>
            <h1>Обновить аттрибут</h1>
            <DynamicSearchGoods
                type={dynamicSearchGoodsConstants.GOODS_UPDATER}
            />
            <div className={style.goodsAttributesContainer}>
                {
                    GoodsAttributes && GoodsAttributes.map(goodsAttribute => (
                        <GoodsAttributeElement
                            {...goodsAttribute}
                            typeElement={typesGoodsAttributeElement.OLD_ELEMENT}
                        />
                    ))
                }
                {
                    GoodsAttributes && (
                        <GoodsAttributeElement
                            typeElement={typesGoodsAttributeElement.NEW_ELEMENT}
                        />
                    )
                }
            </div>
        </div>
    )
};

const mapStateToProps = state => {
    const {goodsData} = state.createGoodsReducers;

    return {
        goodsData
    }
};

const mapDispatchToProps = dispatch => ({

});

export default connect(mapStateToProps, mapDispatchToProps)(Attributes);