-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMembership.jsx
More file actions
111 lines (100 loc) · 4.23 KB
/
Membership.jsx
File metadata and controls
111 lines (100 loc) · 4.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import React, { Component, PropTypes } from 'react'
import { Link } from 'react-router'
import { connect } from 'react-redux'
import Loading from '../Common/Components/Loading'
import Error from '../Common/Components/Error'
import {get_products} from '../utils/redux_loader'
import {changePageTitle} from '../Layout/Actions/LayoutActions';
class Membership extends Component {
constructor(props, context) {
super(props, context)
this.addToCart = this.addToCart.bind(this)
}
componentWillMount() {
var oproducts = this.props.products.toJS()
if (oproducts.products.length == 0) {
get_products(this.props.dispatch)
}
const {dispatch} = this.props;
const {title} = Membership.getPageMeta();
dispatch(changePageTitle(title));
}
static getPageMeta() {
return {
title: `Membership | Data Skeptic`
}
}
addToCart(product) {
console.log("addToCart")
console.log(product)
var size = ""
this.props.dispatch({type: "ADD_TO_CART", payload: {product, size} })
this.props.dispatch({type: "SHOW_CART", payload: true })
}
render() {
var ocart = this.props.cart.toJS()
var oproducts = this.props.products.toJS()
var products = oproducts.products
var products_loaded = oproducts.products_loaded
if (products_loaded == 0) {
return <div><Loading /></div>
} else if (products_loaded == -1) {
return <div><Error /></div>
} else {
products = oproducts.products
products.sort(function(a, b) {
return a['price'] - b['price']
})
var me = this
return (
<div className="center">
<h2>Data Skeptic Membership</h2>
<p>If you are already a member, you can log-in <a href="/login">here</a>.</p>
<p>Your membership supports Data Skeptic's ability to continue delivering quality content on a weekly basis and expand into new mediums. For $1 per episode, your contributions can help us launch more projects and continuously improve the content of the podcast.</p>
<div>
<h3>Donations</h3>
<p>If you prefer to make a one time contribution, you can do so via the Paypal button below.</p>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick" />
<input type="hidden" name="hosted_button_id" value="3FNHXLXMGRGFY" />
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!" />
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1" />
</form>
</div>
<h3>Monthly Memberships</h3>
<div className="row">
{products.map(function(product) {
if (product.active == 1 && product.type=="membership" && product.price < 128) {
const pid = product.id;
const uid = product.sku.toLowerCase();
return (
<div key={pid} className={`col-xs-12 col-sm-4 membership-container membership-${uid}`}>
<div className="membership-inner">
<div className="membership-title">{product.title}</div>
<div className="membership-desc">{product.desc}</div>
<div className="membership-bottom-container">
<div className="membership-price">${product.price} <span className="per_month">/ month</span></div>
<div className="membership-btn">
<button className="membership-add" onClick={me.addToCart.bind(me, product)}>Add to Cart</button>
<p>or</p>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick" />
<input type="hidden" name="hosted_button_id" value={product.paypal} />
<input type="submit" className="membership-add-paypal" value="Subscribe with Paypal" />
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1" />
</form>
</div>
</div>
</div>
</div>
)
}
})}
</div>
<div className="clear"></div>
</div>
)
}
}
}
export default connect(state => ({ products: state.products, cart: state.cart }))(Membership)