import React from 'react';
import PropTypes from 'prop-types';
import './styles/Badge.scss';
import { createNamespace } from '../../tools/namingTools';

const n = createNamespace('Badge');

const Badge = ({
    label,
    className,
    type,
    ...otherProps
}) => {
    const specificProps = n('wrapper', type).withClass(className).withTestId().withE2EId().props;

    return (
        <span {...otherProps} {...specificProps}>{label}</span>
    );
};

Badge.allowedTypes = ['default', 'error', 'success', 'emphasis', 'pending'];

Badge.propTypes = {
    className: PropTypes.string,
    label: PropTypes.string,
    type: PropTypes.oneOf(Badge.allowedTypes)
};

Badge.defaultProps = {
    className: '',
    label: '',
    type: 'default'
};

export default Badge;
