 KodingAppsController = require './kodingappscontroller'
 HomeGetters          = require 'home/flux/getters'
 LocalStorage = require 'app/localstorage'
+isGroupDisabled = require './util/isGroupDisabled'
+isAdmin = require './util/isAdmin'
 
 module.exports = class KodingRouter extends kd.Router
 

      return KodingAppsController.loadInternalApp name, (err, res) =>
        return kd.warn err  if err
        kd.utils.defer => @handleRoute route, options

    return @handleRoute @getDefaultRoute()  if /<|>/.test route
    super route, options

      return '/Welcome'


  isRouteAllowed: (route) ->

    role = if isAdmin() then 'admin' else 'member'

    allowedRoutes =
      admin: [
        '/Home/team-billing'
        '/Disabled/Admin'
      ]
      member: [
        '/Disabled/Member'
        '/Disabled/Member/notify-success'
      ]

    return route in allowedRoutes[role]


  getGroupDisabledRoute: (originalRoute) ->

    if isAdmin() then '/Disabled/Admin' else '/Disabled/Member'


  setPageTitle: (title = 'Koding') -> kd.singletons.pageTitle.update title
