import React from 'react'; import PropTypes from 'prop-types'; import { Checkbox } from '@buffetjs/core'; import { get } from 'lodash'; import { createMatrix } from '../../utils'; import Card from '../Card'; import CardControlsWrapper from '../CardControlsWrapper'; import ListWrapper from '../ListWrapper'; const List = ({ clickable, data, onChange, onClickEditFile, selectedItems, canSelect }) => { const matrix = createMatrix(data); const handleClick = e => { e.stopPropagation(); }; return ( {matrix.map(({ key, rowContent }) => { return (
{rowContent.map(item => { const { id } = item; const url = get(item, ['formats', 'thumbnail', 'url'], item.url); const checked = selectedItems.findIndex(file => file.id === id) !== -1; const fileUrl = url.startsWith('/') ? `${strapi.backendURL}${url}` : url; return (
{(checked || canSelect) && ( )}
); })}
); })}
); }; List.defaultProps = { clickable: false, canSelect: true, data: [], onChange: () => {}, onClickEditFile: () => {}, selectedItems: [], }; List.propTypes = { clickable: PropTypes.bool, canSelect: PropTypes.bool, data: PropTypes.array, onChange: PropTypes.func, onClickEditFile: PropTypes.func, selectedItems: PropTypes.array, }; export default List;