import React from 'react'; import Button from 'core/ui/components/Button'; import {gettext, gettextPlural} from 'core/utils'; import {Modal} from 'core/ui/components/Modal/Modal'; import {ModalHeader} from 'core/ui/components/Modal/ModalHeader'; import {ModalBody} from 'core/ui/components/Modal/ModalBody'; import {ModalFooter} from 'core/ui/components/Modal/ModalFooter'; import {appConfig} from 'appConfig'; interface IProps { closeModal(): void; } interface IFileError { valid: boolean; name: string; width: number; height: number; type: string; } export function fileUploadErrorModal( invalidFiles: Array, ) { return class FileUploadErrorModal extends React.PureComponent { render() { if (invalidFiles.length > 0) { return ( { gettextPlural( invalidFiles.length, 'The file was not uploaded', 'Some files were not uploaded', ) } {invalidFiles.some((file) => file.type.startsWith('image')) && (

{ gettext( 'Minimum allowed image size is {{minWidth}}x{{minHeight}}', { minWidth: appConfig.pictures.minWidth, minHeight: appConfig.pictures.minHeight, }, ) }

)}
    { invalidFiles.map((file, index) => { if (file.type !== null) { if (file.type.startsWith('image')) { return (
  1. {gettext('The size of {{filename}} is {{width}}x{{height}}', { filename: file.name, width: file.width, height: file.height, }, )}
  2. ); } else { return (
  3. {gettext('Invalid File : {{name}}', { name: file.name, }, )}
  4. ); } } else { return null; } }) }
); } else { return null; } } }; }