constant naming

This commit is contained in:
Virginie Ky 2019-09-18 18:56:04 +02:00
parent dfe3922ca7
commit 1a82ba625e

View File

@ -13,7 +13,7 @@ import {
} from './StyledMediaPreviewList'; } from './StyledMediaPreviewList';
function MediaPreviewList({ hoverable, files }) { function MediaPreviewList({ hoverable, files }) {
const maxLength = 3; const IMAGE_PREVIEW_COUNT = 3;
const getFileType = fileName => fileName.split('.').slice(-1)[0]; const getFileType = fileName => fileName.split('.').slice(-1)[0];
const getSrc = fileURL => const getSrc = fileURL =>
fileURL.startsWith('/') ? `${strapi.backendURL}${fileURL}` : fileURL; fileURL.startsWith('/') ? `${strapi.backendURL}${fileURL}` : fileURL;
@ -74,8 +74,9 @@ function MediaPreviewList({ hoverable, files }) {
return files.map((file, index) => { return files.map((file, index) => {
return ( return (
<React.Fragment key={JSON.stringify(file)}> <React.Fragment key={JSON.stringify(file)}>
{index === maxLength && files.length - maxLength > 1 {index === IMAGE_PREVIEW_COUNT &&
? renderText(files.length - maxLength) files.length > IMAGE_PREVIEW_COUNT + 1
? renderText(files.length - IMAGE_PREVIEW_COUNT)
: renderItem(file)} : renderItem(file)}
</React.Fragment> </React.Fragment>
); );