tf-checkout-react 1.4.24 → 1.4.25
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/auth.d.ts +5 -0
- package/dist/api/cart.d.ts +2 -0
- package/dist/api/checkout.d.ts +1 -0
- package/dist/api/common.d.ts +10 -0
- package/dist/api/index.d.ts +10 -31
- package/dist/api/interceptors.d.ts +1 -0
- package/dist/api/orders.d.ts +2 -0
- package/dist/api/payment.d.ts +5 -0
- package/dist/api/publicRequest.d.ts +10 -0
- package/dist/api/resale.d.ts +5 -0
- package/dist/components/billing-info-container/utils.d.ts +0 -28
- package/dist/components/common/CheckboxField.d.ts +1 -1
- package/dist/components/confirmationContainer/index.d.ts +7 -2
- package/dist/components/loginForm/index.d.ts +6 -22
- package/dist/components/loginModal/index.d.ts +0 -28
- package/dist/components/seatMapContainer/addToCart.d.ts +2 -2
- package/dist/components/seatMapContainer/utils.d.ts +1 -9
- package/dist/components/stripePayment/index.d.ts +1 -1
- package/dist/components/ticketsContainer/index.d.ts +2 -2
- package/dist/components/waitingList/index.d.ts +1 -1
- package/dist/tf-checkout-react.cjs.development.js +1076 -694
- 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 +1076 -694
- package/dist/tf-checkout-react.esm.js.map +1 -1
- package/dist/types/order-data.d.ts +5 -5
- package/dist/utils/auth.d.ts +5 -5
- package/dist/utils/setConfigs.d.ts +0 -12
- package/package.json +1 -1
- package/src/api/auth.ts +44 -0
- package/src/api/cart.ts +28 -0
- package/src/api/checkout.ts +30 -0
- package/src/api/common.ts +129 -0
- package/src/api/guestTicketDelegation.ts +1 -1
- package/src/api/index.ts +40 -346
- package/src/api/interceptors.ts +104 -0
- package/src/api/orders.ts +30 -0
- package/src/api/payment.ts +77 -0
- package/src/api/publicRequest.ts +40 -0
- package/src/api/resale.ts +28 -0
- package/src/components/addonsContainer/adapters/index.tsx +2 -4
- package/src/components/addonsContainer/index.tsx +23 -57
- package/src/components/billing-info-container/index.tsx +144 -214
- package/src/components/billing-info-container/utils.ts +9 -59
- package/src/components/common/CheckboxField.tsx +3 -4
- package/src/components/common/CustomField.tsx +1 -5
- package/src/components/common/NativeSelectFeild/index.tsx +1 -5
- package/src/components/common/SelectField/index.tsx +1 -3
- package/src/components/confirmationContainer/index.tsx +20 -13
- package/src/components/idVerificationContainer/index.tsx +7 -19
- package/src/components/loginForm/index.tsx +28 -41
- package/src/components/loginModal/index.tsx +18 -46
- package/src/components/myTicketsContainer/index.tsx +1 -1
- package/src/components/orderDetailsContainer/index.tsx +3 -3
- package/src/components/paymentContainer/index.tsx +23 -16
- package/src/components/registerForm/index.tsx +3 -6
- package/src/components/registerModal/index.tsx +4 -14
- package/src/components/rsvpContainer/index.tsx +18 -18
- package/src/components/seatMapContainer/addToCart.ts +9 -12
- package/src/components/seatMapContainer/utils.ts +3 -8
- package/src/components/signupModal/index.tsx +9 -30
- package/src/components/stripePayment/index.tsx +1 -1
- package/src/components/ticketResale/index.tsx +7 -6
- package/src/components/ticketsContainer/TicketsSection.tsx +11 -33
- package/src/components/ticketsContainer/index.tsx +32 -56
- package/src/components/waitingList/index.tsx +18 -30
- package/src/types/api/auth.d.ts +20 -12
- package/src/types/api/axiosResponse.d.ts +6 -0
- package/src/types/api/cart.d.ts +65 -0
- package/src/types/api/checkout.d.ts +41 -0
- package/src/types/api/common.d.ts +117 -0
- package/src/types/api/orders.d.ts +100 -0
- package/src/types/api/payment.d.ts +168 -0
- package/src/types/api/ticketResale.d.ts +13 -0
- package/src/types/order-data.ts +5 -5
- package/src/utils/auth.ts +3 -3
- package/src/utils/setConfigs.ts +2 -25
- package/src/types/auth.d.ts +0 -15
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import axios, { AxiosInstance } from 'axios'
|
|
2
|
+
|
|
3
|
+
const headers: { [key: string]: string } = {
|
|
4
|
+
Accept: 'application/vnd.api+json',
|
|
5
|
+
'Content-Type': 'application/vnd.api+json',
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const isWindowDefined = typeof window !== 'undefined'
|
|
9
|
+
const authGuestToken = isWindowDefined ? localStorage.getItem('auth_guest_token') : ''
|
|
10
|
+
if (isWindowDefined && authGuestToken) {
|
|
11
|
+
headers['Authorization-Guest'] = authGuestToken
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const setAxiosHeader = (key: string, value: string | number) => {
|
|
15
|
+
headers[key] = `${value}`
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface IPublicRequest extends AxiosInstance {
|
|
19
|
+
setBaseUrl: (baseUrl: string) => void;
|
|
20
|
+
setGuestToken: (guestToken: string) => void;
|
|
21
|
+
setAccessToken: (token: string) => void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const publicRequest: IPublicRequest = axios.create({
|
|
25
|
+
baseURL: 'https://www.ticketfairy.com/api',
|
|
26
|
+
headers,
|
|
27
|
+
}) as IPublicRequest
|
|
28
|
+
|
|
29
|
+
publicRequest.setBaseUrl = (baseUrl: string) =>
|
|
30
|
+
(publicRequest.defaults.baseURL = baseUrl + '/api')
|
|
31
|
+
|
|
32
|
+
publicRequest.setGuestToken = (guestToken: string) =>
|
|
33
|
+
(publicRequest.defaults.headers.common['Authorization-Guest'] = guestToken)
|
|
34
|
+
|
|
35
|
+
publicRequest.setAccessToken = token =>
|
|
36
|
+
(publicRequest.defaults.headers.common.Authorization = token)
|
|
37
|
+
|
|
38
|
+
export const setBaseUrl = (baseUrl: string) => {
|
|
39
|
+
publicRequest.setBaseUrl(baseUrl)
|
|
40
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { AxiosRequestConfig, AxiosResponse } from 'axios'
|
|
2
|
+
|
|
3
|
+
import { publicRequest } from './publicRequest'
|
|
4
|
+
|
|
5
|
+
export const resaleTicket = async (
|
|
6
|
+
data: FormData,
|
|
7
|
+
hash: string
|
|
8
|
+
): Promise<IResaleTicketResponse> => {
|
|
9
|
+
const response: AxiosResponse<IResaleTicketResponse, AxiosRequestConfig> =
|
|
10
|
+
await publicRequest.post(`v1/ticket/${hash}/sell`, data)
|
|
11
|
+
|
|
12
|
+
return response.data
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const removeFromResale = async (
|
|
16
|
+
hash: string
|
|
17
|
+
): Promise<IRemoveFromResaleResponse> => {
|
|
18
|
+
const response: AxiosResponse<IRemoveFromResaleResponse, AxiosRequestConfig> =
|
|
19
|
+
await publicRequest.delete(`v1/ticket/${hash}/sell`)
|
|
20
|
+
|
|
21
|
+
return response.data
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const processTicket = (hash: string) =>
|
|
25
|
+
publicRequest.post(`v1/ticket/${hash}/process-invitation`)
|
|
26
|
+
|
|
27
|
+
export const declineInvitation = (hash: string) =>
|
|
28
|
+
publicRequest.post(`v1/ticket/${hash}/decline-invitation`)
|
|
@@ -31,9 +31,7 @@ export const addonsWithGroupsAdapter = (data: IAddOnsData) => {
|
|
|
31
31
|
}
|
|
32
32
|
} else {
|
|
33
33
|
const group =
|
|
34
|
-
addOnsGroups.find(
|
|
35
|
-
group => group.attributes.id === currentGroupId
|
|
36
|
-
) || {}
|
|
34
|
+
addOnsGroups.find(group => group.attributes.id === currentGroupId) || {}
|
|
37
35
|
|
|
38
36
|
addOnGroupsWithVariants.push({
|
|
39
37
|
...group.attributes,
|
|
@@ -56,7 +54,7 @@ export const addonsWithGroupsAdapter = (data: IAddOnsData) => {
|
|
|
56
54
|
}
|
|
57
55
|
|
|
58
56
|
export const cartAdapter = (cart: any) => {
|
|
59
|
-
const cartData = _get(cart, 'data.
|
|
57
|
+
const cartData = _get(cart, 'data.attributes', [])
|
|
60
58
|
const { expiresAt, cart: carts_arr } = cartData
|
|
61
59
|
const { id, quantity } = carts_arr[0] || {}
|
|
62
60
|
|
|
@@ -6,18 +6,14 @@ import _get from 'lodash/get'
|
|
|
6
6
|
import _identity from 'lodash/identity'
|
|
7
7
|
import React, { useEffect, useState } from 'react'
|
|
8
8
|
|
|
9
|
-
import {
|
|
10
|
-
getAddons,
|
|
11
|
-
getCart,
|
|
12
|
-
getCheckoutPageConfigs,
|
|
13
|
-
postOnCheckout,
|
|
14
|
-
} from '../../api'
|
|
9
|
+
import { getAddons, getCart, getCheckoutPageConfigs, postOnCheckout } from '../../api'
|
|
15
10
|
import { currencyNormalizerCreator } from '../../normalizers'
|
|
16
11
|
import { ICheckoutPageConfigs } from '../../types'
|
|
17
12
|
import {
|
|
18
13
|
createCheckoutDataBodyWithDefaultHolder,
|
|
19
14
|
createMarkup,
|
|
20
15
|
getQueryVariable,
|
|
16
|
+
isBrowser,
|
|
21
17
|
} from '../../utils'
|
|
22
18
|
import { VerificationPendingModal } from '../idVerificationContainer/VerificationPendingModal'
|
|
23
19
|
import TimerWidget from '../timerWidget'
|
|
@@ -66,13 +62,9 @@ export const AddonsContainter = ({
|
|
|
66
62
|
const eventId = getQueryVariable('event_id')
|
|
67
63
|
const [addons, setAddons] = useState<any>([])
|
|
68
64
|
const [addonsOptions, setAddonsOptions] = useState<any>({})
|
|
69
|
-
const [groupsWithSelectedVariants, setGroupsWithSelectedVariants] = useState<
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const [
|
|
73
|
-
groupsWithInitialVariantsValues,
|
|
74
|
-
setGroupsWithInitialVariantsValues,
|
|
75
|
-
] = useState<any>({})
|
|
65
|
+
const [groupsWithSelectedVariants, setGroupsWithSelectedVariants] = useState<any>({})
|
|
66
|
+
const [groupsWithInitialVariantsValues, setGroupsWithInitialVariantsValues] =
|
|
67
|
+
useState<any>({})
|
|
76
68
|
const [loading, setLoading] = useState(true)
|
|
77
69
|
const [cartExpirationTime, setCartExpirationTime] = useState(0)
|
|
78
70
|
const [pendingVerificationMessage, setPendingVerificationMessage] = useState()
|
|
@@ -125,10 +117,7 @@ export const AddonsContainter = ({
|
|
|
125
117
|
getAddonsPageInfo()
|
|
126
118
|
}, [])
|
|
127
119
|
|
|
128
|
-
const recreateGroupVariantsSelectOptions = (
|
|
129
|
-
groupId: any,
|
|
130
|
-
changedGroupd: any
|
|
131
|
-
) => {
|
|
120
|
+
const recreateGroupVariantsSelectOptions = (groupId: any, changedGroupd: any) => {
|
|
132
121
|
const { choosedVariants, limit, selectedCount } = changedGroupd
|
|
133
122
|
const remainingGroupStock = limit - selectedCount
|
|
134
123
|
const recreatedVariantsOptions: ObjectLiteral = {}
|
|
@@ -142,18 +131,14 @@ export const AddonsContainter = ({
|
|
|
142
131
|
// Formula for regenerating
|
|
143
132
|
if (
|
|
144
133
|
remainingGroupStock >=
|
|
145
|
-
groupsWithInitialVariantsValues[groupId][variantId] -
|
|
146
|
-
variantCurrSelectedValue
|
|
134
|
+
groupsWithInitialVariantsValues[groupId][variantId] - variantCurrSelectedValue
|
|
147
135
|
) {
|
|
148
136
|
allowedOptionCount = groupsWithInitialVariantsValues[groupId][variantId]
|
|
149
137
|
} else {
|
|
150
138
|
allowedOptionCount = remainingGroupStock + variantCurrSelectedValue
|
|
151
139
|
}
|
|
152
140
|
|
|
153
|
-
recreatedVariantsOptions[variantId] = generateSelectOptions(
|
|
154
|
-
0,
|
|
155
|
-
allowedOptionCount
|
|
156
|
-
)
|
|
141
|
+
recreatedVariantsOptions[variantId] = generateSelectOptions(0, allowedOptionCount)
|
|
157
142
|
}
|
|
158
143
|
|
|
159
144
|
setAddonsOptions((prevState: any) =>
|
|
@@ -170,9 +155,7 @@ export const AddonsContainter = ({
|
|
|
170
155
|
const currSelectedVariantId = id
|
|
171
156
|
const currSelectedVariantCount = Number(value)
|
|
172
157
|
const currSelectedVariantPrevCount =
|
|
173
|
-
groupsWithSelectedVariants[currGroupId].choosedVariants[
|
|
174
|
-
currSelectedVariantId
|
|
175
|
-
]
|
|
158
|
+
groupsWithSelectedVariants[currGroupId].choosedVariants[currSelectedVariantId]
|
|
176
159
|
|
|
177
160
|
const currSelectedGroupCount =
|
|
178
161
|
changeableGroup.selectedCount +
|
|
@@ -206,7 +189,6 @@ export const AddonsContainter = ({
|
|
|
206
189
|
const pageConfigsData: ICheckoutPageConfigs =
|
|
207
190
|
_get(pageConfigsDataResponse, 'data.attributes') || {}
|
|
208
191
|
|
|
209
|
-
const isWindowDefined = typeof window !== 'undefined'
|
|
210
192
|
const skipBillingPage = pageConfigsData.skip_billing_page ?? false
|
|
211
193
|
const nameIsRequired = pageConfigsData.names_required ?? false
|
|
212
194
|
const ageIsRequired = pageConfigsData.age_required ?? false
|
|
@@ -220,9 +202,7 @@ export const AddonsContainter = ({
|
|
|
220
202
|
|
|
221
203
|
if (skipBillingPage && enableBillingInfoAutoCreate) {
|
|
222
204
|
const ticketsQuantity = window.localStorage.getItem('quantity')
|
|
223
|
-
const userData = JSON.parse(
|
|
224
|
-
window.localStorage.getItem('user_data') || '{}'
|
|
225
|
-
)
|
|
205
|
+
const userData = JSON.parse(window.localStorage.getItem('user_data') || '{}')
|
|
226
206
|
|
|
227
207
|
const checkoutBody = createCheckoutDataBodyWithDefaultHolder(
|
|
228
208
|
Number(ticketsQuantity) || 0,
|
|
@@ -237,13 +217,13 @@ export const AddonsContainter = ({
|
|
|
237
217
|
...(!skipAddonPage && { add_ons: values }),
|
|
238
218
|
},
|
|
239
219
|
})
|
|
240
|
-
const hash =
|
|
241
|
-
const total =
|
|
220
|
+
const hash = checkoutResponse?.data?.attributes?.hash || ''
|
|
221
|
+
const total = checkoutResponse?.data?.attributes?.total || ''
|
|
242
222
|
|
|
243
|
-
|
|
244
|
-
|
|
223
|
+
isBrowser && window.localStorage.removeItem('quantity')
|
|
224
|
+
isBrowser && window.localStorage.removeItem('add_ons')
|
|
245
225
|
|
|
246
|
-
onPostCheckoutSuccess(checkoutResponse?.data)
|
|
226
|
+
onPostCheckoutSuccess(checkoutResponse?.data.attributes)
|
|
247
227
|
onConfirmSelectionSuccess({
|
|
248
228
|
skip_billing_page: skipBillingPage,
|
|
249
229
|
names_required: nameIsRequired,
|
|
@@ -266,7 +246,7 @@ export const AddonsContainter = ({
|
|
|
266
246
|
}
|
|
267
247
|
}
|
|
268
248
|
} else {
|
|
269
|
-
if (
|
|
249
|
+
if (isBrowser) {
|
|
270
250
|
if (!skipAddonPage) {
|
|
271
251
|
window.localStorage.setItem('add_ons', JSON.stringify(values))
|
|
272
252
|
}
|
|
@@ -363,41 +343,29 @@ export const AddonsContainter = ({
|
|
|
363
343
|
>
|
|
364
344
|
<div className={`${classNamePrefix}_product_images`}>
|
|
365
345
|
{addon.imageUrl && (
|
|
366
|
-
<div
|
|
367
|
-
className={`${classNamePrefix}_product_image_block`}
|
|
368
|
-
>
|
|
346
|
+
<div className={`${classNamePrefix}_product_image_block`}>
|
|
369
347
|
<img src={addon.imageUrl} alt="No Data" />
|
|
370
348
|
</div>
|
|
371
349
|
)}
|
|
372
350
|
</div>
|
|
373
|
-
<div
|
|
374
|
-
className={`${classNamePrefix}_product_info_block`}
|
|
375
|
-
>
|
|
351
|
+
<div className={`${classNamePrefix}_product_info_block`}>
|
|
376
352
|
<div className={`${classNamePrefix}_product_title`}>
|
|
377
353
|
{addon.name}
|
|
378
354
|
</div>
|
|
379
355
|
<div className={`${classNamePrefix}_product_price`}>
|
|
380
356
|
{addonNormalizedPrice}
|
|
381
357
|
{!isAddonFree && (
|
|
382
|
-
<span
|
|
383
|
-
|
|
384
|
-
>
|
|
385
|
-
{addon.feeIncluded
|
|
386
|
-
? '(incl. Fees)'
|
|
387
|
-
: '(excl. Fees)'}
|
|
358
|
+
<span className={`${classNamePrefix}_product_fee`}>
|
|
359
|
+
{addon.feeIncluded ? '(incl. Fees)' : '(excl. Fees)'}
|
|
388
360
|
</span>
|
|
389
361
|
)}
|
|
390
362
|
</div>
|
|
391
363
|
</div>
|
|
392
364
|
<div
|
|
393
365
|
className={`${classNamePrefix}_product_desc`}
|
|
394
|
-
dangerouslySetInnerHTML={createMarkup(
|
|
395
|
-
addon.description
|
|
396
|
-
)}
|
|
366
|
+
dangerouslySetInnerHTML={createMarkup(addon.description)}
|
|
397
367
|
/>
|
|
398
|
-
<div
|
|
399
|
-
className={`${classNamePrefix}_product_select_container`}
|
|
400
|
-
>
|
|
368
|
+
<div className={`${classNamePrefix}_product_select_container`}>
|
|
401
369
|
{addon.variants ? (
|
|
402
370
|
addon.variants.map((variant: any) => (
|
|
403
371
|
// Group Variants
|
|
@@ -430,9 +398,7 @@ export const AddonsContainter = ({
|
|
|
430
398
|
<button
|
|
431
399
|
type="submit"
|
|
432
400
|
className={`${
|
|
433
|
-
isConfirmDisabled
|
|
434
|
-
? `${classNamePrefix}_is_disabled`
|
|
435
|
-
: ''
|
|
401
|
+
isConfirmDisabled ? `${classNamePrefix}_is_disabled` : ''
|
|
436
402
|
} ${classNamePrefix}_submit_button`}
|
|
437
403
|
disabled={isConfirmDisabled}
|
|
438
404
|
>
|