card preview statement

Signed-off-by: Virginie Ky <virginie.ky@gmail.com>
This commit is contained in:
Virginie Ky 2020-03-16 15:33:58 +01:00
parent 1a695b7da9
commit cfe0ddbff8

View File

@ -11,16 +11,16 @@ import Image from './Image';
const CardPreview = ({ hasError, url, type }) => { const CardPreview = ({ hasError, url, type }) => {
const isFile = getType(type) === 'file'; const isFile = getType(type) === 'file';
const renderFile = () => <FileIcon fileType={type} />; if (hasError) {
return (
const renderImage = () => <Image src={url} />; <Wrapper isFile>
<BrokenFile />
</Wrapper>
);
}
return ( return (
<Wrapper isFile={isFile || hasError}> <Wrapper isFile={isFile}>{isFile ? <FileIcon fileType={type} /> : <Image src={url} />}</Wrapper>
{!hasError && isFile && renderFile()}
{!hasError && !isFile && renderImage()}
{hasError && <BrokenFile />}
</Wrapper>
); );
}; };