UNPKG

@kadconsulting/dry

Version:
39 lines 1.96 kB
import { jsx as _jsx } from "react/jsx-runtime"; import { useState, forwardRef } from 'react'; import classnames from 'classnames'; // import * as Utils from "./AttachmentsModal.utils.js"; import './AttachmentsModal.scss'; import Modal from '../Modal/Modal'; import Attachments from '../Attachments/Attachments'; import { AllowedFileTypes } from '../Attachments/AttachmentsTypes'; const AttachmentsModal = forwardRef(({ id, className, isOpen, closeModal, onSubmit }, ref) => { const [selectedFiles, setSelectedFiles] = useState([]); const clearStateAndCloseModal = () => { setSelectedFiles([]); closeModal(); }; const handleSubmit = () => { if (selectedFiles) { onSubmit(selectedFiles); } clearStateAndCloseModal(); }; const handleFileSelection = (files) => { setSelectedFiles(files); }; return (_jsx(Modal, { isOpen: isOpen, onClose: clearStateAndCloseModal, headerText: 'Upload and attach files', subHeaderText: 'Upload and attach files to this project.', leftButtonHandler: clearStateAndCloseModal, leftButtonText: 'Cancel', leftButtonType: 'secondary', rightButtonHandler: handleSubmit, rightButtonText: 'Attach files', rightButtonType: 'primary', rightButtonDisabled: true, rightButtonNote: 'Under development - coming soon!', children: _jsx("div", { id: id, ref: ref, className: classnames(className, 'dry-attachments-modal'), children: _jsx("div", { className: 'dry-attachments-modal__form', children: _jsx(Attachments, { fileTypes: [ AllowedFileTypes.SVG, AllowedFileTypes.PNG, AllowedFileTypes.JPG, AllowedFileTypes.GIF, ], onFilesSelected: handleFileSelection, selectedFiles: selectedFiles }) }) }) })); }); export default AttachmentsModal; //# sourceMappingURL=AttachmentsModal.js.map