import React from "react";
import { connect } from "redux-bundler-react";
import TreeListItem from "./tree-list-item";

class TreeList extends React.Component {
  render() {
    const { items, collapsed, listStyle, showFavorites, showUserDefaultLayers } = this.props;
    
    if (!!collapsed) return null;
    if (items.length === 0 && showUserDefaultLayers ) return <div>no user default layers selected</div>;
    if (items.length === 0 && showFavorites ) return <div>no favorites selected</div>;
    return (
      <ul className="cm-tree-list" style={listStyle}>
        {items.map(function (item, i) {
          return (
            <TreeListItem
              key={item.uid}
              item={item}
              collapsed={item.collapsed}
              time={new Date()}
            />
          );
        })}
      </ul>
    );
  }
}

export default TreeList;
