context = window
SessionActions = @SessionActions

@SessionVideoBtn = React.createClass({

  openBrowserToPayment: () ->
    context.JK.popExternalLink("/client#/account/subscription", true)

  openBrowserToPlanComparison: () ->
    context.JK.popExternalLink("https://jamkazam.freshdesk.com/support/solutions/articles/66000122535-what-are-jamkazam-s-free-vs-premium-features-")
    return 'noclose'

  sessionWebCam: (e) ->
    e.preventDefault();

    canVideo = window.SessionStore.canVideo()

    if canVideo
      SessionActions.toggleSessionVideo()
    else
      buttons = []
      buttons.push({name: 'CLOSE', buttonStyle: 'button-grey'})
      buttons.push({name: 'COMPARE PLANS', buttonStyle: 'button-grey', click: (() => (@openBrowserToPlanComparison()))})
      buttons.push({
        name: 'UPGRADE PLAN',
        buttonStyle: 'button-orange',
        click: (() => (@openBrowserToPayment()))
      })
      context.JK.Banner.show({
        title: "Your Current Plan Does Not Allow Video",
        html: context._.template($('#template-plan-no-video').html(), {}, { variable: 'data' }),
        buttons: buttons})

  render: () ->
    `<a className="session-share button-grey-toggle left" onClick={this.sessionWebCam}>
      <img src="/assets/content/icon_video.png" align="texttop" height="14" width="14"/>
      VIDEO
    </a>`
})