context = window rest = context.JK.Rest() @JamTrackCta = React.createClass({ redeem: (e) -> e.preventDefault() return if @state.processing isFree = context.JK.currentUserFreeJamTrack rest.addJamtrackToShoppingCart({id: @props.jam_track.id}).done((response) => if(isFree) if context.JK.currentUserId? context.JK.currentUserFreeJamTrack = true # make sure the user sees no more free notices context.location = '/client#/redeemComplete' else # now make a rest call to buy it context.location = '/client#/redeemSignup' else context.location = '/client#/shoppingCart' ).fail((jqXHR, textStatus, errorMessage) => if jqXHR.status == 422 errors = JSON.parse(jqXHR.responseText) cart_errors = errors?.errors?.cart_id if cart_errors?.length == 1 && cart_errors[0] == 'has already been taken' context.location = '/client#/shoppingCart' else context.JK.app.ajaxError(jqXHR, textStatus, errorMessage) @setState({processing:false}) ) @setState({processing:true}) getInitialState:() -> {processing: false} render: () -> isFree = context.JK.currentUserFreeJamTrack if isFree img =`` else img =`` if @props.instrument? getFreeText = "Get \"#{this.props.jam_track.name}\" JamTrack Free Now" instrumentBrowseUrl = "/client?instrument=#{this.props.instrument_id}#/jamtrack/filter" `
{getFreeText}
Or Browse All {this.props.instrument_count} JamTracks With {this.props.instrument} Parts
And Get Your Favorite Free!
` else bandBrowseUrl = "/client?artist=#{this.props.jam_track.original_artist}#/jamtrack/search" `
{img} #{this.props.jam_track.download_price} value

or browse all {this.props.band_track_count} {this.props.jam_track.original_artist} backing tracks

or browse all {this.props.all_track_count} backing tracks!
` })