import * as React from 'react'; import {connect} from 'react-redux'; import * as Redux from 'redux'; import * as Actions from '../actions'; import {getListItems, IProductsModel, IAppState} from '../reducers' import {Grid, ListGroup, ListGroupItem, Glyphicon, Button, DropdownButton, MenuItem} from 'react-bootstrap'; import './listitems.scss'; interface IPropsFromState { items?: { id: string, name: string, checked: boolean }[]; products?: IProductsModel; } interface IPropsFromDispatch { dispatch: Redux.Dispatch } export interface ListItemProps extends IPropsFromState, IPropsFromDispatch { } const ListItems: React.StatelessComponent = (props) => { const unselectedProducts = props.products.products.filter(p=>props.items.map(p=>p.id).indexOf(p.id) < 0); const addItem = (eventKey: any, e: React.SyntheticEvent) => { props.dispatch(Actions.addListItem(unselectedProducts[eventKey].id)); console.log(eventKey,e); } return

Current List

{props.items.map((p, i) => { return { props.dispatch(Actions.toggleListItem(p.id)) } }>{p.name} }) } { unselectedProducts.length > 0 && { unselectedProducts.map((p, i) => {p.name} ) } }
} const mapStateToProps = (s: IAppState):IPropsFromState => { return { items: getListItems(s), products: s.products } }; export default connect(mapStateToProps)(ListItems);