tf-checkout-react 1.3.38 → 1.3.39-beta.2

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.
@@ -0,0 +1 @@
1
+ export declare const createElementFromHTML: (htmlString: string) => ChildNode | "";
@@ -7,3 +7,4 @@ export { setCustomCookie, getCookieByName, deleteCookieByName } from './cookies'
7
7
  export { getDomain } from './getDomain';
8
8
  export { createMarkup } from './createMarkup';
9
9
  export { setLoggedUserData } from './auth';
10
+ export { createElementFromHTML } from './htmlNodeFromString';
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.3.38",
2
+ "version": "1.3.39-beta.2",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
package/src/.DS_Store CHANGED
Binary file
Binary file
@@ -33,6 +33,7 @@ import {
33
33
  register,
34
34
  setCustomHeader,
35
35
  } from '../../api'
36
+ import { usePixel } from '../../hooks/usePixel'
36
37
  import { IBillingInfoData } from '../../types'
37
38
  import {
38
39
  createCheckoutDataBodyWithDefaultHolder,
@@ -312,7 +313,7 @@ export const BillingInfoContainer = React.memo(
312
313
  _get(userData, 'last_name', '') || _get(userValues, 'last_name', '')
313
314
  const showDOB = getQueryVariable('age_required') === 'true'
314
315
  const showTicketHolders = getQueryVariable('names_required') === 'true'
315
- const eventId = getQueryVariable('event_id')
316
+ const eventId = getQueryVariable('event_id') || ''
316
317
  const optedInFieldValue: boolean = brandOptIn
317
318
  ? brandOptIn
318
319
  : _get(cartInfoData, 'optedIn', false)
@@ -519,6 +520,8 @@ export const BillingInfoContainer = React.memo(
519
520
  const initialCountry =
520
521
  selectedCountry.id || _get(userData, 'country', '') || '1'
521
522
 
523
+ usePixel('checkoutPixels', eventId)
524
+
522
525
  return (
523
526
  <ThemeProvider theme={themeMui}>
524
527
  {(loading || isCountriesLoading) && (
@@ -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
+ };
@@ -7,9 +7,10 @@ import _map from 'lodash/map'
7
7
  import React, { useEffect, useRef, useState } from 'react'
8
8
 
9
9
  import { getConfirmationData } from '../../api'
10
+ import { usePixel } from '../../hooks/usePixel'
10
11
  import { IReferralPromotion } from '../../types'
11
- import SocialButtons from './social-buttons'
12
12
  import { createMarkup } from '../../utils'
13
+ import SocialButtons from './social-buttons'
13
14
 
14
15
  export interface IShareButton {
15
16
  mainLabel: string;
@@ -18,7 +19,6 @@ export interface IShareButton {
18
19
  shareData: any;
19
20
  }
20
21
 
21
-
22
22
  export interface IConfirmationLabels {
23
23
  confirmationTitle?: string;
24
24
  confirmationMain?: string;
@@ -48,7 +48,7 @@ export const ConfirmationContainer = ({
48
48
  onGetConfirmationDataSuccess = () => {},
49
49
  onGetConfirmationDataError = () => {},
50
50
  orderHash,
51
- onLinkCopied = () => {}
51
+ onLinkCopied = () => {},
52
52
  }: IConfirmationPage) => {
53
53
  const inputRef = useRef(null)
54
54
  const [data, setData] = useState<any>(null)
@@ -110,45 +110,57 @@ export const ConfirmationContainer = ({
110
110
  confirmationMain = 'Your tickets are available in My Tickets section',
111
111
  confirmationHelper = 'Please bring them with you to the event',
112
112
  } = confirmationLabels
113
+
114
+ usePixel('conversionPixels', data?.product_id)
115
+
113
116
  return (
114
117
  <div className="confirmation-page">
115
118
  {data && (
116
119
  <>
117
- <div className='header-container'>
118
- <div className='header-product-image'>
119
- <img className='product-image' src={data.product_image}/>
120
+ <div className="header-container">
121
+ <div className="header-product-image">
122
+ <img className="product-image" src={data.product_image} />
120
123
  </div>
121
124
  <div className="header-product-text">
122
- <p className="title">{ confirmationTitle }</p>
123
- <div className="share-message-section"
125
+ <p className="title">{confirmationTitle}</p>
126
+ <div
127
+ className="share-message-section"
124
128
  dangerouslySetInnerHTML={
125
- data.custom_confirmation_page_text && data.custom_confirmation_page_text_full_replacement
129
+ data.custom_confirmation_page_text &&
130
+ data.custom_confirmation_page_text_full_replacement
126
131
  ? createMarkup(data.custom_confirmation_page_text)
127
132
  : undefined
128
133
  }
129
134
  >
130
- {data.custom_confirmation_page_text && data.custom_confirmation_page_text_full_replacement
131
- ? undefined
132
- : (
133
- <>
134
- {data.attach_tickets ? (
135
- <span className="main">Your tickets have been emailed to you</span>
136
- ) : (
137
- <span className="main">{ confirmationMain }</span>
138
- )}
139
- <span className="helper">
140
- {data.attach_tickets ? 'Please bring them with you to the event' : confirmationHelper}
135
+ {data.custom_confirmation_page_text &&
136
+ data.custom_confirmation_page_text_full_replacement ? (
137
+ undefined
138
+ ) : (
139
+ <>
140
+ {data.attach_tickets ? (
141
+ <span className="main">
142
+ Your tickets have been emailed to you
141
143
  </span>
142
- </>
143
- )
144
- }
144
+ ) : (
145
+ <span className="main">{confirmationMain}</span>
146
+ )}
147
+ <span className="helper">
148
+ {data.attach_tickets
149
+ ? 'Please bring them with you to the event'
150
+ : confirmationHelper}
151
+ </span>
152
+ </>
153
+ )}
145
154
  </div>
146
155
  </div>
147
156
  </div>
148
- {data.custom_confirmation_page_text && !data.custom_confirmation_page_text_full_replacement ? (
157
+ {data.custom_confirmation_page_text &&
158
+ !data.custom_confirmation_page_text_full_replacement ? (
149
159
  <div
150
- className='custom-confirmation-page-text'
151
- dangerouslySetInnerHTML={createMarkup(data.custom_confirmation_page_text)}
160
+ className="custom-confirmation-page-text"
161
+ dangerouslySetInnerHTML={createMarkup(
162
+ data.custom_confirmation_page_text
163
+ )}
152
164
  />
153
165
  ) : null}
154
166
  {data.disable_referral === false && isReferralEnabled && (
@@ -168,7 +180,11 @@ export const ConfirmationContainer = ({
168
180
  of your ticket money, if they buy tickets as well!
169
181
  </div>
170
182
  </div>
171
- <img className='body-product-image' src={data.product_image} alt="No Data" />
183
+ <img
184
+ className="body-product-image"
185
+ src={data.product_image}
186
+ alt="No Data"
187
+ />
172
188
  </div>
173
189
  <div className="share_wrapper">
174
190
  <div className="share_section">
@@ -197,11 +213,14 @@ export const ConfirmationContainer = ({
197
213
  onLinkCopied()
198
214
  }}
199
215
  >
200
- {hasCopyIcon ? <img
201
- src="https://img.icons8.com/office/50/000000/copy.png"
202
- alt="copy"
203
- />: <span className='copy-icon'>Copy</span>}
204
-
216
+ {hasCopyIcon ? (
217
+ <img
218
+ src="https://img.icons8.com/office/50/000000/copy.png"
219
+ alt="copy"
220
+ />
221
+ ) : (
222
+ <span className="copy-icon">Copy</span>
223
+ )}
205
224
  </div>
206
225
  </div>
207
226
  </div>
@@ -26,6 +26,7 @@ import {
26
26
  } from '../../api'
27
27
  import { X_TF_ECOMMERCE } from '../../constants'
28
28
  import { useCookieListener } from '../../hooks/useCookieListener'
29
+ import { usePixel } from '../../hooks/usePixel'
29
30
  import {
30
31
  createCheckoutDataBodyWithDefaultHolder,
31
32
  deleteCookieByName,
@@ -171,6 +172,7 @@ export const TicketsContainer = ({
171
172
  const ticketsContainerRef = useRef<HTMLDivElement>(null)
172
173
 
173
174
  useCookieListener(X_TF_ECOMMERCE, value => setIsLogged(Boolean(value)))
175
+ usePixel('pagePixels', eventId)
174
176
 
175
177
  useEffect(() => {
176
178
  if (typeof window !== 'undefined') {
@@ -594,7 +596,11 @@ export const TicketsContainer = ({
594
596
  />
595
597
  ) : null}
596
598
  {showWaitingList && event.salesStarted && !hideWaitingList && (
597
- <WaitingList tickets={tickets} eventId={eventId} defaultMaxQuantity={event.waitingListMaxQuantity} />
599
+ <WaitingList
600
+ tickets={tickets}
601
+ eventId={eventId}
602
+ defaultMaxQuantity={event.waitingListMaxQuantity}
603
+ />
598
604
  )}
599
605
  {codeIsLoading ? (
600
606
  <Loader />
@@ -0,0 +1,20 @@
1
+ import _get from 'lodash/get'
2
+ import { useEffect } from 'react'
3
+
4
+ import { getEvent } from '../api'
5
+ import { createElementFromHTML } from '../utils/htmlNodeFromString'
6
+
7
+ export const usePixel = async (key: string, eventId: string | number) => {
8
+ const getEventData = async () => {
9
+ const eventResponse = await getEvent(eventId)
10
+ const event = _get(eventResponse, 'data.data.attributes')
11
+ const pixel = event[key]
12
+ if (document?.head && pixel) {
13
+ document.head.append(createElementFromHTML(pixel))
14
+ }
15
+ }
16
+
17
+ useEffect(() => {
18
+ getEventData()
19
+ }, [])
20
+ }
@@ -0,0 +1,6 @@
1
+ export const createElementFromHTML = (htmlString: string) => {
2
+ const div = document.createElement('div')
3
+ div.innerHTML = htmlString.trim()
4
+ // Change this to div.childNodes to support multiple top-level nodes.
5
+ return div.firstChild || ''
6
+ }
@@ -7,3 +7,4 @@ export { setCustomCookie, getCookieByName, deleteCookieByName } from './cookies'
7
7
  export { getDomain } from './getDomain'
8
8
  export { createMarkup } from './createMarkup'
9
9
  export { setLoggedUserData } from './auth'
10
+ export { createElementFromHTML } from './htmlNodeFromString'
Binary file