import PropTypes from 'prop-types';

import { MENUS, MENU_LINK } from '../../menus';

const { BOTTOM_BAR_MENU, FOOTER_MENU, HOME_BAR_MENU, AUXILIARY_BAR_MENU } = MENUS;

export const linkShape = PropTypes.shape({
    isLocalized: PropTypes.bool,
    type: PropTypes.string,
    value: PropTypes.string
});

export const menuItemPropTypes = PropTypes.shape({
    isDisabled: PropTypes.bool,
    isVisible: PropTypes.bool,
    link: linkShape,
    openInNewTab: PropTypes.bool,
    title: linkShape,
    type: PropTypes.string,
    uuid: PropTypes.string
});

export const menuMainItemPropTypes = PropTypes.shape({
    children: PropTypes.oneOfType(
        [
            PropTypes.arrayOf(menuItemPropTypes),
            PropTypes.oneOf([null]),
            PropTypes.oneOf([undefined])
        ]
    ),
    menuItemPropTypes
});


export const menuPropTypes = PropTypes.arrayOf(
    menuMainItemPropTypes
);

export const menusPropTypes = PropTypes.shape({
    [BOTTOM_BAR_MENU]: PropTypes.shape({
        menu: menuPropTypes,
        menuType: MENU_LINK
    }),
    [FOOTER_MENU]: PropTypes.shape({
        menu: menuPropTypes,
        menuType: MENU_LINK
    }),
    [HOME_BAR_MENU]: PropTypes.shape({
        menu: menuPropTypes,
        menuType: MENU_LINK
    }),
    [AUXILIARY_BAR_MENU]: PropTypes.shape({
        menu: menuPropTypes,
        menuType: 'MENU_LINK'
    })
});
