tf-checkout-react 1.0.103 → 1.0.106
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 +3 -1
- package/dist/components/common/CustomField.d.ts +1 -1
- package/dist/components/common/DatePickerField.d.ts +14 -0
- package/dist/components/common/RedirectModal.d.ts +7 -0
- package/dist/components/countdown/index.d.ts +3 -1
- package/dist/components/orderDetailsContainer/ticketsTable.d.ts +2 -0
- package/dist/components/rsvpContainer/index.d.ts +7 -0
- package/dist/components/ticketResale/index.d.ts +5 -3
- package/dist/components/ticketsContainer/AccessCodeSection.d.ts +7 -0
- package/dist/components/ticketsContainer/PromoCodeSection.d.ts +5 -9
- package/dist/components/ticketsContainer/TicketsSection.d.ts +6 -3
- package/dist/components/ticketsContainer/index.d.ts +9 -2
- package/dist/components/timerWidget/index.d.ts +3 -3
- package/dist/images/cross.svg +44 -0
- package/dist/images/done.svg +3 -3
- package/dist/index.d.ts +2 -0
- package/dist/tf-checkout-react.cjs.development.js +639 -223
- 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 +645 -231
- package/dist/tf-checkout-react.esm.js.map +1 -1
- package/dist/tf-checkout-styles.css +1 -1
- package/package.json +89 -89
- package/src/.DS_Store +0 -0
- package/src/.d.ts +2 -2
- package/src/api/index.ts +300 -278
- package/src/assets/images/cross.svg +44 -0
- package/src/assets/images/done.svg +3 -3
- package/src/components/.DS_Store +0 -0
- package/src/components/billing-info-container/index.tsx +811 -799
- package/src/components/billing-info-container/style.css +105 -105
- package/src/components/billing-info-container/utils.ts +225 -224
- package/src/components/common/CheckboxField.tsx +41 -41
- package/src/components/common/CustomField.tsx +87 -84
- package/src/components/common/DatePickerField.tsx +98 -0
- package/src/components/common/FormikPhoneNumberField.tsx +51 -51
- package/src/components/common/Loader.tsx +9 -9
- package/src/components/common/RadioField.tsx +35 -35
- package/src/components/common/RedirectModal.tsx +43 -0
- package/src/components/common/SelectField.tsx +80 -80
- package/src/components/common/SnackbarAlert.tsx +53 -53
- package/src/components/common/index.tsx +4 -4
- package/src/components/confirmModal/index.tsx +51 -51
- package/src/components/confirmModal/style.css +21 -21
- package/src/components/confirmationContainer/config.ts +72 -72
- package/src/components/confirmationContainer/index.tsx +197 -197
- package/src/components/confirmationContainer/social-buttons.tsx +94 -94
- package/src/components/confirmationContainer/style.css +202 -202
- package/src/components/countdown/index.tsx +98 -89
- package/src/components/countdown/style.css +9 -9
- package/src/components/index.ts +7 -7
- package/src/components/loginModal/index.tsx +209 -209
- package/src/components/loginModal/style.css +71 -71
- package/src/components/myTicketsContainer/index.tsx +196 -196
- package/src/components/myTicketsContainer/row.tsx +41 -41
- package/src/components/myTicketsContainer/style.css +39 -39
- package/src/components/myTicketsContainer/tableConfig.tsx +34 -34
- package/src/components/orderDetailsContainer/index.tsx +252 -249
- package/src/components/orderDetailsContainer/style.css +72 -72
- package/src/components/orderDetailsContainer/ticketsTable.tsx +130 -124
- package/src/components/paymentContainer/index.tsx +285 -284
- package/src/components/registerModal/index.tsx +190 -190
- package/src/components/rsvpContainer/index.tsx +126 -0
- package/src/components/stripePayment/index.tsx +254 -253
- package/src/components/stripePayment/style.css +59 -59
- package/src/components/ticketResale/index.tsx +74 -56
- package/src/components/ticketResaleModal/index.tsx +215 -210
- package/src/components/ticketResaleModal/style.css +28 -28
- package/src/components/ticketsContainer/AccessCodeSection.tsx +50 -0
- package/src/components/ticketsContainer/PromoCodeSection.tsx +88 -99
- package/src/components/ticketsContainer/ReferralLogic.tsx +31 -33
- package/src/components/ticketsContainer/TicketRow.tsx +83 -83
- package/src/components/ticketsContainer/TicketsSection.tsx +90 -81
- package/src/components/ticketsContainer/index.tsx +464 -430
- package/src/components/ticketsContainer/style.css +181 -181
- package/src/components/ticketsContainer/utils.ts +11 -11
- package/src/components/timerWidget/index.tsx +87 -70
- package/src/components/timerWidget/style.css +34 -26
- package/src/components/waitingList/index.tsx +178 -178
- package/src/components/waitingList/style.css +26 -26
- package/src/env.ts +20 -20
- package/src/index.ts +15 -13
- package/src/normalizers/index.ts +45 -45
- package/src/types/billing-info-data.ts +37 -37
- package/src/types/payment-field.ts +7 -7
- package/src/types/referral-promotion.ts +7 -7
- package/src/utils/createCheckoutDataBodyWithDefaultHolder.ts +59 -59
- package/src/utils/downloadPDF.tsx +30 -30
- package/src/utils/formikErrorFocus.ts +24 -24
- package/src/utils/getImage.ts +14 -14
- package/src/utils/getQueryVariable.ts +13 -13
- package/src/utils/index.ts +5 -5
- package/src/utils/setConfigs.ts +26 -26
- package/src/utils/showZero.tsx +10 -10
- package/src/validators/index.ts +20 -20
|
@@ -1,799 +1,811 @@
|
|
|
1
|
-
import React, { FC, useEffect, useState, useRef } from 'react'
|
|
2
|
-
import { AxiosError } from 'axios'
|
|
3
|
-
import {
|
|
4
|
-
Field,
|
|
5
|
-
Form,
|
|
6
|
-
Formik,
|
|
7
|
-
FormikHelpers,
|
|
8
|
-
FormikProps,
|
|
9
|
-
FormikValues,
|
|
10
|
-
} from 'formik'
|
|
11
|
-
import Button from '@mui/material/Button'
|
|
12
|
-
import _identity from 'lodash/identity'
|
|
13
|
-
import _map from 'lodash/map'
|
|
14
|
-
import _get from 'lodash/get'
|
|
15
|
-
import _includes from 'lodash/includes'
|
|
16
|
-
import _isEqual from 'lodash/isEqual'
|
|
17
|
-
import _isEmpty from 'lodash/isEmpty'
|
|
18
|
-
|
|
19
|
-
import './style.css'
|
|
20
|
-
import { combineValidators, requiredValidator } from '../../validators'
|
|
21
|
-
import { IBillingInfoData } from '../../types'
|
|
22
|
-
import {
|
|
23
|
-
getCart,
|
|
24
|
-
getCountries,
|
|
25
|
-
getProfileData,
|
|
26
|
-
handleSetAccessToken,
|
|
27
|
-
postOnCheckout,
|
|
28
|
-
register,
|
|
29
|
-
setCustomHeader,
|
|
30
|
-
getStates,
|
|
31
|
-
} from '../../api'
|
|
32
|
-
import { LoginModal } from '../loginModal'
|
|
33
|
-
import { RegisterModal } from '../registerModal'
|
|
34
|
-
import {
|
|
35
|
-
assingUniqueIds,
|
|
36
|
-
createCheckoutDataBody,
|
|
37
|
-
createRegisterFormData,
|
|
38
|
-
getInitialValues,
|
|
39
|
-
getValidateFunctions,
|
|
40
|
-
setLoggedUserData,
|
|
41
|
-
} from './utils'
|
|
42
|
-
import { createCheckoutDataBodyWithDefaultHolder } from '../../utils'
|
|
43
|
-
import axios from 'axios'
|
|
44
|
-
import { CustomField, CheckboxField, SelectField, FormikPhoneNumberField } from '../common/index'
|
|
45
|
-
import { CircularProgress, ThemeOptions } from '@mui/material'
|
|
46
|
-
import { nanoid } from 'nanoid'
|
|
47
|
-
import { getQueryVariable } from '../../utils/getQueryVariable'
|
|
48
|
-
import { ErrorFocus } from '../../utils/formikErrorFocus'
|
|
49
|
-
import { ThemeProvider, createTheme } from '@mui/material/styles'
|
|
50
|
-
import { CSSProperties } from '@mui/styles'
|
|
51
|
-
import Backdrop from '@mui/material/Backdrop'
|
|
52
|
-
import TimerWidget from '../timerWidget'
|
|
53
|
-
import SnackbarAlert from '../common/SnackbarAlert'
|
|
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
|
-
const
|
|
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
|
-
const
|
|
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
|
-
const
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
const [
|
|
232
|
-
const [
|
|
233
|
-
const [
|
|
234
|
-
const [
|
|
235
|
-
const [
|
|
236
|
-
const [
|
|
237
|
-
const [
|
|
238
|
-
const [
|
|
239
|
-
const [
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
const [
|
|
256
|
-
const
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
const
|
|
264
|
-
const
|
|
265
|
-
const
|
|
266
|
-
const
|
|
267
|
-
const
|
|
268
|
-
const
|
|
269
|
-
const
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
const
|
|
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
|
-
const
|
|
345
|
-
const
|
|
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
|
-
|
|
427
|
-
|
|
428
|
-
/>
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
)
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
{
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
element.
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
)
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
}
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
1
|
+
import React, { FC, useEffect, useState, useRef } from 'react'
|
|
2
|
+
import { AxiosError } from 'axios'
|
|
3
|
+
import {
|
|
4
|
+
Field,
|
|
5
|
+
Form,
|
|
6
|
+
Formik,
|
|
7
|
+
FormikHelpers,
|
|
8
|
+
FormikProps,
|
|
9
|
+
FormikValues,
|
|
10
|
+
} from 'formik'
|
|
11
|
+
import Button from '@mui/material/Button'
|
|
12
|
+
import _identity from 'lodash/identity'
|
|
13
|
+
import _map from 'lodash/map'
|
|
14
|
+
import _get from 'lodash/get'
|
|
15
|
+
import _includes from 'lodash/includes'
|
|
16
|
+
import _isEqual from 'lodash/isEqual'
|
|
17
|
+
import _isEmpty from 'lodash/isEmpty'
|
|
18
|
+
|
|
19
|
+
import './style.css'
|
|
20
|
+
import { combineValidators, requiredValidator } from '../../validators'
|
|
21
|
+
import { IBillingInfoData } from '../../types'
|
|
22
|
+
import {
|
|
23
|
+
getCart,
|
|
24
|
+
getCountries,
|
|
25
|
+
getProfileData,
|
|
26
|
+
handleSetAccessToken,
|
|
27
|
+
postOnCheckout,
|
|
28
|
+
register,
|
|
29
|
+
setCustomHeader,
|
|
30
|
+
getStates,
|
|
31
|
+
} from '../../api'
|
|
32
|
+
import { LoginModal } from '../loginModal'
|
|
33
|
+
import { RegisterModal } from '../registerModal'
|
|
34
|
+
import {
|
|
35
|
+
assingUniqueIds,
|
|
36
|
+
createCheckoutDataBody,
|
|
37
|
+
createRegisterFormData,
|
|
38
|
+
getInitialValues,
|
|
39
|
+
getValidateFunctions,
|
|
40
|
+
setLoggedUserData,
|
|
41
|
+
} from './utils'
|
|
42
|
+
import { createCheckoutDataBodyWithDefaultHolder } from '../../utils'
|
|
43
|
+
import axios from 'axios'
|
|
44
|
+
import { CustomField, CheckboxField, SelectField, FormikPhoneNumberField } from '../common/index'
|
|
45
|
+
import { CircularProgress, ThemeOptions } from '@mui/material'
|
|
46
|
+
import { nanoid } from 'nanoid'
|
|
47
|
+
import { getQueryVariable } from '../../utils/getQueryVariable'
|
|
48
|
+
import { ErrorFocus } from '../../utils/formikErrorFocus'
|
|
49
|
+
import { ThemeProvider, createTheme } from '@mui/material/styles'
|
|
50
|
+
import { CSSProperties } from '@mui/styles'
|
|
51
|
+
import Backdrop from '@mui/material/Backdrop'
|
|
52
|
+
import TimerWidget from '../timerWidget'
|
|
53
|
+
import SnackbarAlert from '../common/SnackbarAlert'
|
|
54
|
+
import { DatePickerField } from '../common/DatePickerField'
|
|
55
|
+
|
|
56
|
+
export interface IBillingInfoPage {
|
|
57
|
+
data?: IBillingInfoData[];
|
|
58
|
+
ticketHoldersFields?: IBillingInfoData;
|
|
59
|
+
handleSubmit?: (
|
|
60
|
+
values: FormikValues,
|
|
61
|
+
formikHelpers: FormikHelpers<FormikValues>,
|
|
62
|
+
eventId: any,
|
|
63
|
+
res: any
|
|
64
|
+
) => void;
|
|
65
|
+
onRegisterSuccess?: (value: {
|
|
66
|
+
accessToken: string;
|
|
67
|
+
refreshToken: string;
|
|
68
|
+
}) => void;
|
|
69
|
+
onRegisterError?: (e: AxiosError, email: string) => void;
|
|
70
|
+
onSubmitError?: (e: AxiosError) => void;
|
|
71
|
+
onGetCartSuccess?: (res: any) => void;
|
|
72
|
+
onGetCartError?: (e: AxiosError) => void;
|
|
73
|
+
onGetCountriesSuccess?: (res: any) => void;
|
|
74
|
+
onGetCountriesError?: (e: AxiosError) => void;
|
|
75
|
+
onGetStatesSuccess?: (res: any) => void;
|
|
76
|
+
onGetStatesError?: (e: AxiosError) => void;
|
|
77
|
+
onGetProfileDataSuccess?: (res: any) => void;
|
|
78
|
+
onGetProfileDataError?: (e: AxiosError) => void;
|
|
79
|
+
onAuthorizeSuccess?: () => void;
|
|
80
|
+
onAuthorizeError?: (e: AxiosError) => void;
|
|
81
|
+
onLogin?: () => void;
|
|
82
|
+
onLoginSuccess?: () => void;
|
|
83
|
+
onErrorClose?: () => void;
|
|
84
|
+
initialValues?: FormikValues;
|
|
85
|
+
buttonName?: string;
|
|
86
|
+
theme?: 'light' | 'dark';
|
|
87
|
+
isLoggedIn?: boolean;
|
|
88
|
+
accountInfoTitle?: string | JSX.Element;
|
|
89
|
+
hideLogo?: boolean;
|
|
90
|
+
themeOptions?: ThemeOptions & {
|
|
91
|
+
input?: CSSProperties;
|
|
92
|
+
checkbox?: CSSProperties;
|
|
93
|
+
};
|
|
94
|
+
hideErrorsAlertSection?: boolean;
|
|
95
|
+
onSkipBillingPage: (data: any) => void;
|
|
96
|
+
skipPage?: boolean;
|
|
97
|
+
canSkipHolderNames?: boolean;
|
|
98
|
+
onCountdownFinish?: () => void;
|
|
99
|
+
enableTimer?: boolean;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const LogicRunner: FC<{
|
|
103
|
+
values: any;
|
|
104
|
+
setStates: React.Dispatch<any>;
|
|
105
|
+
setFieldValue: any;
|
|
106
|
+
setValues: any;
|
|
107
|
+
setUserValues: any;
|
|
108
|
+
onGetStatesSuccess: any;
|
|
109
|
+
onGetStatesError: any;
|
|
110
|
+
}> = ({
|
|
111
|
+
values,
|
|
112
|
+
setStates,
|
|
113
|
+
setFieldValue,
|
|
114
|
+
setValues,
|
|
115
|
+
setUserValues,
|
|
116
|
+
onGetStatesSuccess,
|
|
117
|
+
onGetStatesError,
|
|
118
|
+
}) => {
|
|
119
|
+
const prevCountry = useRef(values.country)
|
|
120
|
+
useEffect(() => {
|
|
121
|
+
const fetchStates = async () => {
|
|
122
|
+
try {
|
|
123
|
+
const res = await getStates(values.country)
|
|
124
|
+
const mappedStates = _map(_get(res, 'data.data'), (item, key) => ({
|
|
125
|
+
label: item,
|
|
126
|
+
value: key,
|
|
127
|
+
}))
|
|
128
|
+
setStates(mappedStates)
|
|
129
|
+
if (prevCountry.current !== values.country) {
|
|
130
|
+
setFieldValue('state', mappedStates[0]?.value ?? '')
|
|
131
|
+
prevCountry.current = values.country
|
|
132
|
+
}
|
|
133
|
+
onGetStatesSuccess(res.data)
|
|
134
|
+
} catch (e) {
|
|
135
|
+
if (axios.isAxiosError(e)) {
|
|
136
|
+
onGetStatesError(e)
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
fetchStates()
|
|
141
|
+
}, [values.country, setStates, setFieldValue])
|
|
142
|
+
const userDataEncoded =
|
|
143
|
+
typeof window !== 'undefined'
|
|
144
|
+
? window.localStorage.getItem('user_data')
|
|
145
|
+
: ''
|
|
146
|
+
useEffect(() => {
|
|
147
|
+
// set user data from local storage
|
|
148
|
+
const getStoredUserData = () => {
|
|
149
|
+
if (typeof window !== 'undefined') {
|
|
150
|
+
if (userDataEncoded) {
|
|
151
|
+
try {
|
|
152
|
+
const parsedData = JSON.parse(userDataEncoded)
|
|
153
|
+
const mappedValues = {
|
|
154
|
+
firstName: parsedData?.first_name || '',
|
|
155
|
+
lastName: parsedData?.last_name || '',
|
|
156
|
+
email: parsedData?.email || '',
|
|
157
|
+
phone: parsedData?.phone || '',
|
|
158
|
+
confirmEmail: parsedData?.email || '',
|
|
159
|
+
state: parsedData?.state || '',
|
|
160
|
+
street_address: parsedData?.street_address || '',
|
|
161
|
+
country: parsedData?.country || '1',
|
|
162
|
+
zip: parsedData?.zip || '',
|
|
163
|
+
brand_opt_in: parsedData?.brand_opt_in || '',
|
|
164
|
+
city: parsedData?.city || '',
|
|
165
|
+
confirmPassword: '',
|
|
166
|
+
password: '',
|
|
167
|
+
'holderFirstName-0': parsedData?.first_name || '',
|
|
168
|
+
'holderLastName-0': parsedData?.last_name || '',
|
|
169
|
+
'holderEmail-0': parsedData?.email || '',
|
|
170
|
+
}
|
|
171
|
+
setValues(mappedValues)
|
|
172
|
+
setUserValues(mappedValues)
|
|
173
|
+
} catch (e) {}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
getStoredUserData()
|
|
178
|
+
}, [userDataEncoded, setValues, setUserValues])
|
|
179
|
+
return null
|
|
180
|
+
}
|
|
181
|
+
export const BillingInfoContainer = ({
|
|
182
|
+
data = [],
|
|
183
|
+
ticketHoldersFields = {
|
|
184
|
+
id: 1,
|
|
185
|
+
fields: [],
|
|
186
|
+
},
|
|
187
|
+
initialValues = {},
|
|
188
|
+
buttonName = 'Submit',
|
|
189
|
+
handleSubmit = _identity,
|
|
190
|
+
theme = 'light',
|
|
191
|
+
onRegisterSuccess = () => {},
|
|
192
|
+
onRegisterError = () => {},
|
|
193
|
+
onSubmitError = () => {},
|
|
194
|
+
onGetCartSuccess = () => {},
|
|
195
|
+
onGetCartError = () => {},
|
|
196
|
+
onGetCountriesSuccess = () => {},
|
|
197
|
+
onGetCountriesError = () => {},
|
|
198
|
+
onGetStatesSuccess = () => {},
|
|
199
|
+
onGetStatesError = () => {},
|
|
200
|
+
onGetProfileDataSuccess = () => {},
|
|
201
|
+
onGetProfileDataError = () => {},
|
|
202
|
+
onAuthorizeSuccess = () => {},
|
|
203
|
+
onAuthorizeError = () => {},
|
|
204
|
+
onLogin,
|
|
205
|
+
onLoginSuccess = () => {},
|
|
206
|
+
isLoggedIn: pIsLoggedIn = false,
|
|
207
|
+
accountInfoTitle = '',
|
|
208
|
+
hideLogo,
|
|
209
|
+
themeOptions,
|
|
210
|
+
onErrorClose = () => {},
|
|
211
|
+
hideErrorsAlertSection = false,
|
|
212
|
+
onSkipBillingPage = () => {},
|
|
213
|
+
skipPage = false,
|
|
214
|
+
canSkipHolderNames = false,
|
|
215
|
+
onCountdownFinish = () => {},
|
|
216
|
+
enableTimer = false
|
|
217
|
+
}: IBillingInfoPage) => {
|
|
218
|
+
const themeMui = createTheme(themeOptions)
|
|
219
|
+
const isWindowDefined = typeof window !== 'undefined'
|
|
220
|
+
const userData =
|
|
221
|
+
isWindowDefined && window.localStorage.getItem('user_data')
|
|
222
|
+
? JSON.parse(window.localStorage.getItem('user_data') || '')
|
|
223
|
+
: {}
|
|
224
|
+
const access_token =
|
|
225
|
+
isWindowDefined && window.localStorage.getItem('access_token')
|
|
226
|
+
? window.localStorage.getItem('access_token') || ''
|
|
227
|
+
: ''
|
|
228
|
+
const [dataWithUniqueIds, setDataWithUniqueIds] = useState<
|
|
229
|
+
IBillingInfoData[]
|
|
230
|
+
>(data)
|
|
231
|
+
const [isLoggedIn, setIsLoggedIn] = useState(!!access_token)
|
|
232
|
+
const [cartInfoData, setCartInfo] = useState<any>({})
|
|
233
|
+
const [countries, setCountries] = useState<any>([])
|
|
234
|
+
const [states, setStates] = useState<any>([])
|
|
235
|
+
const [showModalLogin, setShowModalLogin] = useState(false)
|
|
236
|
+
const [alreadyHasUser, setAlreadyHasUser] = useState(false)
|
|
237
|
+
const [userExpired, setUserExpired] = useState(false)
|
|
238
|
+
const [showModalRegister, setShowModalRegister] = useState(false)
|
|
239
|
+
const [ticketsQuantity, setTicketsQuantity] = useState<string[]>([])
|
|
240
|
+
const [userValues, setUserValues] = useState<any>({
|
|
241
|
+
firstName: '',
|
|
242
|
+
lastName: '',
|
|
243
|
+
email: '',
|
|
244
|
+
phone: '',
|
|
245
|
+
confirmEmail: '',
|
|
246
|
+
holderFirstName: '',
|
|
247
|
+
holderLastName: '',
|
|
248
|
+
holderAge: '',
|
|
249
|
+
city: '',
|
|
250
|
+
country: '',
|
|
251
|
+
street_address: '',
|
|
252
|
+
state: '',
|
|
253
|
+
zip: '',
|
|
254
|
+
})
|
|
255
|
+
const [loading, setLoading] = useState(true)
|
|
256
|
+
const [error, setError] = useState(null)
|
|
257
|
+
const emailLogged =
|
|
258
|
+
_get(userData, 'email', '') || _get(userValues, 'email', '')
|
|
259
|
+
const firstNameLogged =
|
|
260
|
+
_get(userData, 'first_name', '') || _get(userValues, 'first_name', '')
|
|
261
|
+
const lastNameLogged =
|
|
262
|
+
_get(userData, 'last_name', '') || _get(userValues, 'last_name', '')
|
|
263
|
+
const showDOB = getQueryVariable('age_required') === 'true'
|
|
264
|
+
const showTicketHolders = getQueryVariable('names_required') === 'true'
|
|
265
|
+
const eventId = getQueryVariable('event_id')
|
|
266
|
+
const optedInFieldValue: boolean = _get(cartInfoData, 'optedIn', false)
|
|
267
|
+
const ttfOptIn: boolean = Boolean(_get(cartInfoData, 'ttfOptIn', false))
|
|
268
|
+
const hideTtfOptIn: boolean = _get(cartInfoData, 'hide_ttf_opt_in', true)
|
|
269
|
+
const expirationTime = _get(cartInfoData, 'expiresAt')
|
|
270
|
+
const flagRequirePhone = getQueryVariable('phone_required') === 'true'
|
|
271
|
+
|
|
272
|
+
// Get prevProps
|
|
273
|
+
const prevData = useRef(data)
|
|
274
|
+
|
|
275
|
+
useEffect(() => {
|
|
276
|
+
const hasUniqueId = _get(dataWithUniqueIds, '[0].uniqueId')
|
|
277
|
+
const isEqualData = _isEqual(prevData.current, data)
|
|
278
|
+
if (!hasUniqueId || !isEqualData) {
|
|
279
|
+
setDataWithUniqueIds(assingUniqueIds(data))
|
|
280
|
+
if (!isEqualData) {
|
|
281
|
+
prevData.current = data
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}, [dataWithUniqueIds, data])
|
|
285
|
+
|
|
286
|
+
const getQuantity = (cart: any = []) => {
|
|
287
|
+
let qty: any = 0
|
|
288
|
+
cart.forEach((item: any) => {
|
|
289
|
+
qty += +item.quantity
|
|
290
|
+
})
|
|
291
|
+
return qty
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
useEffect(() => {
|
|
295
|
+
if ((pIsLoggedIn || access_token) && !isLoggedIn) {
|
|
296
|
+
setIsLoggedIn(true)
|
|
297
|
+
}
|
|
298
|
+
}, [pIsLoggedIn, isLoggedIn, access_token])
|
|
299
|
+
//just once
|
|
300
|
+
useEffect(() => {
|
|
301
|
+
// fetch countries data
|
|
302
|
+
const fetchCountries = async () => {
|
|
303
|
+
try {
|
|
304
|
+
const res = await getCountries()
|
|
305
|
+
setCustomHeader(res)
|
|
306
|
+
setCountries(
|
|
307
|
+
_map(_get(res, 'data.data'), (item, key) => ({
|
|
308
|
+
label: item,
|
|
309
|
+
value: key,
|
|
310
|
+
}))
|
|
311
|
+
)
|
|
312
|
+
onGetCountriesSuccess(res.data)
|
|
313
|
+
} catch (e) {
|
|
314
|
+
if (axios.isAxiosError(e)) {
|
|
315
|
+
onGetCountriesError(e)
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
fetchCountries()
|
|
320
|
+
fetchCart()
|
|
321
|
+
}, [])
|
|
322
|
+
// fetch cart data
|
|
323
|
+
const fetchCart = async () => {
|
|
324
|
+
try {
|
|
325
|
+
const res = await getCart()
|
|
326
|
+
setCustomHeader(res)
|
|
327
|
+
const cartInfo = _get(res, 'data.data.attributes')
|
|
328
|
+
setCartInfo(cartInfo)
|
|
329
|
+
const { cart = [] } = cartInfo
|
|
330
|
+
setTicketsQuantity(
|
|
331
|
+
new Array(getQuantity(cart)).fill(null).map(() => nanoid())
|
|
332
|
+
)
|
|
333
|
+
onGetCartSuccess(res.data)
|
|
334
|
+
} catch (e) {
|
|
335
|
+
if (axios.isAxiosError(e)) {
|
|
336
|
+
onGetCartError(e)
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
// fetch user data
|
|
341
|
+
const fetchUserData = async (token: string) => {
|
|
342
|
+
try {
|
|
343
|
+
if (isWindowDefined && token) {
|
|
344
|
+
const userDataResponse = await getProfileData(token)
|
|
345
|
+
const profileSpecifiedData = _get(userDataResponse, 'data.data')
|
|
346
|
+
const profileDataObj = setLoggedUserData(profileSpecifiedData)
|
|
347
|
+
setUserValues({
|
|
348
|
+
...profileDataObj,
|
|
349
|
+
firstName: profileDataObj.first_name,
|
|
350
|
+
lastName: profileDataObj.last_name,
|
|
351
|
+
})
|
|
352
|
+
window.localStorage.setItem(
|
|
353
|
+
'user_data',
|
|
354
|
+
JSON.stringify(profileDataObj)
|
|
355
|
+
)
|
|
356
|
+
onGetProfileDataSuccess(userDataResponse.data)
|
|
357
|
+
}
|
|
358
|
+
} catch (e) {
|
|
359
|
+
if (axios.isAxiosError(e)) {
|
|
360
|
+
onGetProfileDataError(e)
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
useEffect(() => {
|
|
365
|
+
fetchUserData(access_token)
|
|
366
|
+
}, [access_token])
|
|
367
|
+
|
|
368
|
+
useEffect(() => {
|
|
369
|
+
const collectPaymentData = async () => {
|
|
370
|
+
if (skipPage && !_isEmpty(ticketsQuantity) && !showDOB) {
|
|
371
|
+
setLoading(true)
|
|
372
|
+
const checkoutBody = createCheckoutDataBodyWithDefaultHolder(
|
|
373
|
+
ticketsQuantity.length,
|
|
374
|
+
userData
|
|
375
|
+
)
|
|
376
|
+
|
|
377
|
+
try {
|
|
378
|
+
const res = await postOnCheckout(checkoutBody, access_token)
|
|
379
|
+
removeReferralKey()
|
|
380
|
+
onSkipBillingPage(_get(res, 'data.data.attributes'))
|
|
381
|
+
setLoading(false)
|
|
382
|
+
} catch (e) {
|
|
383
|
+
onSubmitError(e)
|
|
384
|
+
}
|
|
385
|
+
} else {
|
|
386
|
+
setLoading(false)
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
collectPaymentData()
|
|
390
|
+
}, [skipPage, ticketsQuantity])
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
const collectCheckoutBody = (values: object): object => {
|
|
394
|
+
let checkoutBody = {}
|
|
395
|
+
|
|
396
|
+
// Auto collect ticket holders name when it was skipped optionally
|
|
397
|
+
if (showDOB && !showTicketHolders && canSkipHolderNames) {
|
|
398
|
+
checkoutBody = createCheckoutDataBodyWithDefaultHolder(
|
|
399
|
+
ticketsQuantity.length,
|
|
400
|
+
values,
|
|
401
|
+
true
|
|
402
|
+
)
|
|
403
|
+
} else {
|
|
404
|
+
checkoutBody = createCheckoutDataBody(
|
|
405
|
+
ticketsQuantity.length,
|
|
406
|
+
values,
|
|
407
|
+
{ emailLogged, firstNameLogged, lastNameLogged },
|
|
408
|
+
showDOB
|
|
409
|
+
)
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
return checkoutBody
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
const removeReferralKey = () => {
|
|
416
|
+
localStorage.removeItem('referral_key')
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
// Displaying loader
|
|
420
|
+
if (loading || (enableTimer && !expirationTime && typeof window !== 'undefined')) {
|
|
421
|
+
if (expirationTime === 0) {
|
|
422
|
+
// Redirect to homepage (countdown finished and browser reloaded case)
|
|
423
|
+
window.location.href='/'
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
return (
|
|
427
|
+
<Backdrop sx={{ color: '#fff' }} open={true}>
|
|
428
|
+
<CircularProgress color="inherit" />
|
|
429
|
+
</Backdrop>
|
|
430
|
+
)
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
return (
|
|
434
|
+
<ThemeProvider theme={themeMui}>
|
|
435
|
+
{!!expirationTime && enableTimer && (
|
|
436
|
+
<TimerWidget
|
|
437
|
+
expires_at={expirationTime}
|
|
438
|
+
onCountdownFinish={onCountdownFinish}
|
|
439
|
+
/>
|
|
440
|
+
)}
|
|
441
|
+
<Formik
|
|
442
|
+
initialValues={getInitialValues(
|
|
443
|
+
dataWithUniqueIds,
|
|
444
|
+
{
|
|
445
|
+
...initialValues,
|
|
446
|
+
country: _get(userData, 'country', '') || '1',
|
|
447
|
+
state: _get(userData, 'state', '') || '1',
|
|
448
|
+
brand_opt_in: optedInFieldValue,
|
|
449
|
+
ttf_opt_in: ttfOptIn,
|
|
450
|
+
},
|
|
451
|
+
userValues
|
|
452
|
+
)}
|
|
453
|
+
enableReinitialize={true}
|
|
454
|
+
onSubmit={async (values, formikHelpers) => {
|
|
455
|
+
try {
|
|
456
|
+
if (isLoggedIn) {
|
|
457
|
+
if (access_token) {
|
|
458
|
+
const updatedUserData = await getProfileData(access_token)
|
|
459
|
+
const profileSpecifiedData = _get(updatedUserData, 'data.data')
|
|
460
|
+
const profileDataObj = setLoggedUserData(profileSpecifiedData)
|
|
461
|
+
if (isWindowDefined) {
|
|
462
|
+
window.localStorage.setItem(
|
|
463
|
+
'user_data',
|
|
464
|
+
JSON.stringify(profileDataObj)
|
|
465
|
+
)
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
const checkoutBody = collectCheckoutBody(values)
|
|
470
|
+
const res = await postOnCheckout(checkoutBody, access_token)
|
|
471
|
+
removeReferralKey()
|
|
472
|
+
handleSubmit(
|
|
473
|
+
values,
|
|
474
|
+
formikHelpers as FormikHelpers<any>,
|
|
475
|
+
eventId,
|
|
476
|
+
res
|
|
477
|
+
)
|
|
478
|
+
return
|
|
479
|
+
}
|
|
480
|
+
const checkoutBodyForRegistration = createCheckoutDataBody(
|
|
481
|
+
ticketsQuantity.length,
|
|
482
|
+
values,
|
|
483
|
+
{ emailLogged, firstNameLogged, lastNameLogged },
|
|
484
|
+
showDOB
|
|
485
|
+
)
|
|
486
|
+
const bodyFormData = createRegisterFormData(
|
|
487
|
+
values,
|
|
488
|
+
checkoutBodyForRegistration
|
|
489
|
+
)
|
|
490
|
+
let access_token_register = null
|
|
491
|
+
try {
|
|
492
|
+
const resRegister = await register(bodyFormData)
|
|
493
|
+
access_token_register = _get(
|
|
494
|
+
resRegister,
|
|
495
|
+
'data.data.attributes.access_token'
|
|
496
|
+
)
|
|
497
|
+
const refreshToken = _get(
|
|
498
|
+
resRegister,
|
|
499
|
+
'data.data.attributes.refresh_token'
|
|
500
|
+
)
|
|
501
|
+
handleSetAccessToken(access_token_register)
|
|
502
|
+
const tokens = {
|
|
503
|
+
accessToken: access_token_register,
|
|
504
|
+
refreshToken,
|
|
505
|
+
}
|
|
506
|
+
onRegisterSuccess(tokens)
|
|
507
|
+
} catch (e) {
|
|
508
|
+
if (axios.isAxiosError(e)) {
|
|
509
|
+
const error = e?.response?.data?.message
|
|
510
|
+
if (_includes(error, 'You must be aged')) {
|
|
511
|
+
formikHelpers.setFieldError('holderAge', error)
|
|
512
|
+
}
|
|
513
|
+
if (error?.password) {
|
|
514
|
+
formikHelpers.setFieldError('password', error.password)
|
|
515
|
+
formikHelpers.setFieldError(
|
|
516
|
+
'confirmPassword',
|
|
517
|
+
error.password
|
|
518
|
+
)
|
|
519
|
+
}
|
|
520
|
+
if (error?.email && !onLogin) {
|
|
521
|
+
// False will stand for outside controll
|
|
522
|
+
setAlreadyHasUser(true)
|
|
523
|
+
setShowModalLogin(true)
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
if (_includes(error, 'The cart is expired') && !hideErrorsAlertSection) {
|
|
527
|
+
setError(error)
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
onRegisterError(e, values.email)
|
|
531
|
+
}
|
|
532
|
+
return
|
|
533
|
+
}
|
|
534
|
+
const profileData = await getProfileData(access_token_register)
|
|
535
|
+
const profileSpecifiedData = _get(profileData, 'data.data')
|
|
536
|
+
const profileDataObj = setLoggedUserData(profileSpecifiedData)
|
|
537
|
+
if (isWindowDefined) {
|
|
538
|
+
window.localStorage.setItem(
|
|
539
|
+
'user_data',
|
|
540
|
+
JSON.stringify(profileDataObj)
|
|
541
|
+
)
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
const checkoutBody = collectCheckoutBody(values)
|
|
545
|
+
const res = await postOnCheckout(
|
|
546
|
+
checkoutBody,
|
|
547
|
+
access_token_register
|
|
548
|
+
)
|
|
549
|
+
removeReferralKey()
|
|
550
|
+
handleSubmit(
|
|
551
|
+
values,
|
|
552
|
+
formikHelpers as FormikHelpers<any>,
|
|
553
|
+
eventId,
|
|
554
|
+
res
|
|
555
|
+
)
|
|
556
|
+
} catch (e) {
|
|
557
|
+
if (axios.isAxiosError(e)) {
|
|
558
|
+
if (e.response?.data.error === 'invalid_token') {
|
|
559
|
+
if (isWindowDefined) {
|
|
560
|
+
window.localStorage.removeItem('user_data')
|
|
561
|
+
window.localStorage.removeItem('access_token')
|
|
562
|
+
setUserExpired(true)
|
|
563
|
+
setShowModalLogin(true)
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
if (e.response?.data.message && !hideErrorsAlertSection) {
|
|
567
|
+
setError(_get(e, 'response.data.message'))
|
|
568
|
+
}
|
|
569
|
+
onSubmitError(e)
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
}}
|
|
573
|
+
>
|
|
574
|
+
{(props: FormikProps<any>) => (
|
|
575
|
+
<Form onSubmit={props.handleSubmit}>
|
|
576
|
+
<ErrorFocus />
|
|
577
|
+
<LogicRunner
|
|
578
|
+
values={props.values}
|
|
579
|
+
setStates={setStates}
|
|
580
|
+
setFieldValue={props.setFieldValue}
|
|
581
|
+
setValues={props.setValues}
|
|
582
|
+
setUserValues={setUserValues}
|
|
583
|
+
onGetStatesSuccess={onGetStatesSuccess}
|
|
584
|
+
onGetStatesError={onGetStatesError}
|
|
585
|
+
/>
|
|
586
|
+
<div className={`billing-info-container ${theme}`}>
|
|
587
|
+
<SnackbarAlert
|
|
588
|
+
type="error"
|
|
589
|
+
isOpen={!!error}
|
|
590
|
+
message={error || ''}
|
|
591
|
+
onClose={() => {
|
|
592
|
+
setError(null)
|
|
593
|
+
onErrorClose()
|
|
594
|
+
}}
|
|
595
|
+
/>
|
|
596
|
+
{!isLoggedIn && (
|
|
597
|
+
<div className="account-actions-block">
|
|
598
|
+
<div>{accountInfoTitle}</div>
|
|
599
|
+
<div>Login & skip ahead:</div>
|
|
600
|
+
<div className="login-block">
|
|
601
|
+
<button
|
|
602
|
+
className="login-register-button"
|
|
603
|
+
type="button"
|
|
604
|
+
onClick={() => {
|
|
605
|
+
// If outside login needed to skip package login functionallity
|
|
606
|
+
if (onLogin) {
|
|
607
|
+
onLogin()
|
|
608
|
+
} else {
|
|
609
|
+
setShowModalLogin(true)
|
|
610
|
+
}
|
|
611
|
+
}}
|
|
612
|
+
>
|
|
613
|
+
Login
|
|
614
|
+
</button>
|
|
615
|
+
{!hideLogo && (
|
|
616
|
+
<div className="logo-image-container">
|
|
617
|
+
<img
|
|
618
|
+
src={
|
|
619
|
+
theme === 'dark'
|
|
620
|
+
? 'https://www.ticketfairy.com/resources/images/logo-ttf.svg'
|
|
621
|
+
: 'https://www.ticketfairy.com/resources/images/logo-ttf-black.svg'
|
|
622
|
+
}
|
|
623
|
+
alt="nodata"
|
|
624
|
+
/>
|
|
625
|
+
</div>
|
|
626
|
+
)}
|
|
627
|
+
</div>
|
|
628
|
+
</div>
|
|
629
|
+
)}
|
|
630
|
+
{_map(dataWithUniqueIds, item => {
|
|
631
|
+
const { label, labelClassName, fields } = item
|
|
632
|
+
return (
|
|
633
|
+
<React.Fragment key={item.uniqueId}>
|
|
634
|
+
<p className={labelClassName}>{label}</p>
|
|
635
|
+
{_map(fields, group => {
|
|
636
|
+
const { groupClassname, groupItems } = group
|
|
637
|
+
return (
|
|
638
|
+
<React.Fragment key={group.uniqueId}>
|
|
639
|
+
<div className={groupClassname}>
|
|
640
|
+
{_map(
|
|
641
|
+
groupItems.filter(el => {
|
|
642
|
+
if (el.name === 'holderAge' && !showDOB) {
|
|
643
|
+
return false
|
|
644
|
+
}
|
|
645
|
+
if (el.name === 'ttf_opt_in' && hideTtfOptIn) {
|
|
646
|
+
return false
|
|
647
|
+
}
|
|
648
|
+
if (el.name === 'phone') {
|
|
649
|
+
el.required = flagRequirePhone
|
|
650
|
+
}
|
|
651
|
+
return true
|
|
652
|
+
}),
|
|
653
|
+
element =>
|
|
654
|
+
[
|
|
655
|
+
'password',
|
|
656
|
+
'confirmPassword',
|
|
657
|
+
'password-info',
|
|
658
|
+
].includes(element.name) &&
|
|
659
|
+
isLoggedIn ? null : (
|
|
660
|
+
<React.Fragment key={element.uniqueId}>
|
|
661
|
+
<div className={element.className}>
|
|
662
|
+
{element.component ? (
|
|
663
|
+
element.component
|
|
664
|
+
) : (
|
|
665
|
+
<Field
|
|
666
|
+
name={element.name}
|
|
667
|
+
label={element.name === 'phone'
|
|
668
|
+
? `${element.label}${flagRequirePhone ? '' : ' (optional)'} `
|
|
669
|
+
: element.label}
|
|
670
|
+
type={element.type}
|
|
671
|
+
validate={getValidateFunctions(
|
|
672
|
+
element,
|
|
673
|
+
states,
|
|
674
|
+
props.values
|
|
675
|
+
)}
|
|
676
|
+
setFieldValue={props.setFieldValue}
|
|
677
|
+
onBlur={props.handleBlur}
|
|
678
|
+
component={
|
|
679
|
+
element.type === 'checkbox'
|
|
680
|
+
? CheckboxField
|
|
681
|
+
: element.type === 'select'
|
|
682
|
+
? SelectField
|
|
683
|
+
: element.type === 'phone'
|
|
684
|
+
? FormikPhoneNumberField
|
|
685
|
+
: element.type === 'date'
|
|
686
|
+
? DatePickerField
|
|
687
|
+
: CustomField
|
|
688
|
+
}
|
|
689
|
+
selectOptions={
|
|
690
|
+
element.name === 'country'
|
|
691
|
+
? countries
|
|
692
|
+
: element.name === 'state'
|
|
693
|
+
? states
|
|
694
|
+
: []
|
|
695
|
+
}
|
|
696
|
+
theme={theme}
|
|
697
|
+
/>
|
|
698
|
+
)}
|
|
699
|
+
</div>
|
|
700
|
+
</React.Fragment>
|
|
701
|
+
)
|
|
702
|
+
)}
|
|
703
|
+
</div>
|
|
704
|
+
</React.Fragment>
|
|
705
|
+
)
|
|
706
|
+
})}
|
|
707
|
+
</React.Fragment>
|
|
708
|
+
)
|
|
709
|
+
})}
|
|
710
|
+
{!_isEmpty(ticketHoldersFields.fields) && (
|
|
711
|
+
<div className="ticket-holders-fields">
|
|
712
|
+
<p>{ticketHoldersFields.label}</p>
|
|
713
|
+
{_map(ticketsQuantity, (_item, index) => (
|
|
714
|
+
<div key={_item}>
|
|
715
|
+
<h5>Ticket {index + 1}</h5>
|
|
716
|
+
{_map(ticketHoldersFields.fields, group => {
|
|
717
|
+
const { groupClassname, groupItems } = group
|
|
718
|
+
return (
|
|
719
|
+
<div key={group.id}>
|
|
720
|
+
<div className={groupClassname}>
|
|
721
|
+
{_map(groupItems, element => (
|
|
722
|
+
<div
|
|
723
|
+
className={element.className}
|
|
724
|
+
key={element.name}
|
|
725
|
+
>
|
|
726
|
+
<Field
|
|
727
|
+
name={`${element.name}-${index}`}
|
|
728
|
+
label={element.label}
|
|
729
|
+
type={element.type}
|
|
730
|
+
required={true}
|
|
731
|
+
component={
|
|
732
|
+
element.type === 'checkbox'
|
|
733
|
+
? CheckboxField
|
|
734
|
+
: CustomField
|
|
735
|
+
}
|
|
736
|
+
validate={combineValidators(
|
|
737
|
+
element.required
|
|
738
|
+
? requiredValidator
|
|
739
|
+
: () => {},
|
|
740
|
+
element.onValidate
|
|
741
|
+
? element.onValidate
|
|
742
|
+
: () => {}
|
|
743
|
+
)}
|
|
744
|
+
/>
|
|
745
|
+
</div>
|
|
746
|
+
))}
|
|
747
|
+
</div>
|
|
748
|
+
</div>
|
|
749
|
+
)
|
|
750
|
+
})}
|
|
751
|
+
</div>
|
|
752
|
+
))}
|
|
753
|
+
</div>
|
|
754
|
+
)}
|
|
755
|
+
<div className="button-container">
|
|
756
|
+
<Button
|
|
757
|
+
type="submit"
|
|
758
|
+
variant="contained"
|
|
759
|
+
className="login-register-button"
|
|
760
|
+
disabled={props.isSubmitting}
|
|
761
|
+
>
|
|
762
|
+
{props.isSubmitting ? (
|
|
763
|
+
<CircularProgress size={26} />
|
|
764
|
+
) : (
|
|
765
|
+
buttonName
|
|
766
|
+
)}
|
|
767
|
+
</Button>
|
|
768
|
+
</div>
|
|
769
|
+
</div>
|
|
770
|
+
</Form>
|
|
771
|
+
)}
|
|
772
|
+
</Formik>
|
|
773
|
+
{showModalLogin && (
|
|
774
|
+
<LoginModal
|
|
775
|
+
onClose={() => {
|
|
776
|
+
setShowModalLogin(false)
|
|
777
|
+
}}
|
|
778
|
+
onLogin={() => {
|
|
779
|
+
setShowModalLogin(false)
|
|
780
|
+
setUserExpired(false)
|
|
781
|
+
onLoginSuccess()
|
|
782
|
+
}}
|
|
783
|
+
alreadyHasUser={alreadyHasUser}
|
|
784
|
+
userExpired={userExpired}
|
|
785
|
+
onAuthorizeSuccess={onAuthorizeSuccess}
|
|
786
|
+
onAuthorizeError={onAuthorizeError}
|
|
787
|
+
onGetProfileDataSuccess={(data: any) => {
|
|
788
|
+
fetchCart()
|
|
789
|
+
onGetProfileDataSuccess(data)
|
|
790
|
+
}}
|
|
791
|
+
onGetProfileDataError={onGetProfileDataError}
|
|
792
|
+
/>
|
|
793
|
+
)}
|
|
794
|
+
{showModalRegister && (
|
|
795
|
+
<RegisterModal
|
|
796
|
+
onClose={() => {
|
|
797
|
+
setShowModalRegister(false)
|
|
798
|
+
}}
|
|
799
|
+
onRegister={() => {
|
|
800
|
+
setShowModalRegister(false)
|
|
801
|
+
}}
|
|
802
|
+
onGetProfileDataSuccess={(data: any) => {
|
|
803
|
+
fetchCart()
|
|
804
|
+
onGetProfileDataSuccess(data)
|
|
805
|
+
}}
|
|
806
|
+
onGetProfileDataError={onGetProfileDataError}
|
|
807
|
+
/>
|
|
808
|
+
)}
|
|
809
|
+
</ThemeProvider>
|
|
810
|
+
)
|
|
811
|
+
}
|