tf-checkout-react 1.2.7 → 1.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/paymentContainer/index.d.ts +4 -5
- package/dist/tf-checkout-react.cjs.development.js +25 -18
- package/dist/tf-checkout-react.cjs.development.js.map +1 -1
- package/dist/tf-checkout-react.cjs.production.min.js +1 -1
- package/dist/tf-checkout-react.cjs.production.min.js.map +1 -1
- package/dist/tf-checkout-react.esm.js +25 -18
- package/dist/tf-checkout-react.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/.DS_Store +0 -0
- package/src/api/index.ts +7 -8
- package/src/components/.DS_Store +0 -0
- package/src/components/common/dist/PhoneNumberField.js +96 -0
- package/src/components/myTicketsContainer/index.tsx +2 -1
- package/src/components/orderDetailsContainer/index.tsx +5 -8
- package/src/components/paymentContainer/index.tsx +53 -49
package/package.json
CHANGED
package/src/.DS_Store
ADDED
|
Binary file
|
package/src/api/index.ts
CHANGED
|
@@ -4,7 +4,7 @@ import _get from 'lodash/get'
|
|
|
4
4
|
import { CONFIGS, getCookieByName, setCustomCookie } from '../utils'
|
|
5
5
|
|
|
6
6
|
const isWindowDefined = typeof window !== 'undefined'
|
|
7
|
-
|
|
7
|
+
const isDocumentDefined = typeof document !== 'undefined'
|
|
8
8
|
|
|
9
9
|
const ttfHeaders: { [key: string]: any } = {
|
|
10
10
|
Accept: 'application/vnd.api+json',
|
|
@@ -172,15 +172,14 @@ export function getEvent(id: string | number) {
|
|
|
172
172
|
referralIdlocal = referral_key.split('.')[1]
|
|
173
173
|
}
|
|
174
174
|
referralValue = referralId || referralIdlocal
|
|
175
|
-
console.log(referralValue)
|
|
176
175
|
}
|
|
177
176
|
|
|
178
177
|
const response = publicRequest
|
|
179
178
|
.get(`v1/event/${id}`, {
|
|
180
179
|
headers: {
|
|
181
180
|
...ttfHeaders,
|
|
182
|
-
|
|
183
|
-
|
|
181
|
+
'Referer-Url': isDocumentDefined ? document.referrer : '',
|
|
182
|
+
'Referrer-Id': isWindowDefined ? referralValue : '',
|
|
184
183
|
},
|
|
185
184
|
})
|
|
186
185
|
.catch(error => {
|
|
@@ -212,7 +211,7 @@ export const addToCart = (id: string | number, data: any) => {
|
|
|
212
211
|
{ data },
|
|
213
212
|
{
|
|
214
213
|
headers: {
|
|
215
|
-
|
|
214
|
+
'Referer-Url': isDocumentDefined ? document.referrer : '',
|
|
216
215
|
},
|
|
217
216
|
}
|
|
218
217
|
)
|
|
@@ -254,7 +253,7 @@ export const getPaymentData = (hash: string) => {
|
|
|
254
253
|
const response = publicRequest
|
|
255
254
|
.get(`v1/order/${hash}/review/`, {
|
|
256
255
|
headers: {
|
|
257
|
-
|
|
256
|
+
'Referer-Url': isDocumentDefined ? document.referrer : '',
|
|
258
257
|
},
|
|
259
258
|
})
|
|
260
259
|
.catch(error => {
|
|
@@ -278,7 +277,7 @@ export const handlePaymentSuccess = (orderHash: string) => {
|
|
|
278
277
|
const res = publicRequest
|
|
279
278
|
.post(`v1/order/${orderHash}/success`, undefined, {
|
|
280
279
|
headers: {
|
|
281
|
-
|
|
280
|
+
'Referer-Url': isDocumentDefined ? document.referrer : '',
|
|
282
281
|
},
|
|
283
282
|
})
|
|
284
283
|
.catch(error => {
|
|
@@ -291,7 +290,7 @@ export const handleFreeSuccess = (orderHash: string) => {
|
|
|
291
290
|
const res = publicRequest
|
|
292
291
|
.post(`v1/order/${orderHash}/complete_free_registration`, undefined, {
|
|
293
292
|
headers: {
|
|
294
|
-
|
|
293
|
+
'Referer-Url': isDocumentDefined ? document.referrer : '',
|
|
295
294
|
},
|
|
296
295
|
})
|
|
297
296
|
.catch(error => {
|
|
Binary file
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (_) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
exports.__esModule = true;
|
|
50
|
+
exports.PhoneNumberField = void 0;
|
|
51
|
+
var TextField_1 = require("@mui/material/TextField");
|
|
52
|
+
var debounce_1 = require("lodash/debounce");
|
|
53
|
+
var get_1 = require("lodash/get");
|
|
54
|
+
var react_1 = require("react");
|
|
55
|
+
var api_1 = require("../../api");
|
|
56
|
+
exports.PhoneNumberField = function (_a) {
|
|
57
|
+
var label = _a.label, _b = _a.type, type = _b === void 0 ? 'text' : _b, field = _a.field, _c = _a.form, errors = _c.errors, setFieldError = _c.setFieldError, setStatus = _c.setStatus;
|
|
58
|
+
var error = get_1["default"](errors, field.name);
|
|
59
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
60
|
+
var debounceCb = react_1.useCallback(debounce_1["default"](function (cb) { return void cb(); }, 1000), []);
|
|
61
|
+
react_1.useEffect(function () {
|
|
62
|
+
var _a;
|
|
63
|
+
if (field.value) {
|
|
64
|
+
setStatus((_a = {}, _a[field.name] = true, _a));
|
|
65
|
+
}
|
|
66
|
+
debounceCb(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
67
|
+
var error_1, message;
|
|
68
|
+
var _a;
|
|
69
|
+
return __generator(this, function (_b) {
|
|
70
|
+
switch (_b.label) {
|
|
71
|
+
case 0:
|
|
72
|
+
_b.trys.push([0, 3, 4, 5]);
|
|
73
|
+
if (!field.value) return [3 /*break*/, 2];
|
|
74
|
+
return [4 /*yield*/, api_1.validatePhoneNumber(field.value)];
|
|
75
|
+
case 1:
|
|
76
|
+
_b.sent();
|
|
77
|
+
_b.label = 2;
|
|
78
|
+
case 2:
|
|
79
|
+
setFieldError(field.name, '');
|
|
80
|
+
return [3 /*break*/, 5];
|
|
81
|
+
case 3:
|
|
82
|
+
error_1 = _b.sent();
|
|
83
|
+
message = get_1["default"](error_1, 'response.data.message', 'Invalid phone number');
|
|
84
|
+
setFieldError(field.name, message);
|
|
85
|
+
return [3 /*break*/, 5];
|
|
86
|
+
case 4:
|
|
87
|
+
setStatus((_a = {}, _a[field.name] = false, _a));
|
|
88
|
+
return [7 /*endfinally*/];
|
|
89
|
+
case 5: return [2 /*return*/];
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}); });
|
|
93
|
+
// eslint-disable-next-line
|
|
94
|
+
}, [field.value]);
|
|
95
|
+
return (react_1["default"].createElement(TextField_1["default"], __assign({}, field, { id: field.name, label: label, type: type, fullWidth: true, error: !!error, helperText: error, value: field.value || '', inputProps: { pattern: '[+0-9]/d+' } })));
|
|
96
|
+
};
|
|
@@ -17,6 +17,7 @@ import _identity from 'lodash/identity'
|
|
|
17
17
|
import React, { useEffect, useState } from 'react'
|
|
18
18
|
|
|
19
19
|
import { getOrders } from '../../api'
|
|
20
|
+
import { getCookieByName } from '../../utils'
|
|
20
21
|
import { LoginModal } from '../loginModal'
|
|
21
22
|
import MyTicketsRow, { RowItems } from './row'
|
|
22
23
|
import tableConfig from './tableConfig'
|
|
@@ -48,7 +49,7 @@ export const MyTicketsContainer = ({
|
|
|
48
49
|
|
|
49
50
|
const isWindowDefined = typeof window !== 'undefined'
|
|
50
51
|
const [isLogged, setIsLogged] = useState(
|
|
51
|
-
isWindowDefined ? !!
|
|
52
|
+
isWindowDefined ? !!getCookieByName('X-TF-ECOMMERCE') : false
|
|
52
53
|
)
|
|
53
54
|
const [showModalLogin, setShowModalLogin] = useState(false)
|
|
54
55
|
const [userExpired, setUserExpired] = useState(false)
|
|
@@ -215,15 +215,12 @@ export const OrderDetailsContainer = ({
|
|
|
215
215
|
{data?.personal_share_link}
|
|
216
216
|
</a>
|
|
217
217
|
</div>
|
|
218
|
-
|
|
219
|
-
<
|
|
220
|
-
|
|
218
|
+
{data?.sales_referred ? (
|
|
219
|
+
<div className="link-item">
|
|
220
|
+
<p className="total-referrer">{`So far, you’ve referred ${data.sales_referred} tickets`}</p>
|
|
221
|
+
</div>
|
|
222
|
+
) : null}
|
|
221
223
|
</div>
|
|
222
|
-
{data?.sales_referred ? (
|
|
223
|
-
<div className="total-referrer">
|
|
224
|
-
<b>So far, you've referred {data.sales_referred} tickets.</b>
|
|
225
|
-
</div>
|
|
226
|
-
) : null}
|
|
227
224
|
<TableContainer component={Paper}>
|
|
228
225
|
<Table className="tt-type" aria-label="collapsible table">
|
|
229
226
|
<TableHead>
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import CircularProgress from '@mui/material/CircularProgress'
|
|
1
|
+
import './style.css'
|
|
2
|
+
|
|
3
|
+
import { ThemeOptions } from '@mui/material'
|
|
5
4
|
import Alert from '@mui/material/Alert'
|
|
5
|
+
import CircularProgress from '@mui/material/CircularProgress'
|
|
6
|
+
import Container from '@mui/material/Container'
|
|
7
|
+
import { createTheme, ThemeProvider } from '@mui/material/styles'
|
|
8
|
+
import { CSSProperties } from '@mui/styles'
|
|
6
9
|
import { Elements } from '@stripe/react-stripe-js'
|
|
7
10
|
import {
|
|
8
11
|
loadStripe,
|
|
12
|
+
StripeCardNumberElementOptions,
|
|
9
13
|
StripeConstructorOptions,
|
|
10
14
|
StripeElementsOptions,
|
|
11
15
|
} from '@stripe/stripe-js'
|
|
12
|
-
import
|
|
16
|
+
import { AxiosError } from 'axios'
|
|
13
17
|
import _get from 'lodash/get'
|
|
14
18
|
import _identity from 'lodash/identity'
|
|
15
|
-
import
|
|
19
|
+
import _map from 'lodash/map'
|
|
16
20
|
import { nanoid } from 'nanoid'
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
import './style.css'
|
|
20
|
-
import StripePayment from '../stripePayment'
|
|
21
|
-
import { IOrderData, IPaymentField } from '../../types'
|
|
21
|
+
import React, { useEffect, useState } from 'react'
|
|
22
22
|
|
|
23
23
|
import {
|
|
24
|
-
getPaymentData,
|
|
25
|
-
handlePaymentSuccess,
|
|
26
24
|
getConditions,
|
|
25
|
+
getPaymentData,
|
|
27
26
|
handleFreeSuccess,
|
|
27
|
+
handlePaymentSuccess,
|
|
28
28
|
} from '../../api'
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import { CSSProperties } from '@mui/styles'
|
|
33
|
-
import TimerWidget from '../timerWidget'
|
|
29
|
+
import { IOrderData, IPaymentField } from '../../types'
|
|
30
|
+
import { CONFIGS } from '../../utils'
|
|
31
|
+
import { getQueryVariable } from '../../utils/getQueryVariable'
|
|
34
32
|
import { Loader } from '../common/index'
|
|
33
|
+
import StripePayment from '../stripePayment'
|
|
34
|
+
import TimerWidget from '../timerWidget'
|
|
35
35
|
|
|
36
36
|
const publishableKey = CONFIGS.STRIPE_PUBLISHABLE_KEY || ''
|
|
37
37
|
|
|
@@ -99,17 +99,17 @@ export const PaymentContainer = ({
|
|
|
99
99
|
errorText,
|
|
100
100
|
checkoutData,
|
|
101
101
|
onErrorClose = _identity,
|
|
102
|
-
onGetPaymentDataSuccess =
|
|
103
|
-
onGetPaymentDataError =
|
|
104
|
-
onPaymentError =
|
|
102
|
+
onGetPaymentDataSuccess = _identity,
|
|
103
|
+
onGetPaymentDataError = _identity,
|
|
104
|
+
onPaymentError = _identity,
|
|
105
105
|
stripeCardOptions = {},
|
|
106
106
|
disableZipSection = false,
|
|
107
107
|
themeOptions,
|
|
108
108
|
elementsOptions,
|
|
109
|
-
onCountdownFinish =
|
|
109
|
+
onCountdownFinish = _identity,
|
|
110
110
|
enableTimer = false,
|
|
111
111
|
enablePaymentPlan = false,
|
|
112
|
-
paymentButtonText
|
|
112
|
+
paymentButtonText,
|
|
113
113
|
}: IPaymentPage) => {
|
|
114
114
|
const [reviewData, setReviewData] = useState(initialReviewValues)
|
|
115
115
|
const [orderData, setOrderData] = useState(initialOrderValues)
|
|
@@ -117,15 +117,16 @@ export const PaymentContainer = ({
|
|
|
117
117
|
const [showPaymentPlanSection, setShowPaymentPlanSection] = useState(false)
|
|
118
118
|
const [paymentIsLoading, setPaymentIsLoading] = useState(false)
|
|
119
119
|
const [paymentDataIsLoading, setPaymentDataIsLoading] = useState(true)
|
|
120
|
-
const [conditions, setConditions] = useState<{ id: string
|
|
120
|
+
const [conditions, setConditions] = useState<{ id: string, text: string }[]>(
|
|
121
121
|
[]
|
|
122
122
|
)
|
|
123
123
|
|
|
124
|
-
const showFormTitle
|
|
125
|
-
const showErrorText
|
|
124
|
+
const showFormTitle = Boolean(formTitle)
|
|
125
|
+
const showErrorText = Boolean(errorText)
|
|
126
126
|
|
|
127
127
|
const eventId = getQueryVariable('event_id')
|
|
128
128
|
const { hash, total } = checkoutData
|
|
129
|
+
const isFreeTickets = !Number(total) && !Number(orderData.total)
|
|
129
130
|
|
|
130
131
|
useEffect(() => {
|
|
131
132
|
(async () => {
|
|
@@ -168,10 +169,10 @@ export const PaymentContainer = ({
|
|
|
168
169
|
setConditions(
|
|
169
170
|
conditionsInfo
|
|
170
171
|
? conditionsInfo.map((item: string) => ({
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
172
|
+
id: nanoid(),
|
|
173
|
+
text: item,
|
|
174
|
+
checked: false,
|
|
175
|
+
}))
|
|
175
176
|
: []
|
|
176
177
|
)
|
|
177
178
|
}
|
|
@@ -245,22 +246,24 @@ export const PaymentContainer = ({
|
|
|
245
246
|
)
|
|
246
247
|
})}
|
|
247
248
|
</div>
|
|
248
|
-
{enablePaymentPlan &&
|
|
249
|
-
<
|
|
250
|
-
<
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
249
|
+
{enablePaymentPlan && (
|
|
250
|
+
<div className="payment_toggle">
|
|
251
|
+
<label htmlFor="togBtn" className="switch">
|
|
252
|
+
<input
|
|
253
|
+
type="checkbox"
|
|
254
|
+
id="togBtn"
|
|
255
|
+
disabled={true}
|
|
256
|
+
onChange={() =>
|
|
257
|
+
setShowPaymentPlanSection(!showPaymentPlanSection)
|
|
258
|
+
}
|
|
259
|
+
/>
|
|
260
|
+
<div className="slider round" />
|
|
261
|
+
<span className="tog_text">
|
|
262
|
+
Click to checkout using Payment Plan
|
|
263
|
+
</span>
|
|
264
|
+
</label>
|
|
265
|
+
</div>
|
|
266
|
+
)}
|
|
264
267
|
{showPaymentPlanSection && (
|
|
265
268
|
<div className="payment_plan">
|
|
266
269
|
<h2>PAYMENT PLAN</h2>
|
|
@@ -292,7 +295,7 @@ export const PaymentContainer = ({
|
|
|
292
295
|
</div>
|
|
293
296
|
</div>
|
|
294
297
|
)}
|
|
295
|
-
{
|
|
298
|
+
{!isFreeTickets ? (
|
|
296
299
|
<div className="payment_info">
|
|
297
300
|
<div className="payment_info_label">ORDER CONFIRMATION</div>
|
|
298
301
|
{showErrorText && (
|
|
@@ -325,8 +328,9 @@ export const PaymentContainer = ({
|
|
|
325
328
|
</div>
|
|
326
329
|
) : (
|
|
327
330
|
<div
|
|
328
|
-
className={`payment_button ${
|
|
329
|
-
|
|
331
|
+
className={`payment_button ${
|
|
332
|
+
paymentIsLoading ? 'disabled-payment-button' : ''
|
|
333
|
+
}`}
|
|
330
334
|
>
|
|
331
335
|
<button
|
|
332
336
|
disabled={paymentIsLoading}
|