import { Component } from 'react';
import { connect } from 'react-redux';
import PreconditionButton from './PreconditionButton';
import { emptyConditionCards } from './conditionsOrFilters/CardCreator';
import Anything from './conditionsOrFilters/conditions/Anything';

class PreconditionsList extends Component {

    render() {
        return <div className="space-y-1 flex-0">
            {emptyConditionCards.filter(conditonCard => conditonCard.constructor.TYPE !== Anything.TYPE && !this.props.preconditions.find(({type}) => type === conditonCard.constructor.TYPE)).map(
                conditionCard => {
                    return <PreconditionButton key={conditionCard.getTitle()} conditionCard={conditionCard}/>
                }
            )}
        </div>;
    }
}

export default connect(PreconditionsList.mapStateToProps, {})(PreconditionsList);