All Downloads are FREE. Search and download functionalities are using the official Maven repository.

META-INF.resources.js.components.digital-signature-form.FileEntryList.js Maven / Gradle / Ivy

The newest version!
/**
 * SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com
 * SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
 */

import {ClayButtonWithIcon} from '@clayui/button';
import ClayList from '@clayui/list';
import classNames from 'classnames';
import React from 'react';

const FileEntryList = ({errors, fileEntries = [], setFieldValue}) => {
	const hasError = (fileEntryId) => {
		if (errors) {
			return !!errors.find((entry) => entry.fileEntryId === fileEntryId);
		}

		return false;
	};

	const onRemoveFileEntry = (fileEntryIndex) => {
		setFieldValue(
			'fileEntries',
			fileEntries.filter((_, index) => index !== fileEntryIndex)
		);
	};

	if (!fileEntries.length) {
		return null;
	}

	return (
		
			
				{Liferay.Language.get('documents-added')}
			

			{fileEntries.map(({fileEntryId, title}, index) => (
				
					
						{title}

						{hasError(fileEntryId) && (
							
								{Liferay.Language.get(
									'this-file-extension-is-not-supported-by-docusign'
								)}
							
						)}
					

					
						 onRemoveFileEntry(index)}
							symbol="trash"
						/>
					
				
			))}
		
	);
};

export default FileEntryList;




© 2015 - 2024 Weber Informatics LLC | Privacy Policy