import React from 'react';
import PropTypes from 'prop-types';
import { createNamespace } from '../../tools/namingTools';
// IMPORTANT: (s)css should be imported after other atoms/components
import './styles/Badge.scss';

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;
