 BidderPosition = require '../../../models/bidder_position.coffee'
 ErrorHandlingForm = require '../../../components/credit_card/client/error_handling_form.coffee'
 { SESSION_ID } = require('sharify').data
+trackSnowplow = analytics.snowplowStruct
 
 module.exports = class BidForm extends ErrorHandlingForm
 

        artwork_id: @saleArtwork.get('artwork').id
        max_bid_amount_cents: @getBidAmount()
      bidderPosition.save null,
        success: =>
          _.delay =>
            @pollForBidPlacement(@saleArtwork.get('minimum_next_bid_cents'))
          , 1000
          analytics.track.funnel 'Confirmed bid on bid page'
        error: (xhr) =>
          @showError 'Error placing your bid', xhr
    else
      @showError "Your bid must be higher than #{@bidderPositions.minBid()}"

  pollForBidPlacement: (minimumBidAmountInCents) ->
    @saleArtwork.fetch


  showSuccessfulBidMessage: =>
    window.location = @saleArtwork.artwork().bidSuccessUrl()

  showError: (description, response = {}) =>
    trackSnowplow 'bid', 'validation_error', @saleArtwork.artwork().get('_id'), 'artwork', undefined, { error_name: description }
    super
