import LearningPlanList from 'trc-client-core/src/learningPlan/LearningPlanList';
import PathwayStore from 'trc-client-core/src/course/PathwayStore';
import React from 'react';
import Reflux from 'reflux';
import UserStore from 'trc-client-core/src/user/UserStore';

var LearningPlanListCurrentParticipant = React.createClass({
    displayName: 'LearningPlanListCurrentParticipant',
    propTypes: {
        participantId: React.PropTypes.string,
        filter: React.PropTypes.array
    },
    mixins:[
        Reflux.listenTo(PathwayStore, 'onStoreChange'),
        require('reflux-immutable/StoreMixin')
    ],
    getDefaultProps() {
        return {
            participantId: UserStore.get('participantId')
        };
    },
    getStoreState() {
        return {
            learningPlans: PathwayStore.get('learningPlans')
        };
    },
    render() {
        if(this.state.learningPlans && this.state.learningPlans.size !== 0) {
            return <li>
                <LearningPlanList
                    itemClassNamePrefix="IconList-"
                    learningPlans={this.state.learningPlans}
                    filter={this.props.filter}
                />
            </li>;
        }

        return null;
    }
});

module.exports = LearningPlanListCurrentParticipant;
