import React from 'react';
import PropTypes from 'prop-types';
import {MenuItem as ReactBootstrapMenuItem} from 'react-bootstrap';

type MenuItemProps = {
    testAutomationId?: string;
    children: React.ReactNode;
} & ReactBootstrapMenuItem.MenuItemProps;

export class MenuItem extends React.Component<MenuItemProps> {
    static propTypes = {
        testAutomationId: PropTypes.string,
        children: PropTypes.node.isRequired
    };

    static defaultProps = {
        testAutomationId: null,
        children: null
    };

    render() {
        let {children, testAutomationId, ...props} = this.props;

        return (
            <ReactBootstrapMenuItem data-test-automation-id={testAutomationId} {...props}>
                {children}
            </ReactBootstrapMenuItem>
        );
    }
}
