import { Component } from 'react';
import { connect } from 'react-redux';
import NoPreconditions from './NoPreconditions';
import Testable from './Testable';

class CurrentPrecondtions extends Component {
    render() {
        if (!this.props.preconditions.length) {
            return <NoPreconditions />
        }

        return <div className="flex-shrink-0 space-y-4 mb-5">
            {this.props.preconditions.map((condition) => {
                return <Testable 
                            key={condition.temporaryID} 
                            conditionOrFilter={condition} 
                            testableType={'conditions'}
                            contextTemporaryID={this.props.context.temporaryID}
                            columnTemporaryID={this.props.column.temporaryID}
                        />
            })}
        </div>;
    }
}

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