import { useState } from 'react';
import { v4 as uuidv4 } from 'uuid';
import PropTypes from 'prop-types';
import { Button, ListGroup } from 'react-bootstrap';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faTree, faFile, faFolder, faFolderOpen } from '@fortawesome/free-solid-svg-icons';
function TreeItem({ treeData, types }) {
const [isOpen, setIsOpen] = useState(true);
if (treeData.children) {
return (
{treeData.data}
{treeData.children.map((children) => (
))}
);
}
return (
{treeData.icon ?? types.file.icon}
{treeData.data}
);
}
TreeItem.propTypes = {
treeData: PropTypes.object.isRequired,
types: PropTypes.object.isRequired,
};
function Tree({ treeList, types = { drive: {}, folder: {}, file: {} } }) {
const typeProps = {
drive: { ...{ title: 'Root', icon: }, ...types.drive },
folder: { ...{ icon: }, ...types.folder },
file: { ...{ icon: }, ...types.file },
};
return (
{typeProps.drive.icon}
{typeProps.drive.title}
{treeList.map((treeData) => (
))}
);
}
Tree.propTypes = {
treeList: PropTypes.array.isRequired,
types: PropTypes.object,
};
export default Tree;