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-01-31 19:40:26 +01:00
|
|
|
const AssetPreview = ({ name, claimId, fileExt, contentType }) => {
|
|
|
|
const directSourceLink = `${claimId}/${name}.${fileExt}`;
|
2018-01-31 23:50:35 +01:00
|
|
|
const showUrlLink = `${claimId}/${name}`;
|
2018-02-01 01:00:11 +01:00
|
|
|
return (
|
2018-02-07 07:28:17 +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':
|
|
|
|
return (
|
2018-02-07 07:28:17 +01:00
|
|
|
<img className={'asset-preview'} src={directSourceLink} alt={name}/>
|
2018-02-01 01:00:11 +01:00
|
|
|
);
|
|
|
|
case 'image/gif':
|
|
|
|
return (
|
2018-02-07 07:28:17 +01:00
|
|
|
<img className={'asset-preview'} src={directSourceLink} alt={name}/>
|
2018-02-01 01:00:11 +01:00
|
|
|
);
|
|
|
|
case 'video/mp4':
|
|
|
|
return (
|
2018-02-07 07:28:17 +01:00
|
|
|
<video className={'asset-preview'}>
|
2018-02-01 01:00:11 +01:00
|
|
|
<source src={directSourceLink} type={contentType}/>
|
|
|
|
</video>
|
|
|
|
);
|
|
|
|
default:
|
|
|
|
return (
|
|
|
|
<p>unsupported file type</p>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
})()}
|
|
|
|
</Link>
|
|
|
|
</div>
|
|
|
|
);
|
2018-01-30 20:46:22 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
export default AssetPreview;
|