+_              = require 'lodash'
 kd             = require 'kd'
 JView          = require 'app/jview'
 KodingSwitch   = require 'app/commonviews/kodingswitch'
+CustomLinkView = require 'app/customlinkview'
 
 
 module.exports = class HomeUtilitiesCustomerFeedback extends kd.CustomHTMLView

    <p>
    <strong>Customer Feedback</strong>
    Enable Chatlio.com for real-time customer feedback
    {{> @switch}}
    </p>
    """

    # @switch  = new KodingSwitch
    #   cssClass: 'small'
    #   callback: (state) =>
    #     if state
    #     then @setClass 'on'
    #     else @unsetClass 'on'

    # {{> @switch}}
    # <p class='primary'>
    # <strong>Customer Feedback</strong>
    # Enable Chatlio.com for real-time customer feedback
    # </p>
    # <p class='secondary'>


    super options, data

    team          = kd.singletons.groupsController.getCurrentGroup()
    { customize } = team
    id            = customize.chatlioId

    @input = new kd.InputView
      defaultValue : id  if id

    @guide = new CustomLinkView
      cssClass : 'HomeAppView--button'
      title    : 'VIEW GUIDE'
      href     : 'https://www.koding.com/docs/chatlio'

    @save = new CustomLinkView
      cssClass : 'HomeAppView--button primary fr'
      title    : 'SAVE'
      click    : =>
        id = @input.getValue().trim()
        team.modify { 'customize.chatlioId': id }, (err) ->
          new kd.NotificationView if err
          then { title: 'There was an error, please try again!' }
          else
            if id
            then { title: 'Chatlio id successfully saved!' }
            else { title: 'Chatlio integration successfully turned off!' }


  pistachio: ->
