import ImmutablePropTypes from 'react-immutable-proptypes';
import React from 'react';
import Markdown from 'trc-client-core/src/components/Markdown';

var LearningPlanFooter = React.createClass({
    displayName: 'LearningPlanFooter',
    propTypes: {
        learningPlan: ImmutablePropTypes.map
    },
    render() {
        var {learningPlan} = this.props;
        if(!learningPlan) {
            return null;
        }

        const {additonalResource, footerText} = learningPlan.get('displayText').toJS();

        return <div>
            {this.renderAdditionalResources(additonalResource)}
            {this.renderFooter(footerText)}
        </div>
    },
    renderAdditionalResources(data) {
        if(data) {
            return <div>
                <hr/>
                <h3>Additional Resources</h3>
                <Markdown html={data}/>
            </div>;
        }
    },
    renderFooter(data) {
        if(data) {
            return <div>
                <hr/>
                <Markdown html={data}/>
            </div>;
        }
    }
});

module.exports = LearningPlanFooter;
