META-INF.resources.js.import.ImportSubmit.js Maven / Gradle / Ivy
/**
* 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 ClayButton from '@clayui/button';
import PropTypes from 'prop-types';
import React, {useCallback, useState} from 'react';
import ImportModal from './ImportModal';
import ImportPreviewModal from './ImportPreviewModal';
function ImportSubmit({
evaluateForm,
fieldsSelections,
fileContent,
formDataQuerySelector,
formImportURL,
formIsValid,
}) {
const [modalVisibile, setModalVisibile] = useState(false);
const [stage, setStage] = useState('preview');
const showPreviewModal = useCallback(() => {
evaluateForm();
if (formIsValid) {
setModalVisibile(true);
}
}, [evaluateForm, formIsValid]);
return (
{Liferay.Language.get('next')}
{modalVisibile && stage === 'preview' && (
setModalVisibile(false)}
fieldsSelections={fieldsSelections}
fileContent={fileContent}
startImport={() => setStage('import')}
/>
)}
{modalVisibile && stage === 'import' && (
{
setModalVisibile(false);
setStage('preview');
}}
formDataQuerySelector={formDataQuerySelector}
formImportURL={formImportURL}
/>
)}
);
}
ImportSubmit.propTypes = {
formDataQuerySelector: PropTypes.string.isRequired,
formImportURL: PropTypes.string.isRequired,
};
export default ImportSubmit;
© 2015 - 2025 Weber Informatics LLC | Privacy Policy