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

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

app.state.CourseTemplates = function()
{
    var state = app.core.StateManager.createState( 'course-templates' );

    state.onEnter = function( p )
    {
        let $content = app.core.View.getContent(),
            groupId = p.groupId || null,
            adminGroups = app.model.SessionUser.getAdminGroups(),
            group = null;

        app.gui.PageLoader.show();

        app.core.Rpc.call(
            'Team',
            'getDetails',
            {
                teamId : groupId
            },
            function( res )
            {
                group = new app.model.Group(res.team, res.members);

                app.core.View.setContent(
                    app.core.View.getTemplate('course-templates', {g: group})
                );

                app.gui.PageLoader.hide();
            }
        );

    };

    return state;
};