tf-checkout-react 1.6.6 → 1.7.1

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.
Files changed (131) hide show
  1. package/README.md +401 -59
  2. package/dist/adapters/customFields.d.ts +1 -0
  3. package/dist/api/checkout.d.ts +2 -0
  4. package/dist/api/common.d.ts +1 -0
  5. package/dist/api/index.d.ts +2 -0
  6. package/dist/api/preRegistrationComplete.d.ts +1 -1
  7. package/dist/components/addonsContainer/AddonComponent.d.ts +6 -1
  8. package/dist/components/addonsContainer/SimpleAddonsContainer.d.ts +17 -0
  9. package/dist/components/addonsContainer/index.d.ts +6 -1
  10. package/dist/components/billing-info-container/hooks/index.d.ts +3 -0
  11. package/dist/components/billing-info-container/hooks/usePaymentContext.d.ts +5 -0
  12. package/dist/components/billing-info-container/hooks/usePaymentRedirect.d.ts +14 -0
  13. package/dist/components/billing-info-container/hooks/useStripePayment.d.ts +18 -0
  14. package/dist/components/billing-info-container/index.d.ts +13 -2
  15. package/dist/components/billing-info-container/utils.d.ts +25 -1
  16. package/dist/components/common/DatePickerField.d.ts +7 -1
  17. package/dist/components/confirmationContainer/index.d.ts +4 -1
  18. package/dist/components/countdown/index.d.ts +1 -1
  19. package/dist/components/forgotPasswordModal/index.d.ts +2 -1
  20. package/dist/components/myTicketsContainer/index.d.ts +3 -2
  21. package/dist/components/orderDetailsContainer/index.d.ts +8 -1
  22. package/dist/components/paymentContainer/OrderDetails.d.ts +9 -0
  23. package/dist/components/paymentContainer/handlePayment.d.ts +15 -0
  24. package/dist/components/paymentContainer/index.d.ts +12 -6
  25. package/dist/components/preRegistration/FieldsSection.d.ts +7 -1
  26. package/dist/components/preRegistration/PreRegistrationComplete.d.ts +6 -0
  27. package/dist/components/preRegistration/constants.d.ts +2 -2
  28. package/dist/components/preRegistration/index.d.ts +6 -0
  29. package/dist/components/resetPasswordContainer/index.d.ts +2 -2
  30. package/dist/components/ticketsContainer/InfoIcon.d.ts +5 -0
  31. package/dist/components/ticketsContainer/TicketsSection.d.ts +3 -2
  32. package/dist/components/ticketsContainer/TimeSlotsSection.d.ts +25 -0
  33. package/dist/components/ticketsContainer/index.d.ts +29 -5
  34. package/dist/components/timerWidget/index.d.ts +2 -1
  35. package/dist/constants/index.d.ts +5 -0
  36. package/dist/index.d.ts +4 -1
  37. package/dist/tf-checkout-react.cjs.development.js +11231 -9563
  38. package/dist/tf-checkout-react.cjs.development.js.map +1 -1
  39. package/dist/tf-checkout-react.cjs.production.min.js +1 -1
  40. package/dist/tf-checkout-react.cjs.production.min.js.map +1 -1
  41. package/dist/tf-checkout-react.esm.js +11194 -9529
  42. package/dist/tf-checkout-react.esm.js.map +1 -1
  43. package/dist/tf-checkout-styles.css +1 -1
  44. package/dist/types/add_on.d.ts +1 -0
  45. package/dist/types/checkoutPageConfigs.d.ts +1 -1
  46. package/dist/types/order-data.d.ts +3 -1
  47. package/dist/utils/auth.d.ts +8 -0
  48. package/dist/utils/customFields.d.ts +11 -0
  49. package/dist/utils/getDomain.d.ts +1 -1
  50. package/dist/utils/index.d.ts +1 -1
  51. package/dist/utils/setConfigs.d.ts +1 -0
  52. package/package.json +14 -8
  53. package/src/adapters/customFields.ts +7 -1
  54. package/src/api/auth.ts +2 -1
  55. package/src/api/checkout.ts +9 -4
  56. package/src/api/common.ts +49 -2
  57. package/src/api/index.ts +1 -0
  58. package/src/api/interceptors.ts +7 -23
  59. package/src/api/preRegistrationComplete.ts +1 -1
  60. package/src/api/publicRequest.ts +10 -0
  61. package/src/components/addonsContainer/AddonComponent.tsx +96 -11
  62. package/src/components/addonsContainer/SimpleAddonsContainer.tsx +420 -0
  63. package/src/components/addonsContainer/index.tsx +198 -47
  64. package/src/components/billing-info-container/hooks/index.ts +3 -0
  65. package/src/components/billing-info-container/hooks/usePaymentContext.ts +22 -0
  66. package/src/components/billing-info-container/hooks/usePaymentRedirect.ts +147 -0
  67. package/src/components/billing-info-container/hooks/useStripePayment.ts +121 -0
  68. package/src/components/billing-info-container/index.tsx +827 -406
  69. package/src/components/billing-info-container/{utils.ts → utils.tsx} +119 -0
  70. package/src/components/common/CheckboxField/index.tsx +1 -1
  71. package/src/components/common/CustomField.tsx +38 -2
  72. package/src/components/common/DatePickerField.tsx +25 -10
  73. package/src/components/common/SnackbarAlert.tsx +32 -34
  74. package/src/components/confirmationContainer/config.ts +3 -3
  75. package/src/components/confirmationContainer/index.tsx +20 -1
  76. package/src/components/confirmationContainer/social-buttons.tsx +5 -3
  77. package/src/components/confirmationContainer/style.css +9 -5
  78. package/src/components/countdown/index.tsx +22 -22
  79. package/src/components/delegationsContainer/IssueComponent.tsx +2 -1
  80. package/src/components/forgotPasswordModal/index.tsx +44 -13
  81. package/src/components/loginForm/index.tsx +1 -1
  82. package/src/components/loginModal/index.tsx +19 -27
  83. package/src/components/loginModal/style.css +3 -1
  84. package/src/components/myTicketsContainer/index.tsx +13 -9
  85. package/src/components/orderDetailsContainer/index.tsx +206 -174
  86. package/src/components/paymentContainer/OrderDetails.tsx +257 -0
  87. package/src/components/paymentContainer/handlePayment.ts +86 -0
  88. package/src/components/paymentContainer/index.tsx +299 -259
  89. package/src/components/paymentContainer/style.css +141 -0
  90. package/src/components/preRegistration/FieldsSection.tsx +8 -0
  91. package/src/components/preRegistration/PreRegistrationComplete.tsx +128 -118
  92. package/src/components/preRegistration/PreRegistrationInformations.tsx +21 -15
  93. package/src/components/preRegistration/constants.tsx +10 -4
  94. package/src/components/preRegistration/index.tsx +194 -174
  95. package/src/components/registerForm/constants.tsx +3 -1
  96. package/src/components/registerForm/index.tsx +3 -3
  97. package/src/components/registerModal/index.tsx +47 -72
  98. package/src/components/resetPasswordContainer/index.tsx +20 -14
  99. package/src/components/seatMapContainer/TicketsSection.tsx +2 -2
  100. package/src/components/signupModal/index.tsx +13 -6
  101. package/src/components/ticketResale/index.tsx +7 -0
  102. package/src/components/ticketsContainer/InfoIcon.tsx +35 -0
  103. package/src/components/ticketsContainer/PromoCodeSection.tsx +34 -28
  104. package/src/components/ticketsContainer/TicketRow.tsx +1 -1
  105. package/src/components/ticketsContainer/TicketsSection.tsx +189 -57
  106. package/src/components/ticketsContainer/TimeSlotsSection.tsx +120 -0
  107. package/src/components/ticketsContainer/index.tsx +268 -106
  108. package/src/components/timerWidget/index.tsx +15 -3
  109. package/src/constants/index.ts +2 -0
  110. package/src/env.ts +14 -6
  111. package/src/hoc/CustomFields/index.tsx +9 -1
  112. package/src/index.ts +7 -2
  113. package/src/types/add_on.ts +1 -0
  114. package/src/types/api/cart.d.ts +8 -0
  115. package/src/types/api/checkout.d.ts +58 -7
  116. package/src/types/api/common.d.ts +30 -0
  117. package/src/types/api/orders.d.ts +19 -3
  118. package/src/types/api/payment.d.ts +6 -2
  119. package/src/types/api/preRegistrationComplete.d.ts +2 -2
  120. package/src/types/checkoutPageConfigs.ts +1 -1
  121. package/src/types/order-data.ts +3 -1
  122. package/src/types/pre-registration-complete.d.ts +6 -1
  123. package/src/utils/auth.ts +32 -0
  124. package/src/utils/cookies.ts +42 -11
  125. package/src/utils/customFields.ts +22 -0
  126. package/src/utils/getDomain.ts +10 -4
  127. package/src/utils/index.ts +1 -1
  128. package/src/utils/setConfigs.ts +3 -1
  129. package/dist/components/stripePayment/index.d.ts +0 -24
  130. package/src/components/stripePayment/index.tsx +0 -281
  131. package/src/components/stripePayment/style.css +0 -60
@@ -1,281 +0,0 @@
1
- import './style.css'
2
-
3
- import CircularProgress from '@mui/material/CircularProgress'
4
- import {
5
- CardCvcElement,
6
- CardExpiryElement,
7
- CardNumberElement,
8
- useElements,
9
- useStripe,
10
- } from '@stripe/react-stripe-js'
11
- import { StripeCardNumberElementOptions } from '@stripe/stripe-js'
12
- import _get from 'lodash/get'
13
- import _identity from 'lodash/identity'
14
- import React, { useEffect, useState } from 'react'
15
-
16
- import { refreshSeatReservation } from '../../api'
17
- import { getCurrencySymbolByCurrency } from '../../normalizers'
18
- import { getQueryVariable } from '../../utils'
19
- import { adaptStripeError } from '../../utils/adaptStripeErrors'
20
- import { Checkbox } from '../common/index'
21
- import ConfirmModal from '../confirmModal'
22
-
23
- const options: StripeCardNumberElementOptions = {
24
- style: {
25
- base: {
26
- backgroundColor: '#000',
27
- fontSize: '18px',
28
- color: '#ffffff',
29
- letterSpacing: '1px',
30
- ':-webkit-autofill': {
31
- color: '#ffffff',
32
- },
33
- '::placeholder': {
34
- color: 'rgba(201, 201, 201, 0.5)',
35
- },
36
- },
37
- invalid: {
38
- color: '#E53935',
39
- },
40
- },
41
- }
42
-
43
- export interface ICheckoutForm {
44
- total: string | number;
45
- currency: string;
46
- onSubmit: (error: any, data?: object) => Promise<any>;
47
- error?: string | null;
48
- stripeCardOptions?: StripeCardNumberElementOptions;
49
- stripe_client_secret: string;
50
- billing_info: { [key: string]: any };
51
- isLoading: any;
52
- handleSetLoading: (loading: any) => void;
53
- conditions: any;
54
- disableZipSection: boolean;
55
- paymentButtonText?: string;
56
- forPaymentPlan?: boolean;
57
- orderId?: string;
58
- hasSeatMapActions: boolean;
59
- }
60
-
61
- interface AddressTypes {
62
- city: string;
63
- line1: string;
64
- state: string;
65
- postal_code?: string;
66
- }
67
-
68
- const CheckoutForm = ({
69
- total,
70
- orderId,
71
- onSubmit = _identity,
72
- stripeCardOptions = {},
73
- error = null,
74
- stripe_client_secret,
75
- currency,
76
- billing_info,
77
- isLoading = false,
78
- handleSetLoading = _identity,
79
- conditions = [],
80
- disableZipSection,
81
- paymentButtonText,
82
- forPaymentPlan = false,
83
- hasSeatMapActions = false,
84
- }: ICheckoutForm) => {
85
- const stripe = useStripe()
86
- const elements = useElements()
87
- const [postalCode, setPostalCode] = useState<any>('')
88
- const [stripeError, setStripeError] = useState<any>(null)
89
- const [checkboxes, setCheckboxes] = useState<any>([])
90
- const [allowSubmit, setAllowSubmit] = useState(false)
91
- const eventId = getQueryVariable('event_id') || ''
92
-
93
- const handleSubmit = async (event: React.SyntheticEvent) => {
94
- setStripeError(null)
95
- try {
96
- event.preventDefault()
97
-
98
- if (!postalCode && !disableZipSection) {
99
- setStripeError({ message: 'Please enter your zip code.' })
100
- handleSetLoading(false)
101
- return
102
- }
103
-
104
- if (!stripe || !elements) {
105
- // Stripe.js has not loaded yet. Make sure to disable
106
- // form submission until Stripe.js has loaded.
107
- handleSetLoading(false)
108
- return
109
- }
110
-
111
- const card = elements.getElement(CardNumberElement)
112
-
113
- const address: AddressTypes = {
114
- city: billing_info.city,
115
- line1: billing_info.street_address,
116
- state: billing_info.state,
117
- }
118
-
119
- if (!disableZipSection) {
120
- address.postal_code = postalCode
121
- }
122
-
123
- if (forPaymentPlan) {
124
- const setupResponse = await stripe.confirmCardSetup(stripe_client_secret, {
125
- payment_method: { card: card || { token: '' } },
126
- })
127
- onSubmit(null, { paymentMethodId: setupResponse.setupIntent?.payment_method })
128
- return
129
- }
130
-
131
- const paymentMethodReq = await stripe.createPaymentMethod({
132
- type: 'card',
133
- card: card || { token: '' },
134
- billing_details: {
135
- address,
136
- },
137
- })
138
-
139
- if (paymentMethodReq.error) {
140
- setStripeError(paymentMethodReq.error || null)
141
- handleSetLoading(false)
142
- return
143
- }
144
-
145
- handleSetLoading(true)
146
- const { error } = await stripe.confirmCardPayment(stripe_client_secret, {
147
- payment_method: paymentMethodReq.paymentMethod.id,
148
- })
149
-
150
- if (error) {
151
- setStripeError(adaptStripeError(error))
152
- hasSeatMapActions && (await refreshSeatReservation(eventId, orderId || ''))
153
- handleSetLoading(false)
154
- return
155
- }
156
-
157
- onSubmit(null)
158
- } catch (e) {
159
- onSubmit(e)
160
- }
161
- }
162
-
163
- const handleCheckboxes = (e: any) => {
164
- const checkbox = e.target
165
- const updatedCheckedState = checkboxes.map((item: any) => {
166
- const value = item.id === checkbox.name ? !item.checked : item.checked
167
- return {
168
- ...item,
169
- checked: value,
170
- }
171
- })
172
- setCheckboxes(updatedCheckedState)
173
- }
174
-
175
- const onChangePostalCode = (e: any) => {
176
- setPostalCode(e.target.value)
177
- }
178
-
179
- useEffect(() => {
180
- if (typeof window !== 'undefined') {
181
- const userData = JSON.parse(window.localStorage.getItem('user_data') || '')
182
- const zipCode = _get(userData, 'zip', '')
183
- zipCode && setPostalCode(zipCode)
184
- }
185
- }, [])
186
-
187
- useEffect(() => {
188
- if (conditions.length) {
189
- setCheckboxes(conditions)
190
- }
191
- }, [conditions])
192
-
193
- useEffect(() => {
194
- if (checkboxes.length) {
195
- const allChecked = checkboxes.every((item: any) => item?.checked === true)
196
- setAllowSubmit(allChecked)
197
- } else {
198
- setAllowSubmit(true)
199
- }
200
- }, [checkboxes])
201
-
202
- const buttonIsDiabled = !stripe || !!error || isLoading || !allowSubmit
203
- return (
204
- <div className="stripe_payment_container">
205
- {!!stripeError && (
206
- <ConfirmModal
207
- hideCancelBtn
208
- onConfirm={() => {
209
- setStripeError(null)
210
- onSubmit(stripeError)
211
- }}
212
- message={stripeError?.message}
213
- />
214
- )}
215
- <form onSubmit={handleSubmit}>
216
- <div className="card_form_inner">
217
- <div className="card_number_element">
218
- <span className="card_label_text">Card number</span>
219
- <CardNumberElement
220
- options={{ ...options, ...stripeCardOptions }}
221
- onReady={_identity}
222
- onChange={_identity}
223
- onBlur={_identity}
224
- onFocus={_identity}
225
- />
226
- </div>
227
- <div className="elements">
228
- <div className="expiration_element">
229
- <span className="card_label_text">Expiration date</span>
230
- <CardExpiryElement options={{ ...options, ...stripeCardOptions }} />
231
- </div>
232
- <div className="cvc_element">
233
- <span className="card_label_text">CVC</span>
234
- <CardCvcElement options={{ ...options, ...stripeCardOptions }} />
235
- </div>
236
- </div>
237
- {!disableZipSection && (
238
- <div className="zip_element">
239
- <p className="card_label_text">ZIP</p>
240
- <input
241
- type="text"
242
- value={postalCode}
243
- onChange={onChangePostalCode}
244
- placeholder="ZIP"
245
- />
246
- </div>
247
- )}
248
- </div>
249
- {checkboxes?.map((checkbox: any) => (
250
- <div className={'billing-info-container__singleField'} key={checkbox.id}>
251
- <div className="conditions-block">
252
- <Checkbox
253
- name={checkbox.id}
254
- label={checkbox.text}
255
- required={true}
256
- onChange={handleCheckboxes}
257
- checked={checkbox.checked}
258
- />
259
- </div>
260
- </div>
261
- ))}
262
- <div
263
- className={`payment_button ${buttonIsDiabled ? 'disabled-payment-button' : ''}`}
264
- >
265
- <button disabled={buttonIsDiabled} type="submit">
266
- {isLoading ? (
267
- <CircularProgress size={26} />
268
- ) : forPaymentPlan ? (
269
- 'Confirm Payment Plan'
270
- ) : (
271
- `${paymentButtonText ? paymentButtonText : 'Pay'
272
- } ${getCurrencySymbolByCurrency(currency)}${total}`
273
- )}
274
- </button>
275
- </div>
276
- </form>
277
- </div>
278
- )
279
- }
280
-
281
- export default CheckoutForm
@@ -1,60 +0,0 @@
1
- .card_form_inner {
2
- background: #232323;
3
- border-radius: 8px;
4
- padding: 15px;
5
- width: 50%;
6
- margin: 0 auto;
7
- min-width: 325px;
8
- margin-bottom: 20px;
9
- }
10
- .card_form_inner .card_label_text {
11
- color: #fff;
12
- }
13
- .card_form_inner .StripeElement {
14
- margin: 5px 0 10px;
15
- }
16
- .card_label_text {
17
- color: #fff;
18
- }
19
- .payment_button {
20
- text-align: center;
21
- padding-top: 15px;
22
- }
23
- .payment_button button {
24
- background-color: #212529;
25
- font-size: 26px;
26
- cursor: pointer;
27
- padding: 15px 30px;
28
- width: 200px;
29
- border-radius: 8px;
30
- color: #fff;
31
- transition: opacity 0.5s;
32
- }
33
- .payment_button button:hover {
34
- opacity: 0.7;
35
- }
36
-
37
- .disabled-payment-button button {
38
- user-select: none;
39
- pointer-events: none;
40
- opacity: 0.3;
41
- }
42
-
43
- .checkout_error_block {
44
- color: #e53935;
45
- padding: 15px 0;
46
- font-weight: 600;
47
- }
48
-
49
- .zip_element p {
50
- margin-bottom: 0;
51
- }
52
- .zip_element input {
53
- background-color: #000;
54
- outline: none;
55
- border: none;
56
- font-size: 18px;
57
- margin-top: 5px;
58
- color: #ffffff;
59
- width: 100%;
60
- }