<commit_before>'use strict'

Sprangular.directive 'checkoutButton', ->
  restrict: 'E'
  scope:
    user: '='
  templateUrl: 'directives/checkout_button.html'
  controller: ($scope, $location, Cart, Checkout) ->
    $scope.allowOneClick = false
    $scope.processing = false

    $scope.$watch 'user', (user) ->
      $scope.allowOneClick = user.allowOneClick

    $scope.standardCheckout = ->
      $scope.processing = true
      $location.path("/checkout")

    $scope.oneClickCheckout = ->
      $scope.processing = true

      order = Cart.current
      user = $scope.user

      order.resetAddresses(user)
      order.resetCreditCard(user)

      Checkout.update()
        .success ->
          $location.path('/checkout/confirm')
        .error ->
          $location.path('/checkout')

    $scope.checkout = ->
      if $scope.allowOneClick
        $scope.oneClickCheckout()<commit_msg>Fixed one-click checkout, should transition to payment state<commit_after>'use strict'

Sprangular.directive 'checkoutButton', ->
  restrict: 'E'
  scope:
    user: '='
  templateUrl: 'directives/checkout_button.html'
  controller: ($scope, $location, Cart, Checkout) ->
    $scope.allowOneClick = false
    $scope.processing = false

    $scope.$watch 'user', (user) ->
      $scope.allowOneClick = user.allowOneClick

    $scope.standardCheckout = ->
      $scope.processing = true
      $location.path("/checkout")

    $scope.oneClickCheckout = ->
      $scope.processing = true

      order = Cart.current
      user = $scope.user

      order.resetAddresses(user)
      order.resetCreditCard(user)

      Checkout.update('payment')
        .success ->
          $location.path('/checkout/confirm')
        .error ->
          $location.path('/checkout')

    $scope.checkout = ->
      if $scope.allowOneClick
        $scope.oneClickCheckout()
{'fraction_non_alphanumeric': 0.13572204125950055, 'fraction_numerical': 0.0, 'mean_word_length': 2.6351084812623276, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3402723', 'n_tokens_mistral': 566, 'n_tokens_neox': 548, 'n_words': 98}