import React from 'react';
import {connect} from 'react-redux';

export class taskDetails extends React.Component {

    render() {
        if (!this.props.currentTask.description) {
            if(this.props.currentTask.length !== 0) {
                return (<h4 className="alert alert-warning task-info">No description for task: {this.props.currentTask.taskName}</h4>)
            }
            return (<h4 className="alert alert-info task-info">Select task to view description...</h4>)

        }
        return (
            <div className="card task-info">
                <div className="card-header">
                    <h4>{this.props.currentTask.taskName}</h4>
                </div>
                <div className="card-block word-wrap">
                    <h5 >{this.props.currentTask.description}</h5>
                </div>
            </div>
        );
    }
}


function mapStateToProps(state) {
    return {
        currentTask: state.activeTask
    };
}

export default connect(mapStateToProps, null)(taskDetails);