Skip to content

Instantly share code, notes, and snippets.

@blittle
Forked from ryanflorence/Pricing.js
Last active April 13, 2016 14:51
Show Gist options
  • Save blittle/50d42729c525738e5f2f943d01a52159 to your computer and use it in GitHub Desktop.
Save blittle/50d42729c525738e5f2f943d01a52159 to your computer and use it in GitHub Desktop.
const PricingWrap = function ({props}) {
return <div className="pricing" style={{ opacity: purchasing ? 0.25 : '' }}>
{props.children}
</div>
}
const Pricing = React.createClass({
// ...
render() {
// ...
if (purchaseError) {
return <PricingWrap>
<div className="purchase-complete">
<h2 style={{ color: 'hsl(10, 50%, 50%)' }}>Oops!</h2>
<p>
Sorry, there was an unkown error with the server, please try
again or email us at hello@reactjs-training.com to work out
payment a different way.
</p>
<p>
<button
className="cta-button outlined-button"
onClick={() => this.replaceState(this.getInitialState())}
>
Try again
</button>
</p>
</div>
</PricingWrap>
}
if (purchaseComplete) {
return <PricingWrap>
<div className="purchase-complete">
<h2>Thanks!</h2>
<p>
Thank you for your purchase of {formatPrice(this.state.total)}.
We’ll send you a receipt shortly.
</p>
<p>
<button
className="cta-button outlined-button"
onClick={() => this.replaceState(this.getInitialState())}
>
Buy more tickets
</button>
</p>
</div>
</PricingWrap>
}
if (seatsAvailable) {
if (promoAvailable) {
return <PricingWrap>
<PurchaseBlock
training={training}
price={promo}
regularPrice={regular}
title={`Promo: ${query.c}`}
getAvailableSeats={() => getAvailableSeatsWithPromo(training, promo)}
onPurchase={this.purchaseWithPromo}
/>
</PricingWrap>
} else if (earlyBirdAvailable) {
return <PricingWrap>
<PurchaseBlock
training={training}
price={earlyBird}
regularPrice={regular}
title="Early Bird Price"
getAvailableSeats={() => getAvailableSeats(training)}
onPurchase={this.purchaseEarlyBird}
/>
</PricingWrap>
} else {
return <PricingWrap>
<PurchaseBlock
training={training}
price={regular}
title="Ticket Price"
getAvailableSeats={() => getAvailableSeats(training)}
onPurchase={this.purchaseRegular}
/>
</PricingWrap>
}
}
return <PricingWrap>
<SoldOut training={training}/>
</PricingWrap>
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment