/**
 * (c) by aheadware.com
 */

var app = app || {};
app.state = app.state || {};

app.state.AuthJoin = function()
{
    var state = app.core.StateManager.createState( 'auth-join' );

    state.onEnter = function (p)
    {
        let $authContent = app.core.View.getAuthContent(),
            publicTeamid = p.publicTeamId;

        app.gui.PageLoader.show();

        app.core.Rpc.call(
            'Auth',
            'getTeamForJoin',
            { publicTeamId : publicTeamid },
            function( res )
            {
                app.core.View.setAuthContent(
                    app.core.View.getTemplate('auth-join', { joinTeamData: res.team } )
                );

                app.gui.PageLoader.hide();
            }
            ,
            function( res )
            {
                console.log( res );
            }
        );
    }

    return state;
};