import React, { useState, useEffect } from 'react'; import { faFolder } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import StyledWrapper from './StyledWrapper'; import Modal from '../Modal'; const SaveRequestButton = ({folders}) => { const [openSaveRequestModal, setOpenSaveRequestModal] = useState(false); const [showFolders, setShowFolders] = useState([]); useEffect(() => { setShowFolders(folders); }, [folders, openSaveRequestModal]) const handleFolderClick = (folder) => { let subFolders = []; for (let item of folder.items) { if (item.items) { subFolders.push(item) } } subFolders.length ? setShowFolders(subFolders) : setShowFolders((prev) => prev); } return ( {openSaveRequestModal ? ( setOpenSaveRequestModal(false)} handleConfirm = {() => setOpenSaveRequestModal(false)} >

Select a folder to save request:

{showFolders && showFolders.length ? showFolders.map((folder) => (
handleFolderClick(folder)} > {folder.name}
)): null}
): null}
) }; export default SaveRequestButton;