tf-checkout-react 1.2.25 → 1.2.26
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/api/index.d.ts +1 -8
- package/dist/tf-checkout-react.cjs.development.js +26 -28
- 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 +26 -28
- package/dist/tf-checkout-react.esm.js.map +1 -1
- package/dist/utils/setConfigs.d.ts +12 -1
- package/package.json +1 -1
- package/src/api/index.ts +2 -21
- package/src/components/billing-info-container/index.tsx +9 -10
- package/src/utils/setConfigs.ts +23 -4
- package/src/.DS_Store +0 -0
- package/src/components/.DS_Store +0 -0
- package/src/components/common/dist/PhoneNumberField.js +0 -96
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
export declare const ttfHeaders: {
|
|
3
|
+
[key: string]: any;
|
|
4
|
+
};
|
|
5
|
+
interface IPublicRequest extends AxiosInstance {
|
|
6
|
+
setGuestToken: (token: string) => void;
|
|
7
|
+
setAccessToken: (token: string) => void;
|
|
8
|
+
setBaseUrl: (baseUrl: string) => void;
|
|
9
|
+
}
|
|
10
|
+
export interface IConfigs {
|
|
2
11
|
BASE_URL: string;
|
|
3
12
|
CLIENT_ID: string;
|
|
4
13
|
CLIENT_SECRET: string;
|
|
@@ -7,5 +16,7 @@ interface IConfigs {
|
|
|
7
16
|
[key: string]: string | number;
|
|
8
17
|
}
|
|
9
18
|
export declare const CONFIGS: IConfigs;
|
|
19
|
+
export declare const publicRequest: IPublicRequest;
|
|
20
|
+
export declare const setXSourceOrigin: (sourceOrigin: string) => void;
|
|
10
21
|
export declare const setConfigs: (configs: IConfigs) => void;
|
|
11
22
|
export {};
|
package/package.json
CHANGED
package/src/api/index.ts
CHANGED
|
@@ -1,31 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { AxiosRequestConfig, AxiosResponse } from 'axios'
|
|
2
2
|
import _get from 'lodash/get'
|
|
3
3
|
|
|
4
4
|
import { CONFIGS, getCookieByName, setCustomCookie } from '../utils'
|
|
5
|
+
import { publicRequest, ttfHeaders } from '../utils/setConfigs'
|
|
5
6
|
|
|
6
7
|
const isWindowDefined = typeof window !== 'undefined'
|
|
7
8
|
const isDocumentDefined = typeof document !== 'undefined'
|
|
8
9
|
|
|
9
|
-
const ttfHeaders: { [key: string]: any } = {
|
|
10
|
-
Accept: 'application/vnd.api+json',
|
|
11
|
-
'Content-Type': 'application/vnd.api+json',
|
|
12
|
-
}
|
|
13
|
-
|
|
14
10
|
if (isWindowDefined && localStorage.getItem('auth_guest_token')) {
|
|
15
11
|
ttfHeaders['Authorization-Guest'] = localStorage.getItem('auth_guest_token')
|
|
16
12
|
}
|
|
17
13
|
|
|
18
|
-
interface IPublicRequest extends AxiosInstance {
|
|
19
|
-
setGuestToken: (token: string) => void;
|
|
20
|
-
setAccessToken: (token: string) => void;
|
|
21
|
-
setBaseUrl: (baseUrl: string) => void;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const publicRequest: IPublicRequest = axios.create({
|
|
25
|
-
baseURL: CONFIGS.BASE_URL || `https://www.ticketfairy.com/api`,
|
|
26
|
-
headers: ttfHeaders,
|
|
27
|
-
}) as IPublicRequest
|
|
28
|
-
|
|
29
14
|
publicRequest.interceptors.response.use(
|
|
30
15
|
response => {
|
|
31
16
|
const authGuestToken = _get(response, 'headers.authorization-guest')
|
|
@@ -131,10 +116,6 @@ publicRequest.setBaseUrl = (baseUrl: string) =>
|
|
|
131
116
|
publicRequest.setAccessToken = token =>
|
|
132
117
|
(publicRequest.defaults.headers.common.Authorization = token)
|
|
133
118
|
|
|
134
|
-
export const setXSourceOrigin = (sourceOrigin: string) => {
|
|
135
|
-
ttfHeaders['X-Source-Origin'] = sourceOrigin
|
|
136
|
-
}
|
|
137
|
-
|
|
138
119
|
export const setCustomHeader = (response: any) => {
|
|
139
120
|
const guestHeaderResponseValue = _get(response, 'headers.authorization-guest')
|
|
140
121
|
const guestHeaderExistingValue = _get(
|
|
@@ -508,24 +508,23 @@ export const BillingInfoContainer = React.memo(
|
|
|
508
508
|
onSubmit={async (values, formikHelpers) => {
|
|
509
509
|
try {
|
|
510
510
|
if (isLoggedIn) {
|
|
511
|
-
|
|
511
|
+
const checkoutBody = collectCheckoutBody(values, userData)
|
|
512
|
+
const res = await postOnCheckout(checkoutBody, access_token)
|
|
513
|
+
removeReferralKey()
|
|
514
|
+
// After checkout is successful recover updated profile and store it on local storage if needed
|
|
515
|
+
if (isWindowDefined) {
|
|
512
516
|
const updatedUserData = await getProfileData(access_token)
|
|
513
517
|
const profileSpecifiedData = _get(
|
|
514
|
-
|
|
515
|
-
|
|
518
|
+
updatedUserData,
|
|
519
|
+
'data.data'
|
|
516
520
|
)
|
|
517
521
|
const profileDataObj = setLoggedUserData(profileSpecifiedData)
|
|
518
|
-
|
|
519
|
-
window.localStorage.setItem(
|
|
522
|
+
window.localStorage.setItem(
|
|
520
523
|
'user_data',
|
|
521
524
|
JSON.stringify(profileDataObj)
|
|
522
|
-
|
|
523
|
-
}
|
|
525
|
+
)
|
|
524
526
|
}
|
|
525
527
|
|
|
526
|
-
const checkoutBody = collectCheckoutBody(values, userData)
|
|
527
|
-
const res = await postOnCheckout(checkoutBody, access_token)
|
|
528
|
-
removeReferralKey()
|
|
529
528
|
handleSubmit(
|
|
530
529
|
values,
|
|
531
530
|
formikHelpers as FormikHelpers<any>,
|
package/src/utils/setConfigs.ts
CHANGED
|
@@ -1,18 +1,37 @@
|
|
|
1
|
+
import axios, { AxiosInstance } from 'axios';
|
|
1
2
|
import _forEach from 'lodash/forEach'
|
|
2
|
-
import { publicRequest, setXSourceOrigin } from '../api'
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
export const ttfHeaders: { [key: string]: any } = {
|
|
5
|
+
Accept: 'application/vnd.api+json',
|
|
6
|
+
'Content-Type': 'application/vnd.api+json',
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface IPublicRequest extends AxiosInstance {
|
|
10
|
+
setGuestToken: (token: string) => void;
|
|
11
|
+
setAccessToken: (token: string) => void;
|
|
12
|
+
setBaseUrl: (baseUrl: string) => void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface IConfigs {
|
|
5
16
|
BASE_URL: string;
|
|
6
17
|
CLIENT_ID: string;
|
|
7
18
|
CLIENT_SECRET: string;
|
|
8
19
|
STRIPE_PUBLISHABLE_KEY: string;
|
|
9
20
|
X_SOURCE_ORIGIN: string;
|
|
10
|
-
|
|
11
21
|
[key: string]: string | number;
|
|
12
22
|
}
|
|
13
23
|
|
|
14
24
|
export const CONFIGS: IConfigs = {} as IConfigs
|
|
15
25
|
|
|
26
|
+
export const publicRequest: IPublicRequest = axios.create({
|
|
27
|
+
baseURL: CONFIGS.BASE_URL || `https://www.ticketfairy.com/api`,
|
|
28
|
+
headers: ttfHeaders,
|
|
29
|
+
}) as IPublicRequest
|
|
30
|
+
|
|
31
|
+
export const setXSourceOrigin = (sourceOrigin: string) => {
|
|
32
|
+
ttfHeaders['X-Source-Origin'] = sourceOrigin
|
|
33
|
+
}
|
|
34
|
+
|
|
16
35
|
export const setConfigs = (configs: IConfigs) => {
|
|
17
36
|
_forEach(configs, (value, key) => {
|
|
18
37
|
CONFIGS[key] = value
|
|
@@ -23,4 +42,4 @@ export const setConfigs = (configs: IConfigs) => {
|
|
|
23
42
|
if (CONFIGS.X_SOURCE_ORIGIN) {
|
|
24
43
|
setXSourceOrigin(CONFIGS.X_SOURCE_ORIGIN)
|
|
25
44
|
}
|
|
26
|
-
}
|
|
45
|
+
}
|
package/src/.DS_Store
DELETED
|
Binary file
|
package/src/components/.DS_Store
DELETED
|
Binary file
|
|
@@ -1,96 +0,0 @@
|
|
|
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
|
-
};
|