class OrderingForm extends Skr.Api.Components.Base dataObjects: sale: 'props' onPurchase: (ev) -> ev.preventDefault() @sale.copySkusFromCart(@props.cart) @setState(isSaving: true, isSaveComplete: false) @sale.save().then (a, b) => @setState(isSaveComplete: true) _.delay => @setState(isSaving: false) @setState(isSaveComplete: false) @props.onComplete() unless @sale.errors , 1100 render: -> classNames = _.classnames( 'order', { 'is-saving': @state.isSaving, 'is-complete': @state.isSaveComplete })
Submitting…
{
{@sale.errorMessage}
if @sale.errorMessage}
class OrderingComplete extends Skr.Api.Components.Base dataObjects: sale: 'props' render: ->

Order number {@sale.visible_id} was successfully saved

Download Receipt
class ErrorFetching extends Skr.Api.Components.Base render: ->

Error loading sale item {@props.skuCode}

class Skr.SingleItemCheckout extends Skr.Api.Components.Base statics: render: (options) -> new Lanes.React.Viewport(_.extend(options, { rootProps: _.pick(options, 'sale_options', 'skuCode', 'customer') pubSubDisabled: true rootComponent: @ })) getInitialState: -> showingOrder: true dataObjects: cart: -> new Skr.Api.Models.Cart sale: -> new Skr.Api.Models.Sale(@props.sale_options) componentWillMount: -> @cart.addBySkuCode(@props.skuCode).then => @setState(errorFetching: true) if @cart.skus.length is 0 onTypeSwitch: -> if @state.showingOrder Skr.Api.Models.SalesHistory.record(@sale) else @sale.clear() @setState(showingOrder: not @state.showingOrder) render: -> return if @state.errorFetching Component = if @state.showingOrder then OrderingForm else OrderingComplete