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,430 +1,464 @@
|
|
|
1
|
-
import React, { useState, useEffect, useRef } from 'react'
|
|
2
|
-
import axios, { AxiosError } from 'axios'
|
|
3
|
-
import { Loader } from '../common/index'
|
|
4
|
-
import './style.css'
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
getTickets,
|
|
8
|
-
getEvent,
|
|
9
|
-
addToCart,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import {
|
|
23
|
-
import { LoginModal } from '../loginModal'
|
|
24
|
-
import Countdown from '../countdown'
|
|
25
|
-
import { createCheckoutDataBodyWithDefaultHolder, getQueryVariable } from '../../utils'
|
|
26
|
-
import { ThemeProvider } from '@mui/private-theming'
|
|
27
|
-
import { createTheme, ThemeOptions } from '@mui/material'
|
|
28
|
-
import { CSSProperties } from '@mui/styles'
|
|
29
|
-
import { ReferralLogic } from './ReferralLogic'
|
|
30
|
-
|
|
31
|
-
interface CartSuccess {
|
|
32
|
-
skip_billing_page: boolean;
|
|
33
|
-
names_required: boolean;
|
|
34
|
-
age_required: boolean;
|
|
35
|
-
phone_required: boolean;
|
|
36
|
-
event_id: string;
|
|
37
|
-
hash?: string;
|
|
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
|
-
const [
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
const
|
|
104
|
-
const [
|
|
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
|
-
useEffect(() => {
|
|
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
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
1
|
+
import React, { useState, useEffect, useRef, ReactNode } from 'react'
|
|
2
|
+
import axios, { AxiosError } from 'axios'
|
|
3
|
+
import { Loader } from '../common/index'
|
|
4
|
+
import './style.css'
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
getTickets,
|
|
8
|
+
getEvent,
|
|
9
|
+
addToCart,
|
|
10
|
+
postOnCheckout,
|
|
11
|
+
} from '../../api'
|
|
12
|
+
import _get from 'lodash/get'
|
|
13
|
+
import _some from 'lodash/some'
|
|
14
|
+
import _every from 'lodash/every'
|
|
15
|
+
import _find from 'lodash/find'
|
|
16
|
+
import _isEmpty from 'lodash/isEmpty'
|
|
17
|
+
import Button from 'react-bootstrap/Button'
|
|
18
|
+
import jwt_decode from 'jwt-decode'
|
|
19
|
+
import { TicketsSection } from './TicketsSection'
|
|
20
|
+
import WaitingList from '../waitingList'
|
|
21
|
+
import { PromoCodeSection } from './PromoCodeSection'
|
|
22
|
+
import { AccessCodeSection } from './AccessCodeSection'
|
|
23
|
+
import { LoginModal } from '../loginModal'
|
|
24
|
+
import Countdown from '../countdown'
|
|
25
|
+
import { createCheckoutDataBodyWithDefaultHolder, getQueryVariable } from '../../utils'
|
|
26
|
+
import { ThemeProvider } from '@mui/private-theming'
|
|
27
|
+
import { createTheme, ThemeOptions } from '@mui/material'
|
|
28
|
+
import { CSSProperties } from '@mui/styles'
|
|
29
|
+
import { ReferralLogic } from './ReferralLogic'
|
|
30
|
+
|
|
31
|
+
interface CartSuccess {
|
|
32
|
+
skip_billing_page: boolean;
|
|
33
|
+
names_required: boolean;
|
|
34
|
+
age_required: boolean;
|
|
35
|
+
phone_required: boolean;
|
|
36
|
+
event_id: string;
|
|
37
|
+
hash?: string;
|
|
38
|
+
total?: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface IGetTickets {
|
|
42
|
+
eventId: number;
|
|
43
|
+
onAddToCartSuccess: (response: CartSuccess) => void;
|
|
44
|
+
getTicketsLabel?: string;
|
|
45
|
+
contentStyle?: React.CSSProperties;
|
|
46
|
+
onAddToCartError: (e: AxiosError) => void;
|
|
47
|
+
onGetTicketsSuccess: (response: any) => void;
|
|
48
|
+
onGetTicketsError: (e: AxiosError) => void;
|
|
49
|
+
onLoginSuccess: () => void;
|
|
50
|
+
|
|
51
|
+
theme?: 'light' | 'dark';
|
|
52
|
+
queryPromoCode?: string;
|
|
53
|
+
isPromotionsEnabled?: boolean;
|
|
54
|
+
themeOptions?: ThemeOptions & { input?: CSSProperties; checkbox?: CSSProperties }
|
|
55
|
+
isAccessCodeEnabled?: boolean;
|
|
56
|
+
hideSessionButtons?: boolean;
|
|
57
|
+
hideWaitingList?: boolean;
|
|
58
|
+
isButtonScrollable?: boolean;
|
|
59
|
+
sortBySoldOut?: boolean;
|
|
60
|
+
disableCountdownLeadingZero?: boolean;
|
|
61
|
+
isLoggedIn?: boolean;
|
|
62
|
+
actionsSectionComponent?: any;
|
|
63
|
+
ticketsHeaderComponent?: ReactNode,
|
|
64
|
+
hideTicketsHeader?: boolean,
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface ITicket {
|
|
68
|
+
id: string | number;
|
|
69
|
+
[key: string]: string | number;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface ISelectedTickets {
|
|
73
|
+
[key: string]: string | number;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export const TicketsContainer = ({
|
|
77
|
+
onLoginSuccess,
|
|
78
|
+
getTicketsLabel,
|
|
79
|
+
eventId,
|
|
80
|
+
onAddToCartSuccess,
|
|
81
|
+
contentStyle = {},
|
|
82
|
+
onAddToCartError = () => {},
|
|
83
|
+
onGetTicketsSuccess = () => {},
|
|
84
|
+
onGetTicketsError = () => {},
|
|
85
|
+
theme = 'light',
|
|
86
|
+
queryPromoCode = '',
|
|
87
|
+
isPromotionsEnabled = true,
|
|
88
|
+
themeOptions,
|
|
89
|
+
isAccessCodeEnabled = false,
|
|
90
|
+
hideSessionButtons = false,
|
|
91
|
+
hideWaitingList = false,
|
|
92
|
+
isButtonScrollable = false,
|
|
93
|
+
sortBySoldOut = false,
|
|
94
|
+
disableCountdownLeadingZero = false,
|
|
95
|
+
isLoggedIn = false,
|
|
96
|
+
actionsSectionComponent : ActionsSectionComponent,
|
|
97
|
+
ticketsHeaderComponent,
|
|
98
|
+
hideTicketsHeader = false
|
|
99
|
+
}: IGetTickets) => {
|
|
100
|
+
const [selectedTickets, setSelectedTickets] = useState(
|
|
101
|
+
{} as ISelectedTickets
|
|
102
|
+
)
|
|
103
|
+
const isWindowDefined = typeof window !== 'undefined'
|
|
104
|
+
const [isLogged, setIsLogged] = useState(
|
|
105
|
+
isWindowDefined ? !!window.localStorage.getItem('access_token') : false
|
|
106
|
+
)
|
|
107
|
+
const [showLoginModal, setShowLoginModal] = useState(false)
|
|
108
|
+
const [tickets, setTickets] = useState([] as ITicket[])
|
|
109
|
+
const [event, setEvent] = useState<any>(null)
|
|
110
|
+
const [showWaitingList, setShowWaitingList] = useState(false)
|
|
111
|
+
const [isLoading, setIsLoading] = useState(true)
|
|
112
|
+
const [codeIsLoading, setCodeIsLoading] = useState(false)
|
|
113
|
+
const [handleBookIsLoading, setHandleBookIsLoading] = useState(false)
|
|
114
|
+
const [code, setCode] = useState(getQueryVariable('r') || queryPromoCode)
|
|
115
|
+
const [showPromoInput, setShowPromoInput] = useState(false)
|
|
116
|
+
const [codeIsApplied, setCodeIsApplied] = useState(false)
|
|
117
|
+
const [showAccessCodeSection, setShowAccessCodeSection] = useState(isAccessCodeEnabled)
|
|
118
|
+
const [showPromoCodeSection, setShowPromoCodeSection] = useState(isPromotionsEnabled)
|
|
119
|
+
|
|
120
|
+
const ticketsContainerRef = useRef<HTMLDivElement>(null)
|
|
121
|
+
|
|
122
|
+
useEffect(() => {
|
|
123
|
+
if (typeof window !== 'undefined') {
|
|
124
|
+
const access_token = window.localStorage.getItem('access_token')
|
|
125
|
+
if (access_token) {
|
|
126
|
+
const decoded = jwt_decode<{ exp: number }>(access_token)
|
|
127
|
+
if (decoded && decoded.exp < Date.now() / 1000) {
|
|
128
|
+
window.localStorage.removeItem('access_token')
|
|
129
|
+
window.localStorage.removeItem('user_data')
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}, [])
|
|
134
|
+
|
|
135
|
+
useEffect(() => {
|
|
136
|
+
!!eventId && getTicketsApi()
|
|
137
|
+
}, [eventId])
|
|
138
|
+
|
|
139
|
+
const handleLogout = () => {
|
|
140
|
+
if (isWindowDefined) {
|
|
141
|
+
window.localStorage.removeItem('access_token')
|
|
142
|
+
window.localStorage.removeItem('user_data')
|
|
143
|
+
setIsLogged(false)
|
|
144
|
+
const event = new window.CustomEvent('tf-logout')
|
|
145
|
+
window.document.dispatchEvent(event)
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
useEffect(() => {
|
|
150
|
+
try {
|
|
151
|
+
if (typeof window !== 'undefined') {
|
|
152
|
+
const userData = window.localStorage.getItem('user_data')
|
|
153
|
+
? JSON.parse(window.localStorage.getItem('user_data') || '{}')
|
|
154
|
+
: {}
|
|
155
|
+
if (userData.country === '') {
|
|
156
|
+
handleLogout()
|
|
157
|
+
window.open("https://www.ticketfairy.com/account/change_information?need_country=true");
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
} catch(e) {}
|
|
161
|
+
}, [])
|
|
162
|
+
|
|
163
|
+
const handleExternalLogin = () => {
|
|
164
|
+
setIsLogged(true)
|
|
165
|
+
}
|
|
166
|
+
const handleOnClose = () => {
|
|
167
|
+
setShowLoginModal(false)
|
|
168
|
+
}
|
|
169
|
+
const handleOnLogin = () => {
|
|
170
|
+
setShowLoginModal(false)
|
|
171
|
+
setIsLogged(true)
|
|
172
|
+
if (onLoginSuccess) {
|
|
173
|
+
onLoginSuccess()
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
async function getTicketsApi(isUpdateingCode?: boolean) {
|
|
178
|
+
try {
|
|
179
|
+
isUpdateingCode ? setCodeIsLoading(true) : setIsLoading(true)
|
|
180
|
+
const response = await getTickets(eventId, code)
|
|
181
|
+
const eventResponse = await getEvent(eventId)
|
|
182
|
+
if (response.data.success) {
|
|
183
|
+
const attributes = _get(response, 'data.data.attributes')
|
|
184
|
+
setCodeIsApplied(attributes.ValidPromoCode)
|
|
185
|
+
setTickets(_get(attributes, 'tickets'))
|
|
186
|
+
setShowWaitingList(attributes.showWaitingList)
|
|
187
|
+
onGetTicketsSuccess(response.data)
|
|
188
|
+
setCode('')
|
|
189
|
+
setShowAccessCodeSection(attributes.is_access_code)
|
|
190
|
+
setShowPromoCodeSection(attributes.isPromotionsEnabled)
|
|
191
|
+
}
|
|
192
|
+
if (eventResponse.data.success) {
|
|
193
|
+
const event = _get(eventResponse, 'data.data.attributes')
|
|
194
|
+
setEvent(event)
|
|
195
|
+
}
|
|
196
|
+
} catch (e) {
|
|
197
|
+
if (axios.isAxiosError(e)) {
|
|
198
|
+
onGetTicketsError(e)
|
|
199
|
+
}
|
|
200
|
+
} finally {
|
|
201
|
+
setIsLoading(false)
|
|
202
|
+
setCodeIsLoading(false)
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
const handleTicketSelect = (key: string, value: number | string) => {
|
|
207
|
+
setSelectedTickets(prevState => {
|
|
208
|
+
if (Object.keys(prevState)[0] !== key && !value) {
|
|
209
|
+
return prevState
|
|
210
|
+
}
|
|
211
|
+
return {
|
|
212
|
+
[key]: value,
|
|
213
|
+
}
|
|
214
|
+
})
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const handleOrdersClick = () => {
|
|
218
|
+
if (isWindowDefined) {
|
|
219
|
+
window.location.href = '/orders'
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const handleBook = async () => {
|
|
224
|
+
setHandleBookIsLoading(true)
|
|
225
|
+
const ticket =
|
|
226
|
+
_find(tickets, item => selectedTickets[item.id] > 0) || ({} as ITicket)
|
|
227
|
+
const optionName = _get(ticket, 'optionName')
|
|
228
|
+
const ticketId = _get(ticket, 'id')
|
|
229
|
+
const ticketQuantity = +selectedTickets[ticket.id]
|
|
230
|
+
|
|
231
|
+
const data = {
|
|
232
|
+
attributes: {
|
|
233
|
+
alternative_view_id: null,
|
|
234
|
+
product_cart_quantity: ticketQuantity,
|
|
235
|
+
product_options: {
|
|
236
|
+
[optionName]: ticketId,
|
|
237
|
+
},
|
|
238
|
+
product_id: eventId,
|
|
239
|
+
ticket_types: {
|
|
240
|
+
[ticketId]: {
|
|
241
|
+
product_options: {
|
|
242
|
+
[optionName]: ticketId,
|
|
243
|
+
ticket_price: ticket.price,
|
|
244
|
+
},
|
|
245
|
+
quantity: ticketQuantity,
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
try {
|
|
252
|
+
const result = await addToCart(eventId, data)
|
|
253
|
+
if (result.status === 200) {
|
|
254
|
+
|
|
255
|
+
const skipBillingPage =
|
|
256
|
+
result?.data?.data?.attributes?.skip_billing_page ?? false
|
|
257
|
+
const nameIsRequired =
|
|
258
|
+
result?.data?.data?.attributes?.names_required ?? false
|
|
259
|
+
const ageIsRequired =
|
|
260
|
+
result?.data?.data?.attributes?.age_required ?? false
|
|
261
|
+
const phoneIsRequired =
|
|
262
|
+
result?.data?.data?.attributes?.phone_required ?? false
|
|
263
|
+
|
|
264
|
+
let hash = ''
|
|
265
|
+
let total = ''
|
|
266
|
+
|
|
267
|
+
if (skipBillingPage) {
|
|
268
|
+
// Get user data for checkout data
|
|
269
|
+
const isWindowDefined = typeof window !== 'undefined'
|
|
270
|
+
const userData =
|
|
271
|
+
isWindowDefined && window.localStorage.getItem('user_data')
|
|
272
|
+
? JSON.parse(window.localStorage.getItem('user_data') || '')
|
|
273
|
+
: {}
|
|
274
|
+
|
|
275
|
+
const access_token =
|
|
276
|
+
isWindowDefined && window.localStorage.getItem('access_token')
|
|
277
|
+
? window.localStorage.getItem('access_token') || ''
|
|
278
|
+
: ''
|
|
279
|
+
|
|
280
|
+
const checkoutBody = createCheckoutDataBodyWithDefaultHolder(
|
|
281
|
+
ticketQuantity,
|
|
282
|
+
userData
|
|
283
|
+
)
|
|
284
|
+
|
|
285
|
+
const checkoutResult = await postOnCheckout(
|
|
286
|
+
checkoutBody,
|
|
287
|
+
access_token
|
|
288
|
+
)
|
|
289
|
+
|
|
290
|
+
hash = _get(checkoutResult, 'data.data.attributes.hash')
|
|
291
|
+
total = _get(checkoutResult, 'data.data.attributes.total')
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
onAddToCartSuccess({
|
|
295
|
+
skip_billing_page: skipBillingPage,
|
|
296
|
+
names_required: nameIsRequired,
|
|
297
|
+
phone_required: phoneIsRequired,
|
|
298
|
+
age_required: ageIsRequired,
|
|
299
|
+
event_id: String(eventId),
|
|
300
|
+
hash,
|
|
301
|
+
total
|
|
302
|
+
})
|
|
303
|
+
}
|
|
304
|
+
} catch (e) {
|
|
305
|
+
if (axios.isAxiosError(e)) {
|
|
306
|
+
onAddToCartError(e)
|
|
307
|
+
}
|
|
308
|
+
} finally {
|
|
309
|
+
setHandleBookIsLoading(false)
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
const updateTickets = (isUpdateingCode?: boolean) => {
|
|
314
|
+
getTicketsApi(isUpdateingCode)
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
const isTicketOnSale = _some(
|
|
318
|
+
tickets,
|
|
319
|
+
item => (item.salesStarted && !item.salesEnded && !item.soldOut)
|
|
320
|
+
)
|
|
321
|
+
|
|
322
|
+
const themeMui = createTheme(themeOptions)
|
|
323
|
+
|
|
324
|
+
useEffect(() => {
|
|
325
|
+
isWindowDefined &&
|
|
326
|
+
window.document.addEventListener('custom-logout', handleLogout)
|
|
327
|
+
return () => {
|
|
328
|
+
isWindowDefined &&
|
|
329
|
+
window.document.removeEventListener('custom-logout', handleLogout)
|
|
330
|
+
}
|
|
331
|
+
}, [])
|
|
332
|
+
|
|
333
|
+
useEffect(() => {
|
|
334
|
+
isWindowDefined &&
|
|
335
|
+
window.document.addEventListener('custom-login', handleExternalLogin)
|
|
336
|
+
return () => {
|
|
337
|
+
isWindowDefined &&
|
|
338
|
+
window.document.removeEventListener(
|
|
339
|
+
'custom-login',
|
|
340
|
+
handleExternalLogin
|
|
341
|
+
)
|
|
342
|
+
}
|
|
343
|
+
}, [])
|
|
344
|
+
|
|
345
|
+
const handleGetTicketClick = () => {
|
|
346
|
+
if (!handleBookIsLoading && !_isEmpty(selectedTickets) && Object.values(selectedTickets)[0] > 0) {
|
|
347
|
+
handleBook()
|
|
348
|
+
} else {
|
|
349
|
+
if (isButtonScrollable && ticketsContainerRef && ticketsContainerRef.current) {
|
|
350
|
+
ticketsContainerRef.current.scrollIntoView({ behavior: 'smooth', block: 'center', inline: 'nearest' })
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
const bookButtonIsDisabled = handleBookIsLoading || _isEmpty(selectedTickets) || Object.values(selectedTickets)[0] === 0
|
|
356
|
+
|
|
357
|
+
const wrappedActionsSectionComponent = React.isValidElement(ActionsSectionComponent) ? React.cloneElement(ActionsSectionComponent as React.ReactElement<any>, {
|
|
358
|
+
handleGetTicketClick,
|
|
359
|
+
isTicketOnSale
|
|
360
|
+
}) : null
|
|
361
|
+
|
|
362
|
+
const externalUrl = event?.redirectUrl
|
|
363
|
+
const eventSaleIsNotStarted = !event?.salesStarted && event?.salesStart
|
|
364
|
+
|
|
365
|
+
return (
|
|
366
|
+
<ThemeProvider theme={themeMui}>
|
|
367
|
+
{!isLoading && <ReferralLogic eventId={eventId} />}
|
|
368
|
+
<div className={`get-tickets-page ${theme}`} style={contentStyle}>
|
|
369
|
+
{isLoading ? (
|
|
370
|
+
<Loader />
|
|
371
|
+
) : (
|
|
372
|
+
<div ref={ticketsContainerRef}>
|
|
373
|
+
<TicketsSection
|
|
374
|
+
ticketsList={tickets}
|
|
375
|
+
selectedTickets={selectedTickets}
|
|
376
|
+
handleTicketSelect={handleTicketSelect}
|
|
377
|
+
codeIsApplied={codeIsApplied}
|
|
378
|
+
sortBySoldOut={sortBySoldOut}
|
|
379
|
+
ticketsHeaderComponent={ticketsHeaderComponent}
|
|
380
|
+
hideTicketsHeader={hideTicketsHeader || _isEmpty(tickets)}
|
|
381
|
+
/>
|
|
382
|
+
{externalUrl ? null : event?.salesEnded ? (
|
|
383
|
+
<p className={`event-closed-message ${!isLoggedIn ? 'event-closed-on-bottom' : ''}`}>Sales for this event are closed.</p>
|
|
384
|
+
) : eventSaleIsNotStarted ? (
|
|
385
|
+
<Countdown
|
|
386
|
+
startDate={event.salesStart}
|
|
387
|
+
timezone={event.timezone}
|
|
388
|
+
title="Sales start in:"
|
|
389
|
+
message="No tickets are currently available for this event."
|
|
390
|
+
callback={updateTickets}
|
|
391
|
+
disableLeadingZero={disableCountdownLeadingZero}
|
|
392
|
+
isLoggedIn={isLoggedIn}
|
|
393
|
+
/>
|
|
394
|
+
) : null}
|
|
395
|
+
{showWaitingList && event.salesStarted && !hideWaitingList && (
|
|
396
|
+
<WaitingList tickets={tickets} eventId={eventId} />
|
|
397
|
+
)}
|
|
398
|
+
{
|
|
399
|
+
codeIsLoading ? (
|
|
400
|
+
<Loader />
|
|
401
|
+
) : showAccessCodeSection ? (
|
|
402
|
+
<AccessCodeSection
|
|
403
|
+
code={code}
|
|
404
|
+
setCode={setCode}
|
|
405
|
+
updateTickets={updateTickets}
|
|
406
|
+
/>
|
|
407
|
+
) : showPromoCodeSection ? (
|
|
408
|
+
<PromoCodeSection
|
|
409
|
+
code={code}
|
|
410
|
+
codeIsApplied={codeIsApplied}
|
|
411
|
+
showPromoInput={showPromoInput}
|
|
412
|
+
setShowPromoInput={setShowPromoInput}
|
|
413
|
+
setCode={setCode}
|
|
414
|
+
updateTickets={updateTickets}
|
|
415
|
+
/>
|
|
416
|
+
) : null
|
|
417
|
+
}
|
|
418
|
+
{wrappedActionsSectionComponent}
|
|
419
|
+
{!wrappedActionsSectionComponent && !eventSaleIsNotStarted && isTicketOnSale && !event?.salesEnded && !externalUrl && (
|
|
420
|
+
<Button
|
|
421
|
+
aria-hidden={true}
|
|
422
|
+
className={`book-button
|
|
423
|
+
${bookButtonIsDisabled ? 'disabled' : ''}
|
|
424
|
+
${isButtonScrollable ? 'is-scrollable' : ''}
|
|
425
|
+
${!isLoggedIn ? 'on-bottom' : ''}
|
|
426
|
+
`}
|
|
427
|
+
onClick={handleGetTicketClick}
|
|
428
|
+
>
|
|
429
|
+
{getTicketsLabel || 'GET TICKETS'}
|
|
430
|
+
</Button>
|
|
431
|
+
)}
|
|
432
|
+
{isLogged && !hideSessionButtons ? (
|
|
433
|
+
<div className="session-wrapper">
|
|
434
|
+
<span className="session-container">
|
|
435
|
+
<Button
|
|
436
|
+
variant="outline-light"
|
|
437
|
+
className="session-buttons"
|
|
438
|
+
onClick={handleOrdersClick}
|
|
439
|
+
>
|
|
440
|
+
My Orders
|
|
441
|
+
</Button>
|
|
442
|
+
</span>
|
|
443
|
+
<span className="session-container">
|
|
444
|
+
<Button
|
|
445
|
+
variant="outline-light"
|
|
446
|
+
className="session-buttons"
|
|
447
|
+
onClick={handleLogout}
|
|
448
|
+
>
|
|
449
|
+
Log out
|
|
450
|
+
</Button>
|
|
451
|
+
</span>
|
|
452
|
+
</div>
|
|
453
|
+
) : (
|
|
454
|
+
''
|
|
455
|
+
)}
|
|
456
|
+
</div>
|
|
457
|
+
)}
|
|
458
|
+
{showLoginModal ? (
|
|
459
|
+
<LoginModal onClose={handleOnClose} onLogin={handleOnLogin} />
|
|
460
|
+
) : null}
|
|
461
|
+
</div>
|
|
462
|
+
</ThemeProvider>
|
|
463
|
+
)
|
|
464
|
+
}
|