/**
* External dependencies
*/
import { Component } from '@wordpress/element';
import { withSelect } from '@wordpress/data';
/**
* WooCommerce dependencies
*/
import { SETTINGS_STORE_NAME } from '@woocommerce/data';
/**
* Internal dependencies
*/
import './style.scss';
class Navigation extends Component {
renderMenuItem( item, depth = 0 ) {
const { slug, title, url } = item;
return (
{ title }
{ item.children && item.children.length && (
{ item.children.map( ( childItem ) => {
return this.renderMenuItem( childItem, depth + 1 );
} ) }
) }
)
}
render() {
const { items } = this.props;
return (
{ items.map( ( item ) => {
return this.renderMenuItem( item );
} ) }
);
}
}
export default withSelect( ( select ) => {
const items = select(
SETTINGS_STORE_NAME
).getSetting( 'wc_admin', 'wcNavigation' );
return { items };
} )( Navigation );