2020-11-25 18:56:31 +01:00
|
|
|
import React, { memo } from 'react';
|
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
import MediaPreviewList from '../MediaPreviewList';
|
|
|
|
|
import RelationPreviewList from '../RelationPreviewList';
|
|
|
|
|
import { Truncate, Truncated } from './styledComponents';
|
|
|
|
|
|
2020-11-26 09:37:41 +01:00
|
|
|
const RowCell = ({ metadatas, type, value, relationType }) => {
|
2020-11-25 18:56:31 +01:00
|
|
|
if (type === 'media') {
|
|
|
|
|
return <MediaPreviewList files={value} />;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (type === 'relation') {
|
2020-11-26 09:37:41 +01:00
|
|
|
return <RelationPreviewList relationType={relationType} metadatas={metadatas} value={value} />;
|
2020-11-25 18:56:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Truncate>
|
|
|
|
|
<Truncated title={value}>{value}</Truncated>
|
|
|
|
|
</Truncate>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
RowCell.defaultProps = {
|
|
|
|
|
type: null,
|
|
|
|
|
value: null,
|
2020-11-26 09:37:41 +01:00
|
|
|
relationType: null,
|
2020-11-25 18:56:31 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
RowCell.propTypes = {
|
|
|
|
|
metadatas: PropTypes.object.isRequired,
|
2020-11-26 09:37:41 +01:00
|
|
|
relationType: PropTypes.string,
|
2020-11-25 18:56:31 +01:00
|
|
|
type: PropTypes.string,
|
|
|
|
|
value: PropTypes.any,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default memo(RowCell);
|