import ImmutablePropTypes from 'react-immutable-proptypes';
import React from 'react';
import {Link} from 'react-router';

var LearningPlanLink = React.createClass({
    displayName: 'LearningPlanLink',
    propTypes: {
        learningPlan: ImmutablePropTypes.map,
        participantId: React.PropTypes.string
    },
    render() {
        var {participantId, learningPlan} = this.props;

        if(!learningPlan) {
            return null;
        }

        // Defaults
        var icon = 0xE423;
        var link = `/portal/learning-plan/${learningPlan.get('careerPlanId')}`

        // Certifications
        if(learningPlan.get('type') === 'Certification') {
            icon = 0xE075;
        }


        switch (learningPlan.get('careerPlanId')) {
            case 'technical_career_plan':
                link = `/learning-plan/${learningPlan.get('careerPlanId')}`;
                break;

            case 'product_training_plan':
            case 'product_training_plan_lexus':
                icon = 0xE006;
                break;

            case 'technical_overview':
                link = `/learning-plan/technical_career_plan`;
                break;
        }

        return <Link
            to={link}
            query={{participantId}}
            className={this.props.className}
            data-icon={String.fromCharCode(icon)}>
            {this.props.children}
        </Link>;
    }
});

module.exports = LearningPlanLink;
