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 isFile = getType(type) === 'file';
const renderFile = () => <FileIcon fileType={type} />;
const renderImage = () => <Image src={url} />;
if (hasError) {
return (
<Wrapper isFile>
<BrokenFile />
</Wrapper>
);
}
return (
<Wrapper isFile={isFile || hasError}>
{!hasError && isFile && renderFile()}
{!hasError && !isFile && renderImage()}
{hasError && <BrokenFile />}
</Wrapper>
<Wrapper isFile={isFile}>{isFile ? <FileIcon fileType={type} /> : <Image src={url} />}</Wrapper>
);
};