import React from 'react';
import { Image } from 'antd';
import PropTypes from 'prop-types';
import './style';
const InfoCollection = props => {
    const { data, gap = 8, wrapStyle = {} } = props;
    return (
        <div className="info-collection" style={wrapStyle}>
            {data.map(item => {
                let style = {};
                if (item.color) style.color = item.color;
                return (
                    <div className="info-line" key={item.key} style={{ marginBottom: gap }}>
                        <div className="label">{item.label}：</div>
                        <div className="value" style={style}>
                            {item.type === 'img'
                                ? item.value.map(e => {
                                      return (
                                          <Image
                                              style={{ width: 50, height: 50 }}
                                              key={e.id}
                                              alt={e.name}
                                              src={`/cloudFile/common/downloadFile?id=${e.id}`}
                                          />
                                      );
                                  })
                                : item.value || '--'}
                        </div>
                    </div>
                );
            })}
        </div>
    );
};

InfoCollection.propTypes = {
    data: PropTypes.any,
    gap: PropTypes.number,
    wrapStyle: PropTypes.object,
};
export default InfoCollection;
