angular
  .module('carfriend')
  .config(config);
 
function config ($stateProvider, $urlRouterProvider, $httpProvider) {
    $stateProvider
            .state('signup', {
                url: '/signup',
                templateUrl: 'templates/signup.html',
                controller: 'SignUpCtrl as vm'
            })
            .state('login', {
                url: '/login',
                params: {
                    result: ''
                },
                templateUrl: 'templates/login.html',
                controller: 'LoginCtrl',
                controllerAs: 'vm'
            })

            .state('tab', {
                url: '/tab',
                abstract: true,
                templateUrl: 'templates/tabs.html'
            })
            .state('tab.account', {
                url: '/account',
                views: {
                    'tab-account': {
                        templateUrl: 'templates/tab-account.html',
                        controller: 'AccountCtrl',
                        controllerAs: 'vm'
                    }
                }
            })
            .state('tab.wildshield', {
                url: '/wildshield',
                views: {
                    'tab-wildshield': {
                        templateUrl: 'templates/tab-wildshield.html',
                        controller: 'NotificatorCtrl as vm'
                    }
                }
            })
            .state('tab.options', {
                url: '/options',
                views: {
                    'tab-options': {
                        templateUrl: 'templates/tab-options.html',
                        controller: 'OptionsCtrl',
                        controllerAs: 'vm'
                    }
                }
            })
            .state('tab.chats', {
                url: '/chats',
                views: {
                    'tab-chats': {
                        templateUrl: 'templates/tab-chat.html',
                        controller: 'ChatsCtrl',
                        controllerAs: 'vm'
                    }
                }
            })
            .state('tab.chat-detail', {
                url: '/chats/:chatId',
                params: {
                    user: null,
                    from: null
                },
                views: {
                    'tab-chats': {
                        templateUrl: 'templates/chat-detail.html',
                        controller: 'ChatDetailCtrl',
                        controllerAs: 'vm'
                    }
                }
            })
            .state('profile', {
                url: '/profile/:userID',
                params: {
                    from: null
                },
                templateUrl: 'templates/profile.html',
                controller: 'ProfileCtrl',
                controllerAs: 'vm'
            });

 
            $urlRouterProvider.otherwise('/signup');
            $httpProvider.interceptors.push('APIInterceptor');
}