import React from 'react';
import PropTypes from 'prop-types';
import IDUtil from '../../../../util/IDUtil';
import classNames from 'classnames';
/*
HTML markup & CSS attributes:
	- regular span => .bg__classification
*/

class Classification extends React.Component {
    constructor(props) {
        super(props);
    }

    delete = () => {
        if (confirm('Are you sure you want to delete this code?')) {
            this.props.delete(this.props.classification);
        }
    };

    render() {
        return (
            <span
                className={classNames(
                    IDUtil.cssClassName('classification-type'),
                    'vocabulary-' +
                        this.props.classification.vocabulary.toLowerCase()
                )}
                title={
                    this.props.classification.id
                        ? this.props.classification.id
                        : 'Custom annotation'
                }
            >
                <div className="delete" title="Delete" onClick={this.delete} />
                {this.props.classification.label}
            </span>
        );
    }
}

Classification.propTypes = {
    classification: PropTypes.object,
    delete: PropTypes.func.isRequired
};
export default Classification;
