import React, { useRef, forwardRef } from 'react'; import range from 'lodash/range'; import get from 'lodash/get'; import { IconChevronRight, IconDots } from '@tabler/icons'; import classnames from 'classnames'; import Dropdown from '../../../../Dropdown'; import StyledWrapper from './StyledWrapper'; const CollectionItem = ({item, collectionId, actions, dispatch, activeRequestTabId}) => { const dropdownTippyRef = useRef(); const MenuIcon = forwardRef((props, ref) => { return (
); }); const iconClassName = classnames({ 'rotate-90': item.collapsed }); const itemRowClassName = classnames('flex collection-item-name items-center', { 'item-focused-in-tab': item.id == activeRequestTabId }); const handleClick = (event) => { let tippyEl = get(dropdownTippyRef, 'current.reference'); if(tippyEl && tippyEl.contains && tippyEl.contains(event.target)) { return; } dispatch({ type: actions.SIDEBAR_COLLECTION_ITEM_CLICK, itemId: item.id, collectionId: collectionId }); }; let indents = range(item.depth); const onDropdownCreate = (ref) => dropdownTippyRef.current = ref; const stopEventPropogation = (event) => { event.stopPropagation(); }; return (
{indents && indents.length ? indents.map((i) => { return (
 {/* Indent */}
); }) : null}
{item.items && item.items.length ? ( ) : null}
{item.name}
} placement='bottom-start'>
{ dropdownTippyRef.current.hide(); stopEventPropogation(e); console.log('Clicked'); }}> Add Request
{item.collapsed ? (
{item.items && item.items.length ? item.items.map((i) => { return }) : null}
) : null}
); }; export default CollectionItem;