-
Notifications
You must be signed in to change notification settings - Fork 0
/
pricing-page.js
426 lines (379 loc) · 19 KB
/
pricing-page.js
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import 'bootstrap/dist/css/bootstrap.css';
import { Container, Button, Row, Col, Tooltip } from 'reactstrap';
import * as tiers from './tiers.json';
import * as plans_and_features from './plans_and_features.json';
import PlansAccordion from './pricing-page-responsive.js';
import MediaQuery from 'react-responsive';
import { FaInfoCircle } from "react-icons/fa";
import ReactTooltip from 'react-tooltip';
var SimplePlanTier = function (_React$Component) {
_inherits(SimplePlanTier, _React$Component);
function SimplePlanTier() {
_classCallCheck(this, SimplePlanTier);
return _possibleConstructorReturn(this, (SimplePlanTier.__proto__ || Object.getPrototypeOf(SimplePlanTier)).apply(this, arguments));
}
_createClass(SimplePlanTier, [{
key: 'render',
value: function render() {
var _this2 = this;
// console.log("props in SimplePlanTier", this.props);
var rows = [];
this.props.tiers.forEach(function (tier) {
rows.push(React.createElement(
Col,
{ sm: '3', key: tier.name, className: 'simple-plan-tier-col' },
React.createElement(
'div',
{ className: 'price-card' },
React.createElement(
'div',
{ className: 'pricing-panel-wrapper' },
React.createElement(
'div',
{ className: 'pricing-panel' },
React.createElement(
'div',
{ className: 'pricing-panel-header' },
React.createElement(
'h6',
{ className: 'pricing-panel-tier' },
tier.name
),
React.createElement(
'h2',
{ className: 'product-price product-price-lg' },
React.createElement(
'span',
{ className: 'currency' },
tier.pricing.monthly.currency
),
React.createElement(
'span',
{ className: 'price' },
tier.pricing.monthly.price
),
React.createElement(
'span',
{ className: 'period' },
'/mo'
)
),
React.createElement(
'div',
{ className: 'pricing-panel-info' },
React.createElement(
'div',
{ className: 'text-light-gray' },
React.createElement(
'p',
{ 'data-alt-text': '$950 billed yearly<br />Save $238/year', className: 'year-pricing' },
tier.pricing.yearly.currency,
tier.pricing.yearly.price,
'/mo when you ',
React.createElement(
'a',
{ href: '#', className: 'yearly' },
' pay yearly'
)
)
)
),
React.createElement('p', null),
React.createElement(
'p',
null,
tier.description
),
React.createElement('p', null),
React.createElement(
'div',
{ className: 'pricing-panel-footer' },
React.createElement(
'div',
{ className: 'cta-wrapper' },
React.createElement(
Button,
{ className: 'sign-up-btn' },
React.createElement(
'a',
{ href: tier.call_to_action.url, className: 'action-link' },
tier.call_to_action.text
)
)
),
React.createElement(
'p',
{ className: 'compare-plans', onClick: function onClick() {
return _this2.props.onClick();
} },
'compare plans'
)
)
)
)
)
)
));
});
return React.createElement(
Row,
null,
rows
);
}
}]);
return SimplePlanTier;
}(React.Component);
;
var PricingPage = function (_React$Component2) {
_inherits(PricingPage, _React$Component2);
function PricingPage(props) {
_classCallCheck(this, PricingPage);
var _this3 = _possibleConstructorReturn(this, (PricingPage.__proto__ || Object.getPrototypeOf(PricingPage)).call(this, props));
_this3.state = {
showDetailedPlanOveriew: false,
tiers: [],
categories: [],
tooltipOpen: false
};
return _this3;
}
_createClass(PricingPage, [{
key: 'handleClick',
value: function handleClick() {
// console.log("about to hide simple plan tier and show detailed plan view");
this.setState({ showDetailedPlanOveriew: !this.state.showDetailedPlanOveriew });
}
// get pricing page details from a remote page
}, {
key: 'componentDidMount',
value: function componentDidMount() {
var _this4 = this;
fetch("https://www.docsie.io/pricing/plans.json").then(function (res) {
return res.json();
}).then(function (result) {
// console.log("result response for plans.json from docsie endpoint", result);
_this4.setState({
// tiers: tiers.default.tiers,
categories: plans_and_features.default.categories
// categories: result.categories
});
// console.log("result from fetch API in pricing page", result)
},
// Note: it's important to handle errors here
// instead of a catch() block so that we don't swallow
// exceptions from actual bugs in components.
function (error) {
// this.setState({
// isLoaded: true,
// error
// });
});
fetch("https://www.docsie.io/pricing/tiers.json").then(function (res) {
return res.json();
}).then(function (result) {
// console.log("result response for tiers.json from docsie endpoint", result);
_this4.setState({
tiers: tiers.default.tiers
// categories: plans_and_features.default.categories
// tiers: result.tiers
});
// console.log("result from fetch API in pricing page", result);
},
// Note: it's important to handle errors here
// instead of a catch() block so that we don't swallow
// exceptions from actual bugs in components.
function (error) {
// this.setState({
// isLoaded: true,
// error
// });
});
}
}, {
key: 'render',
value: function render() {
var _this5 = this;
var detailRows = [];
var categoryFeatures = [];
this.state.tiers.forEach(function (tier) {
detailRows.push(React.createElement(
Col,
{ sm: '2', key: tier.name, style: { textAlign: 'center' } },
React.createElement(
'h4',
{ className: 'pricing-name' },
tier.name
),
React.createElement(
'h2',
{ className: 'product-price product-price-md' },
React.createElement(
'span',
{ className: 'currency' },
tier.pricing.monthly.currency
),
React.createElement(
'span',
{ className: 'price' },
tier.pricing.monthly.price
),
React.createElement(
'span',
{ className: 'period' },
'/mo'
)
)
));
});
this.state.categories.forEach(function (category, i) {
category.features.forEach(function (item, j) {
var _ref;
categoryFeatures.push(React.createElement(
Container,
{ key: item.name },
i != 0 && j == 0 ? React.createElement(
'h4',
{ className: 'category-type-1' },
category.name
) : '',
React.createElement(
Row,
{ style: (_ref = { textAlign: 'center' }, _defineProperty(_ref, 'textAlign', 'center'), _defineProperty(_ref, 'margin', 'auto'), _ref) },
React.createElement(
Col,
{ sm: '2', className: 'category-feature' },
React.createElement(
'div',
null,
item.name,
' ',
React.createElement(FaInfoCircle, { 'data-tip': item.info })
),
React.createElement(ReactTooltip, null)
),
React.createElement(
Col,
{ sm: '2', className: 'category-feature' },
React.createElement(
'div',
null,
item.values.Standard
)
),
React.createElement(
Col,
{ sm: '2', className: 'category-feature' },
React.createElement(
'div',
null,
item.values.Medium
)
),
React.createElement(
Col,
{ sm: '2', className: 'category-feature' },
React.createElement(
'div',
null,
item.values.Large
)
),
React.createElement(
Col,
{ sm: '2', className: 'category-feature' },
React.createElement(
'div',
null,
item.values.Premium
)
)
)
));
});
});
return React.createElement(
'div',
{ className: 'simple-detail-plan-tier-sm-md-lg' },
!this.state.showDetailedPlanOveriew ? React.createElement(
'div',
null,
React.createElement(
MediaQuery,
{ query: '(max-device-width: 1023px)' },
React.createElement(PlansAccordion, { className: 'accordion-plan-tier' })
),
React.createElement(
'div',
{ className: 'simple-plan-container' },
React.createElement(
Container,
null,
React.createElement(
MediaQuery,
{ query: '(min-device-width: 1024px)' },
React.createElement(SimplePlanTier, { tiers: this.state.tiers, onClick: function onClick() {
return _this5.handleClick();
},
className: 'plan-tier' })
)
)
)
) : React.createElement(
'div',
null,
React.createElement(
MediaQuery,
{ query: '(max-device-width: 1023px)' },
React.createElement(PlansAccordion, { className: 'accordion-plan-tier' })
),
React.createElement(
MediaQuery,
{ query: '(min-device-width: 1024px)' },
React.createElement(
'div',
{ className: 'detail-plan-container' },
React.createElement(
Container,
{ style: { background: 'white' } },
React.createElement(
Row,
null,
React.createElement(
Col,
{ sm: '2' },
React.createElement(
'h4',
{ className: 'category-type-1' },
this.state.categories[0].name
)
),
detailRows
),
categoryFeatures,
React.createElement('br', null),
React.createElement(
Button,
{ className: 'sign-up-btn accrd-btn', onClick: function onClick() {
return _this5.handleClick();
} },
'View Simple Plan Tier'
)
)
)
)
)
);
}
}]);
return PricingPage;
}(React.Component);
export default PricingPage;