import React from "react" import PropTypes from "prop-types" import { Column, List, Button } from "ui" import { sizeInfo } from "ui/style" export class MasterList extends React.Component { static propTypes = { capitalizedName: PropTypes.string, items: PropTypes.array, listData: PropTypes.func, onItemListClick: PropTypes.func, selectedItem: PropTypes.object, selectionModified: PropTypes.bool, onAddNewItem: PropTypes.func, } constructor(props) { super(props) this.state = { items: null, } } componentWillReceiveProps(nextProps) { if (nextProps.items !== this.props.items) { this.setState({ items: nextProps.items }) } } render() { const { selectedItem, selectionModified, capitalizedName } = this.props const { items } = this.state return ( { const data = item._id ? this.props.listData(item) : { icon: "blank", text: `[New ${capitalizedName}]`, } return ( this.props.onItemListClick(e, index)} open={item === this.props.selectedItem}> {data.text} {item === selectedItem && selectionModified ? ( ) : null} ) }} />