import Node from '@/components/dashboard/library/Node'; import { TreeProps } from '@/components/dashboard/library/types'; import React from 'react'; type BranchProps = { item: TreeProps['data'][number]; level: number; }; function Branch({ item, level }: BranchProps): React.JSX.Element { const [expanded, setExpanded] = React.useState(item.initiallyExpanded ?? false); const hasChild = item?.children?.length; const renderSubBranches = () => { if (hasChild) { const newLevel = level + 1; return item?.children?.map((el) => ); } }; const onExpand = () => { setExpanded((prev) => !prev); }; return (
{expanded && renderSubBranches()}
); } export default Branch;