import React from 'react';
import {withNamespaces} from "react-i18next";
import {MdMail} from "react-icons/md";

import {withTheme, injectSheet} from '../../lib/theme';
import RouteCascaded from '../../lib/RouteCascaded';

import Nav from "../../component/Nav/Nav";
import Sidebar from "../../layout/ControlPanel/Sidebar";
import StyleGrid from "../../lib/StyleGrid";

const theming = (theme) => ({
    sidebarTop: {
        margin: 'auto ' + theme.gutter.base + 'px',
        [StyleGrid.smUp]: {
            margin: '0 0 ' + theme.gutter.base * 2 + 'px 0',
        }
    }
});

class NavShop extends React.Component {

    render() {
        const { t} = this.props;

        const navContent = (match) => {
            let content = [];

            content.push({
                path: match.url + '/newsletter',
                lbl: {icon: (p) => <MdMail className={p.className} size={p.notxt ? '1.5em' : '1.125em'}/>, txt: t('nav.newsletter')},
            });


            return content;
        };

        //const SideBarTop = p => (<p className={classes.sidebarTop}>{t('sidebar.shop-nav')}</p>);

        return (
            <React.Fragment>
                <Sidebar
                    center={(props => <Nav path='/marketing' content={navContent} notxt={props.notxt}/>)}
                    textToggle={true}
                />

                {this.props.routes ? this.props.routes.map((route, i) => (
                    route.sidebar ?
                        <RouteCascaded key={i} {...route} component={route.sidebar}/> :
                        null
                )) : null}
            </React.Fragment>
        )
    };
}

export default withNamespaces('page--marketing')(withTheme(injectSheet(theming)(NavShop)));