import React from 'react';
import StepMenuItem from './StepMenuItem';


class StepMenu extends React.Component{
    _itens = [];

    constructor(props){
        super(props);
    }

    componentDidMount(){
        this._itens[this._itens.length - 1].showBar = false;
    }

    registerItems(item){
        this._itens.push(item);
    }

    setPassed(index){
        this._itens[index].passed = true;
    }

    setActive(index){
        for(var i = 0; i < this._itens.length; i++){
            if(i == index){
                this._itens[i].active = true;
                continue;
            }

            this._itens[i].active = false;
        }
    }

    render(){
        return(
            <div>
                {
                    this.props.titles.map(el => {
                        return (
                            <StepMenuItem
                                ref={el => this.registerItems(el)}
                                title={el}
                                key={el}
                                theme={this.props.theme}
                            />
                        );
                    })
                }
            </div>
        );
    }
}

export default StepMenu;
