2018-01-30 20:46:22 +01:00
|
|
|
import React from 'react';
|
2018-02-02 22:06:28 +01:00
|
|
|
import { Link } from 'react-router-dom';
|
2018-01-30 20:46:22 +01:00
|
|
|
|
2018-03-15 18:48:04 +01:00
|
|
|
const AssetPreview = ({ defaultThumbnail, claimData: { name, claimId, fileExt, contentType, thumbnail } }) => {
|
2018-01-31 19:40:26 +01:00
|
|
|
const directSourceLink = `${claimId}/${name}.${fileExt}`;
|
2018-02-23 20:04:17 +01:00
|
|
|
const showUrlLink = `/${claimId}/${name}`;
|
2018-02-01 01:00:11 +01:00
|
|
|
return (
|
2018-02-22 02:02:57 +01:00
|
|
|
<div className='asset-holder'>
|
2018-02-01 01:00:11 +01:00
|
|
|
<Link to={showUrlLink} >
|
|
|
|
{(() => {
|
|
|
|
switch (contentType) {
|
|
|
|
case 'image/jpeg':
|
|
|
|
case 'image/jpg':
|
|
|
|
case 'image/png':
|
|
|
|
case 'image/gif':
|
|
|
|
return (
|
2018-03-02 18:36:28 +01:00
|
|
|
<img
|
|
|
|
className={'asset-preview'}
|
|
|
|
src={directSourceLink}
|
|
|
|
alt={name}
|
|
|
|
/>
|
2018-02-01 01:00:11 +01:00
|
|
|
);
|
|
|
|
case 'video/mp4':
|
|
|
|
return (
|
2018-03-02 18:36:28 +01:00
|
|
|
<img
|
2018-03-04 21:17:03 +01:00
|
|
|
className={'asset-preview video'}
|
2018-03-02 18:36:28 +01:00
|
|
|
src={thumbnail || defaultThumbnail}
|
|
|
|
alt={name}
|
|
|
|
/>
|
2018-02-01 01:00:11 +01:00
|
|
|
);
|
|
|
|
default:
|
|
|
|
return (
|
|
|
|
<p>unsupported file type</p>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
})()}
|
|
|
|
</Link>
|
|
|
|
</div>
|
|
|
|
);
|
2018-01-30 20:46:22 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
export default AssetPreview;
|