import React from 'react';
import LinkManager from 'modularity-front';
import Modularity from 'modularity-front';
import {Button , SideNav , SideNavItem} from 'react-materialize';
let Module = Modularity.Module;
let Link = LinkManager.Modules.Link;

class SideNavModule extends Modularity.Module {
    constructor(props){
        super(props);
        this.state = {

        }
    }

    render() {
        let NavItems = this.SideNavItems.value.map((item,index)=>{
            return(
                <SideNavItem 
                key={index}
                userView={item.userView || false}
                user = {item.user || {}}
                divider = {item.divider || false}
                subheader = {item.subheader || false}
                waves = {item.waves || false}
                href={item.link}
                onClick={(e) => { if(item.link)this.CoreSystem.go(item.link); e.preventDefault();} }
                >
                {item.content || ""}
                </SideNavItem>
            )
        })
        return(
            <SideNav trigger={this.props.trigger || <Button><i className={this.NavButton.value}></i></Button>}
            options ={this.Options.value}>
                {NavItems}
                {super.render()}
            </SideNav>
        );
    }
}

SideNavModule.Inputs = {
    SideNavItems : {
        type:Module.Types.Array,
        defaultValue:[
            {
                userView:true,
                content:"",
                link:"#",
                user:{
                    background:'card.jpg',
                    name: 'John Doe',
                    image: 'yuna.jpg',
                    email: 'jdandturk@gmail.com'
                    } 
            },
            {
                divider:true
            },
            {
                content:"SOme content",
                link:"some",
                subheader:true
            },
            {
                content:"Second Content",
                link:"some"
            },
            
        ],
        arrType:Module.Types.Object
    },
    Options:{
        type:Module.Types.Object,
        defaultValue:{ 
            closeOnClick: true 
        }
    },
    NavButton: {
        type:Module.Types.Text,
        defaultValue:"fa fa-bars"
        
    }
}


SideNavModule.Category  = "sxoinas"
export default SideNavModule;



