import * as React from 'react'; import MuiList from '@mui/material/List'; import { ListItemIcon, ListItemText, ListItemButton, ListSubheader, Collapse } from '@mui/material'; import { ExpandLess, StarBorder, ExpandMore, ErrorOutline } from '@mui/icons-material'; import { ListType } from './types'; import { map } from 'lodash'; import { Avatar, Divider, ListItem, ListItemAvatar, Typography } from '@mui/material'; import { useBotConfig } from '@samagra-x/stencil-hooks'; export const List: React.FC = ({ items, label, noItem }) => { const [openItem, setOpenItem] = React.useState(null); const config = useBotConfig('component', 'historyPage'); const handleClick = React.useCallback( (id: string) => { if (id === openItem) setOpenItem(null); else setOpenItem(id); }, [openItem], ); const hasItems = React.useMemo(() => items?.length > 0, [items]); if (!hasItems) return ( {noItem?.icon ? React.cloneElement(noItem?.icon) : } ); return ( {label && {label}}} > {map(items, (item) => { console.log({ item }); return ( <> { ev.stopPropagation(); if (item?.items) { return handleClick(item?.id); } if (item?.onClick) return item?.onClick(item); return null; }} > {item.icon && {React.cloneElement(item.icon)}} {item.avatar && ( )} {item.label && ( {config?.showTimestamp && item?.secondaryLabel && ( {item?.secondaryLabel} )} } /> )} {item?.items && <>{openItem === item?.id ? : }} {item?.isDivider && } ); })} ); };