tf-checkout-react 1.0.100 → 1.0.104

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 (84) hide show
  1. package/dist/components/billing-info-container/index.d.ts +3 -1
  2. package/dist/components/common/RedirectModal.d.ts +7 -0
  3. package/dist/components/common/SnackbarAlert.d.ts +13 -0
  4. package/dist/components/confirmationContainer/index.d.ts +2 -1
  5. package/dist/components/ticketsContainer/index.d.ts +2 -1
  6. package/dist/env.d.ts +1 -0
  7. package/dist/images/done.svg +3 -3
  8. package/dist/index.d.ts +1 -0
  9. package/dist/tf-checkout-react.cjs.development.js +317 -136
  10. package/dist/tf-checkout-react.cjs.development.js.map +1 -1
  11. package/dist/tf-checkout-react.cjs.production.min.js +1 -1
  12. package/dist/tf-checkout-react.cjs.production.min.js.map +1 -1
  13. package/dist/tf-checkout-react.esm.js +318 -138
  14. package/dist/tf-checkout-react.esm.js.map +1 -1
  15. package/dist/tf-checkout-styles.css +1 -1
  16. package/package.json +89 -89
  17. package/src/.DS_Store +0 -0
  18. package/src/.d.ts +2 -2
  19. package/src/api/index.ts +293 -278
  20. package/src/assets/images/done.svg +3 -3
  21. package/src/components/.DS_Store +0 -0
  22. package/src/components/billing-info-container/index.tsx +796 -777
  23. package/src/components/billing-info-container/style.css +105 -105
  24. package/src/components/billing-info-container/utils.ts +224 -224
  25. package/src/components/common/CheckboxField.tsx +41 -41
  26. package/src/components/common/CustomField.tsx +84 -84
  27. package/src/components/common/FormikPhoneNumberField.tsx +51 -51
  28. package/src/components/common/Loader.tsx +9 -9
  29. package/src/components/common/RadioField.tsx +35 -35
  30. package/src/components/common/RedirectModal.tsx +43 -0
  31. package/src/components/common/SelectField.tsx +80 -80
  32. package/src/components/common/SnackbarAlert.tsx +54 -0
  33. package/src/components/common/index.tsx +4 -4
  34. package/src/components/confirmModal/index.tsx +51 -51
  35. package/src/components/confirmModal/style.css +21 -21
  36. package/src/components/confirmationContainer/config.ts +72 -72
  37. package/src/components/confirmationContainer/index.tsx +197 -194
  38. package/src/components/confirmationContainer/social-buttons.tsx +94 -94
  39. package/src/components/confirmationContainer/style.css +202 -202
  40. package/src/components/countdown/index.tsx +89 -89
  41. package/src/components/countdown/style.css +9 -9
  42. package/src/components/index.ts +7 -7
  43. package/src/components/loginModal/index.tsx +209 -209
  44. package/src/components/loginModal/style.css +71 -71
  45. package/src/components/myTicketsContainer/index.tsx +196 -137
  46. package/src/components/myTicketsContainer/row.tsx +41 -41
  47. package/src/components/myTicketsContainer/style.css +39 -39
  48. package/src/components/myTicketsContainer/tableConfig.tsx +34 -34
  49. package/src/components/orderDetailsContainer/index.tsx +249 -249
  50. package/src/components/orderDetailsContainer/style.css +72 -72
  51. package/src/components/orderDetailsContainer/ticketsTable.tsx +124 -124
  52. package/src/components/paymentContainer/index.tsx +284 -284
  53. package/src/components/registerModal/index.tsx +190 -190
  54. package/src/components/stripePayment/index.tsx +253 -253
  55. package/src/components/stripePayment/style.css +59 -59
  56. package/src/components/ticketResale/index.tsx +56 -56
  57. package/src/components/ticketResaleModal/index.tsx +210 -210
  58. package/src/components/ticketResaleModal/style.css +28 -28
  59. package/src/components/ticketsContainer/PromoCodeSection.tsx +99 -99
  60. package/src/components/ticketsContainer/ReferralLogic.tsx +33 -33
  61. package/src/components/ticketsContainer/TicketRow.tsx +83 -83
  62. package/src/components/ticketsContainer/TicketsSection.tsx +81 -81
  63. package/src/components/ticketsContainer/index.tsx +427 -409
  64. package/src/components/ticketsContainer/style.css +181 -181
  65. package/src/components/ticketsContainer/utils.ts +11 -11
  66. package/src/components/timerWidget/index.tsx +70 -70
  67. package/src/components/timerWidget/style.css +26 -26
  68. package/src/components/waitingList/index.tsx +178 -178
  69. package/src/components/waitingList/style.css +26 -26
  70. package/src/env.ts +20 -19
  71. package/src/index.ts +14 -13
  72. package/src/normalizers/index.ts +45 -45
  73. package/src/types/billing-info-data.ts +37 -37
  74. package/src/types/payment-field.ts +7 -7
  75. package/src/types/referral-promotion.ts +7 -7
  76. package/src/utils/createCheckoutDataBodyWithDefaultHolder.ts +59 -59
  77. package/src/utils/downloadPDF.tsx +30 -30
  78. package/src/utils/formikErrorFocus.ts +24 -24
  79. package/src/utils/getImage.ts +14 -14
  80. package/src/utils/getQueryVariable.ts +13 -13
  81. package/src/utils/index.ts +5 -5
  82. package/src/utils/setConfigs.ts +26 -26
  83. package/src/utils/showZero.tsx +10 -10
  84. package/src/validators/index.ts +20 -20
@@ -1,253 +1,253 @@
1
- import React, { useState, useEffect } from 'react'
2
- import {
3
- useStripe,
4
- useElements,
5
- CardNumberElement,
6
- CardExpiryElement,
7
- CardCvcElement,
8
- } from '@stripe/react-stripe-js'
9
- import { StripeCardNumberElementOptions } from '@stripe/stripe-js'
10
- import _identity from 'lodash/identity'
11
- import _get from 'lodash/get'
12
- import { CheckboxField } from '../common/index'
13
-
14
- import './style.css'
15
- import { getCurrencySymbolByCurrency } from '../../normalizers'
16
- import CircularProgress from '@mui/material/CircularProgress'
17
-
18
- const options: StripeCardNumberElementOptions = {
19
- style: {
20
- base: {
21
- backgroundColor: '#000',
22
- fontSize: '18px',
23
- color: '#ffffff',
24
- letterSpacing: '1px',
25
- ':-webkit-autofill': {
26
- color: '#ffffff',
27
- },
28
- '::placeholder': {
29
- color: 'rgba(201, 201, 201, 0.5)',
30
- },
31
- },
32
- invalid: {
33
- color: '#E53935',
34
- },
35
- },
36
- }
37
-
38
- export interface ICheckoutForm {
39
- total: string;
40
- currency: string;
41
- onSubmit: (error: any) => Promise<any>;
42
- error?: string | null;
43
- stripeCardOptions?: StripeCardNumberElementOptions;
44
- stripe_client_secret: string;
45
- billing_info: { [key: string]: any };
46
- isLoading: any;
47
- handleSetLoading: (loading: any) => void;
48
- conditions: any;
49
- disableZipSection: boolean;
50
- }
51
-
52
- interface AddressTypes {
53
- city: string;
54
- line1: string;
55
- state: string;
56
- postal_code?: string;
57
- }
58
-
59
- const CheckoutForm = ({
60
- total,
61
- onSubmit = _identity,
62
- stripeCardOptions = {},
63
- error = null,
64
- stripe_client_secret,
65
- currency,
66
- billing_info,
67
- isLoading = false,
68
- handleSetLoading = () => {},
69
- conditions = [],
70
- disableZipSection,
71
- }: ICheckoutForm) => {
72
- const stripe = useStripe()
73
- const elements = useElements()
74
- const [postalCode, setPostalCode] = useState<any>('')
75
- const [stripeError, setStripeError] = useState<any>(null)
76
- const [checkboxes, setCheckboxes] = useState<any>([])
77
- const [allowSubmit, setAllowSubmit] = useState(false)
78
-
79
- const handleSubmit = async (event: React.SyntheticEvent) => {
80
- handleSetLoading(true)
81
- try {
82
- event.preventDefault()
83
-
84
- if (!postalCode && !disableZipSection) {
85
- setStripeError('Please enter your zip code.')
86
- handleSetLoading(false)
87
- return
88
- }
89
-
90
- if (!stripe || !elements) {
91
- // Stripe.js has not loaded yet. Make sure to disable
92
- // form submission until Stripe.js has loaded.
93
- handleSetLoading(false)
94
- return
95
- }
96
-
97
- const card = elements.getElement(CardNumberElement)
98
-
99
- const address: AddressTypes = {
100
- city: billing_info.city,
101
- line1: billing_info.street_address,
102
- state: billing_info.state,
103
- }
104
-
105
- if (!disableZipSection) {
106
- address.postal_code = postalCode
107
- }
108
-
109
- const paymentMethodReq = await stripe.createPaymentMethod({
110
- type: 'card',
111
- card: card || { token: '' },
112
- billing_details: {
113
- address,
114
- },
115
- })
116
-
117
- if (paymentMethodReq.error) {
118
- setStripeError(paymentMethodReq.error.message || null)
119
- handleSetLoading(false)
120
- return
121
- }
122
-
123
- const { error } = await stripe.confirmCardPayment(stripe_client_secret, {
124
- payment_method: paymentMethodReq.paymentMethod.id,
125
- })
126
-
127
- if (error) {
128
- setStripeError(error.message)
129
- handleSetLoading(false)
130
- return
131
- }
132
-
133
- onSubmit(null)
134
- } catch (e) {
135
- onSubmit(e)
136
- }
137
- }
138
-
139
- const handleCheckboxes = (e: any) => {
140
- const checkbox = e.target
141
- const updatedCheckedState = checkboxes.map((item: any) => {
142
- const value = item.id === checkbox.name ? !item.checked : item.checked
143
- return {
144
- ...item,
145
- checked: value,
146
- }
147
- })
148
- setCheckboxes(updatedCheckedState)
149
- }
150
-
151
- const onChangePostalCode = (e: any) => {
152
- setPostalCode(e.target.value)
153
- }
154
-
155
- useEffect(() => {
156
- if (typeof window !== 'undefined') {
157
- const userData = JSON.parse(
158
- window.localStorage.getItem('user_data') || ''
159
- )
160
- const zipCode = _get(userData, 'zip', '')
161
- zipCode && setPostalCode(zipCode)
162
- }
163
- }, [])
164
-
165
- useEffect(() => {
166
- if (conditions.length) {
167
- setCheckboxes(conditions)
168
- }
169
- }, [conditions])
170
-
171
- useEffect(() => {
172
- if (checkboxes.length) {
173
- const allChecked = checkboxes.every(
174
- (item: any) => item?.checked === true
175
- )
176
- setAllowSubmit(allChecked)
177
- } else {
178
- setAllowSubmit(true)
179
- }
180
- }, [checkboxes])
181
-
182
- const buttonIsDiabled = !stripe || !!error || isLoading || !allowSubmit
183
-
184
- return (
185
- <div className="stripe_payment_container">
186
- {!!stripeError && (
187
- <div className="checkout_error_block">{stripeError}</div>
188
- )}
189
- <form onSubmit={handleSubmit}>
190
- <div className="card_form_inner">
191
- <label className="card_number_element">
192
- <span className="card_label_text">Card number</span>
193
- <CardNumberElement
194
- options={{ ...options, ...stripeCardOptions, }}
195
- onReady={_identity}
196
- onChange={_identity}
197
- onBlur={_identity}
198
- onFocus={_identity}
199
- />
200
- </label>
201
- <label className="expiration_element">
202
- <span className="card_label_text">Expiration date</span>
203
- <CardExpiryElement options={{ ...options, ...stripeCardOptions }} />
204
- </label>
205
- <label className="cvc_element">
206
- <span className="card_label_text">CVC</span>
207
- <CardCvcElement options={{ ...options, ...stripeCardOptions }} />
208
- </label>
209
- {!disableZipSection && (
210
- <label className="zip_element">
211
- <p className="card_label_text">ZIP</p>
212
- <input
213
- type="text"
214
- value={postalCode}
215
- onChange={onChangePostalCode}
216
- placeholder="ZIP"
217
- />
218
- </label>
219
- )}
220
- </div>
221
- {checkboxes?.map((checkbox: any) => (
222
- <div
223
- className={'billing-info-container__singleField'}
224
- key={checkbox.id}
225
- >
226
- <div className="conditions-block">
227
- <CheckboxField
228
- name={checkbox.id}
229
- label={checkbox.text}
230
- required={true}
231
- onChange={handleCheckboxes}
232
- checked={checkbox.checked}
233
- />
234
- </div>
235
- </div>
236
- ))}
237
- <div
238
- className={`payment_button ${buttonIsDiabled ? 'disabled-payment-button' : ''}`}
239
- >
240
- <button disabled={buttonIsDiabled} type="submit">
241
- {isLoading ? (
242
- <CircularProgress size={26} />
243
- ) : (
244
- `Pay ${getCurrencySymbolByCurrency(currency)}${total}`
245
- )}
246
- </button>
247
- </div>
248
- </form>
249
- </div>
250
- )
251
- }
252
-
253
- export default CheckoutForm
1
+ import React, { useState, useEffect } from 'react'
2
+ import {
3
+ useStripe,
4
+ useElements,
5
+ CardNumberElement,
6
+ CardExpiryElement,
7
+ CardCvcElement,
8
+ } from '@stripe/react-stripe-js'
9
+ import { StripeCardNumberElementOptions } from '@stripe/stripe-js'
10
+ import _identity from 'lodash/identity'
11
+ import _get from 'lodash/get'
12
+ import { CheckboxField } from '../common/index'
13
+
14
+ import './style.css'
15
+ import { getCurrencySymbolByCurrency } from '../../normalizers'
16
+ import CircularProgress from '@mui/material/CircularProgress'
17
+
18
+ const options: StripeCardNumberElementOptions = {
19
+ style: {
20
+ base: {
21
+ backgroundColor: '#000',
22
+ fontSize: '18px',
23
+ color: '#ffffff',
24
+ letterSpacing: '1px',
25
+ ':-webkit-autofill': {
26
+ color: '#ffffff',
27
+ },
28
+ '::placeholder': {
29
+ color: 'rgba(201, 201, 201, 0.5)',
30
+ },
31
+ },
32
+ invalid: {
33
+ color: '#E53935',
34
+ },
35
+ },
36
+ }
37
+
38
+ export interface ICheckoutForm {
39
+ total: string;
40
+ currency: string;
41
+ onSubmit: (error: any) => Promise<any>;
42
+ error?: string | null;
43
+ stripeCardOptions?: StripeCardNumberElementOptions;
44
+ stripe_client_secret: string;
45
+ billing_info: { [key: string]: any };
46
+ isLoading: any;
47
+ handleSetLoading: (loading: any) => void;
48
+ conditions: any;
49
+ disableZipSection: boolean;
50
+ }
51
+
52
+ interface AddressTypes {
53
+ city: string;
54
+ line1: string;
55
+ state: string;
56
+ postal_code?: string;
57
+ }
58
+
59
+ const CheckoutForm = ({
60
+ total,
61
+ onSubmit = _identity,
62
+ stripeCardOptions = {},
63
+ error = null,
64
+ stripe_client_secret,
65
+ currency,
66
+ billing_info,
67
+ isLoading = false,
68
+ handleSetLoading = () => {},
69
+ conditions = [],
70
+ disableZipSection,
71
+ }: ICheckoutForm) => {
72
+ const stripe = useStripe()
73
+ const elements = useElements()
74
+ const [postalCode, setPostalCode] = useState<any>('')
75
+ const [stripeError, setStripeError] = useState<any>(null)
76
+ const [checkboxes, setCheckboxes] = useState<any>([])
77
+ const [allowSubmit, setAllowSubmit] = useState(false)
78
+
79
+ const handleSubmit = async (event: React.SyntheticEvent) => {
80
+ handleSetLoading(true)
81
+ try {
82
+ event.preventDefault()
83
+
84
+ if (!postalCode && !disableZipSection) {
85
+ setStripeError('Please enter your zip code.')
86
+ handleSetLoading(false)
87
+ return
88
+ }
89
+
90
+ if (!stripe || !elements) {
91
+ // Stripe.js has not loaded yet. Make sure to disable
92
+ // form submission until Stripe.js has loaded.
93
+ handleSetLoading(false)
94
+ return
95
+ }
96
+
97
+ const card = elements.getElement(CardNumberElement)
98
+
99
+ const address: AddressTypes = {
100
+ city: billing_info.city,
101
+ line1: billing_info.street_address,
102
+ state: billing_info.state,
103
+ }
104
+
105
+ if (!disableZipSection) {
106
+ address.postal_code = postalCode
107
+ }
108
+
109
+ const paymentMethodReq = await stripe.createPaymentMethod({
110
+ type: 'card',
111
+ card: card || { token: '' },
112
+ billing_details: {
113
+ address,
114
+ },
115
+ })
116
+
117
+ if (paymentMethodReq.error) {
118
+ setStripeError(paymentMethodReq.error.message || null)
119
+ handleSetLoading(false)
120
+ return
121
+ }
122
+
123
+ const { error } = await stripe.confirmCardPayment(stripe_client_secret, {
124
+ payment_method: paymentMethodReq.paymentMethod.id,
125
+ })
126
+
127
+ if (error) {
128
+ setStripeError(error.message)
129
+ handleSetLoading(false)
130
+ return
131
+ }
132
+
133
+ onSubmit(null)
134
+ } catch (e) {
135
+ onSubmit(e)
136
+ }
137
+ }
138
+
139
+ const handleCheckboxes = (e: any) => {
140
+ const checkbox = e.target
141
+ const updatedCheckedState = checkboxes.map((item: any) => {
142
+ const value = item.id === checkbox.name ? !item.checked : item.checked
143
+ return {
144
+ ...item,
145
+ checked: value,
146
+ }
147
+ })
148
+ setCheckboxes(updatedCheckedState)
149
+ }
150
+
151
+ const onChangePostalCode = (e: any) => {
152
+ setPostalCode(e.target.value)
153
+ }
154
+
155
+ useEffect(() => {
156
+ if (typeof window !== 'undefined') {
157
+ const userData = JSON.parse(
158
+ window.localStorage.getItem('user_data') || ''
159
+ )
160
+ const zipCode = _get(userData, 'zip', '')
161
+ zipCode && setPostalCode(zipCode)
162
+ }
163
+ }, [])
164
+
165
+ useEffect(() => {
166
+ if (conditions.length) {
167
+ setCheckboxes(conditions)
168
+ }
169
+ }, [conditions])
170
+
171
+ useEffect(() => {
172
+ if (checkboxes.length) {
173
+ const allChecked = checkboxes.every(
174
+ (item: any) => item?.checked === true
175
+ )
176
+ setAllowSubmit(allChecked)
177
+ } else {
178
+ setAllowSubmit(true)
179
+ }
180
+ }, [checkboxes])
181
+
182
+ const buttonIsDiabled = !stripe || !!error || isLoading || !allowSubmit
183
+
184
+ return (
185
+ <div className="stripe_payment_container">
186
+ {!!stripeError && (
187
+ <div className="checkout_error_block">{stripeError}</div>
188
+ )}
189
+ <form onSubmit={handleSubmit}>
190
+ <div className="card_form_inner">
191
+ <label className="card_number_element">
192
+ <span className="card_label_text">Card number</span>
193
+ <CardNumberElement
194
+ options={{ ...options, ...stripeCardOptions, }}
195
+ onReady={_identity}
196
+ onChange={_identity}
197
+ onBlur={_identity}
198
+ onFocus={_identity}
199
+ />
200
+ </label>
201
+ <label className="expiration_element">
202
+ <span className="card_label_text">Expiration date</span>
203
+ <CardExpiryElement options={{ ...options, ...stripeCardOptions }} />
204
+ </label>
205
+ <label className="cvc_element">
206
+ <span className="card_label_text">CVC</span>
207
+ <CardCvcElement options={{ ...options, ...stripeCardOptions }} />
208
+ </label>
209
+ {!disableZipSection && (
210
+ <label className="zip_element">
211
+ <p className="card_label_text">ZIP</p>
212
+ <input
213
+ type="text"
214
+ value={postalCode}
215
+ onChange={onChangePostalCode}
216
+ placeholder="ZIP"
217
+ />
218
+ </label>
219
+ )}
220
+ </div>
221
+ {checkboxes?.map((checkbox: any) => (
222
+ <div
223
+ className={'billing-info-container__singleField'}
224
+ key={checkbox.id}
225
+ >
226
+ <div className="conditions-block">
227
+ <CheckboxField
228
+ name={checkbox.id}
229
+ label={checkbox.text}
230
+ required={true}
231
+ onChange={handleCheckboxes}
232
+ checked={checkbox.checked}
233
+ />
234
+ </div>
235
+ </div>
236
+ ))}
237
+ <div
238
+ className={`payment_button ${buttonIsDiabled ? 'disabled-payment-button' : ''}`}
239
+ >
240
+ <button disabled={buttonIsDiabled} type="submit">
241
+ {isLoading ? (
242
+ <CircularProgress size={26} />
243
+ ) : (
244
+ `Pay ${getCurrencySymbolByCurrency(currency)}${total}`
245
+ )}
246
+ </button>
247
+ </div>
248
+ </form>
249
+ </div>
250
+ )
251
+ }
252
+
253
+ export default CheckoutForm
@@ -1,60 +1,60 @@
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%;
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
60
  }