tf-checkout-react 1.0.37 → 1.0.41
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/components/billing-info-container/utils.d.ts +1 -1
- package/dist/components/stripePayment/index.d.ts +3 -1
- package/dist/tf-checkout-react.cjs.development.css +3 -3
- package/dist/tf-checkout-react.cjs.development.js +87 -42
- 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 +90 -45
- package/dist/tf-checkout-react.esm.js.map +1 -1
- package/dist/types/billing-info-data.d.ts +1 -0
- package/package.json +1 -1
- package/src/.DS_Store +0 -0
- package/src/api/index.ts +2 -2
- package/src/components/.DS_Store +0 -0
- package/src/components/billing-info-container/index.tsx +27 -12
- package/src/components/billing-info-container/style.css +8 -5
- package/src/components/billing-info-container/utils.ts +2 -2
- package/src/components/loginModal/style.css +4 -0
- package/src/components/paymentContainer/index.tsx +5 -0
- package/src/components/stripePayment/index.tsx +24 -5
- package/src/components/ticketsContainer/index.tsx +10 -2
- package/src/components/ticketsContainer/style.css +17 -3
- package/src/types/billing-info-data.ts +1 -0
package/package.json
CHANGED
package/src/.DS_Store
ADDED
|
Binary file
|
package/src/api/index.ts
CHANGED
|
@@ -33,14 +33,14 @@ export const publicRequest: IPublicRequest = axios.create({
|
|
|
33
33
|
}) as IPublicRequest
|
|
34
34
|
|
|
35
35
|
publicRequest.interceptors.response.use(response => response, error => {
|
|
36
|
-
if (error
|
|
36
|
+
if (error?.response?.status === 401) {
|
|
37
37
|
if(isWindowDefined){
|
|
38
38
|
window.localStorage.removeItem('auth_guest_token')
|
|
39
39
|
window.localStorage.removeItem('user_data')
|
|
40
40
|
window.localStorage.removeItem('access_token')
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
return error
|
|
43
|
+
return Promise.reject(error)
|
|
44
44
|
})
|
|
45
45
|
|
|
46
46
|
publicRequest.interceptors.request.use((config: AxiosRequestConfig) => {
|
|
Binary file
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
postOnCheckout,
|
|
25
25
|
register,
|
|
26
26
|
setCustomHeader,
|
|
27
|
-
getStates
|
|
27
|
+
getStates,
|
|
28
28
|
} from '../../api'
|
|
29
29
|
import { LoginModal } from '../loginModal'
|
|
30
30
|
import { RegisterModal } from '../registerModal'
|
|
@@ -67,7 +67,13 @@ export interface IBillingInfoPage {
|
|
|
67
67
|
theme?: 'light' | 'dark';
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
const LogicRunner: FC<{
|
|
70
|
+
const LogicRunner: FC<{
|
|
71
|
+
values: any;
|
|
72
|
+
setStates: React.Dispatch<any>;
|
|
73
|
+
setFieldValue: any;
|
|
74
|
+
setValues: any;
|
|
75
|
+
setUserValues: any;
|
|
76
|
+
}> = ({ values, setStates, setFieldValue, setValues, setUserValues }) => {
|
|
71
77
|
useEffect(() => {
|
|
72
78
|
const fetchStates = async () => {
|
|
73
79
|
try {
|
|
@@ -78,12 +84,14 @@ const LogicRunner: FC<{values: any, setStates: React.Dispatch<any>, setFieldValu
|
|
|
78
84
|
}))
|
|
79
85
|
setStates(mappedStates)
|
|
80
86
|
setFieldValue('state', mappedStates[0]?.label ?? '')
|
|
81
|
-
} catch(e) {
|
|
82
|
-
}
|
|
87
|
+
} catch (e) {}
|
|
83
88
|
}
|
|
84
89
|
fetchStates()
|
|
85
90
|
}, [values.country, setStates, setFieldValue])
|
|
86
|
-
const userDataEncoded =
|
|
91
|
+
const userDataEncoded =
|
|
92
|
+
typeof window !== 'undefined'
|
|
93
|
+
? window.localStorage.getItem('user_data')
|
|
94
|
+
: ''
|
|
87
95
|
useEffect(() => {
|
|
88
96
|
// set user data from local storage
|
|
89
97
|
const getStoredUserData = () => {
|
|
@@ -119,7 +127,7 @@ const LogicRunner: FC<{values: any, setStates: React.Dispatch<any>, setFieldValu
|
|
|
119
127
|
}
|
|
120
128
|
getStoredUserData()
|
|
121
129
|
}, [userDataEncoded, setValues, setUserValues])
|
|
122
|
-
|
|
130
|
+
|
|
123
131
|
return null
|
|
124
132
|
}
|
|
125
133
|
|
|
@@ -291,8 +299,9 @@ export const BillingInfoContainer = ({
|
|
|
291
299
|
formikHelpers.setFieldError('holderAge', error)
|
|
292
300
|
}
|
|
293
301
|
|
|
294
|
-
if(error?.password) {
|
|
302
|
+
if (error?.password) {
|
|
295
303
|
formikHelpers.setFieldError('password', error.password)
|
|
304
|
+
formikHelpers.setFieldError('confirmPassword', error.password)
|
|
296
305
|
}
|
|
297
306
|
|
|
298
307
|
if (error?.email) {
|
|
@@ -313,7 +322,13 @@ export const BillingInfoContainer = ({
|
|
|
313
322
|
>
|
|
314
323
|
{(props: FormikProps<any>) => (
|
|
315
324
|
<Form onSubmit={props.handleSubmit}>
|
|
316
|
-
<LogicRunner
|
|
325
|
+
<LogicRunner
|
|
326
|
+
values={props.values}
|
|
327
|
+
setStates={setStates}
|
|
328
|
+
setFieldValue={props.setFieldValue}
|
|
329
|
+
setValues={props.setValues}
|
|
330
|
+
setUserValues={setUserValues}
|
|
331
|
+
/>
|
|
317
332
|
<div className={`billing-info-container ${theme}`}>
|
|
318
333
|
{!isLoggedIn && (
|
|
319
334
|
<div className="account-actions-block">
|
|
@@ -338,7 +353,7 @@ export const BillingInfoContainer = ({
|
|
|
338
353
|
</div>
|
|
339
354
|
)}
|
|
340
355
|
{_map(data, item => {
|
|
341
|
-
const { id, label, fields } = item
|
|
356
|
+
const { id, label, labelClassName, fields } = item
|
|
342
357
|
if (
|
|
343
358
|
label === 'Ticket Holders' &&
|
|
344
359
|
!showTicketHolderName &&
|
|
@@ -348,7 +363,7 @@ export const BillingInfoContainer = ({
|
|
|
348
363
|
}
|
|
349
364
|
return (
|
|
350
365
|
<SectionContainer key={id}>
|
|
351
|
-
<p>{label}</p>
|
|
366
|
+
<p className={labelClassName}>{label}</p>
|
|
352
367
|
{_map(fields, (group, index) => {
|
|
353
368
|
const {
|
|
354
369
|
groupClassname,
|
|
@@ -414,8 +429,8 @@ export const BillingInfoContainer = ({
|
|
|
414
429
|
selectOptions={
|
|
415
430
|
element.name === 'country'
|
|
416
431
|
? countries
|
|
417
|
-
: element.name === 'state'
|
|
418
|
-
? states
|
|
432
|
+
: element.name === 'state'
|
|
433
|
+
? states
|
|
419
434
|
: []
|
|
420
435
|
}
|
|
421
436
|
/>
|
|
@@ -10,6 +10,11 @@
|
|
|
10
10
|
color: #000;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
.billing-info-container .main-header {
|
|
14
|
+
font-size: 2rem;
|
|
15
|
+
font-weight: 600;
|
|
16
|
+
}
|
|
17
|
+
|
|
13
18
|
.billing-info-container__twoFields {
|
|
14
19
|
display: flex;
|
|
15
20
|
justify-content: space-between;
|
|
@@ -71,11 +76,9 @@ button {
|
|
|
71
76
|
align-items: center;
|
|
72
77
|
}
|
|
73
78
|
|
|
74
|
-
.
|
|
75
|
-
color: #
|
|
76
|
-
|
|
77
|
-
margin-bottom: 0px;
|
|
78
|
-
margin-top: 10px;
|
|
79
|
+
.login-register-button:hover {
|
|
80
|
+
background-color: #505050 !important;
|
|
81
|
+
border-color: #505050 !important;
|
|
79
82
|
}
|
|
80
83
|
|
|
81
84
|
.login-register-block {
|
|
@@ -62,7 +62,7 @@ interface IUserData {
|
|
|
62
62
|
city?: string;
|
|
63
63
|
country?: string;
|
|
64
64
|
phone?: string;
|
|
65
|
-
|
|
65
|
+
streetAddress?: string;
|
|
66
66
|
state?: string;
|
|
67
67
|
zip?: string;
|
|
68
68
|
zipCode?: string;
|
|
@@ -76,7 +76,7 @@ export const setLoggedUserData = (data: IUserData) => ({
|
|
|
76
76
|
city: data?.city || '',
|
|
77
77
|
country: data?.country || '',
|
|
78
78
|
phone: data?.phone || '',
|
|
79
|
-
street_address: data?.
|
|
79
|
+
street_address: data?.streetAddress || '',
|
|
80
80
|
state: data?.state || '',
|
|
81
81
|
zip: data?.zip || data?.zipCode || '',
|
|
82
82
|
})
|
|
@@ -57,6 +57,7 @@ export const PaymentContainer = ({
|
|
|
57
57
|
const [reviewData, setReviewData] = useState(initialReviewValues)
|
|
58
58
|
const [orderData, setOrderData] = useState(initialOrderValues)
|
|
59
59
|
const [error, setError] = useState(null)
|
|
60
|
+
const [paymentIsLoading, setPaymentIsLoading] = useState(false)
|
|
60
61
|
|
|
61
62
|
const showFormTitle: boolean = Boolean(formTitle)
|
|
62
63
|
const showErrorText: boolean = Boolean(errorText)
|
|
@@ -95,6 +96,7 @@ export const PaymentContainer = ({
|
|
|
95
96
|
const handlePaymentMiddleWare = async (error: any) => {
|
|
96
97
|
try {
|
|
97
98
|
if (error) {
|
|
99
|
+
setPaymentIsLoading(false)
|
|
98
100
|
throw error
|
|
99
101
|
}
|
|
100
102
|
const {
|
|
@@ -103,6 +105,7 @@ export const PaymentContainer = ({
|
|
|
103
105
|
const paymentSuccessResponse = await handlePaymentSuccess(order_hash)
|
|
104
106
|
if (paymentSuccessResponse.status === 200) {
|
|
105
107
|
handlePayment(paymentSuccessResponse)
|
|
108
|
+
setPaymentIsLoading(false)
|
|
106
109
|
}
|
|
107
110
|
} catch (e) {
|
|
108
111
|
setError(_get(e, 'response.data.message'))
|
|
@@ -148,6 +151,8 @@ export const PaymentContainer = ({
|
|
|
148
151
|
error={error}
|
|
149
152
|
currency={orderData.currency}
|
|
150
153
|
billing_info={reviewData.billing_info}
|
|
154
|
+
isLoading={paymentIsLoading}
|
|
155
|
+
handleSetLoading={value => setPaymentIsLoading(value)}
|
|
151
156
|
/>
|
|
152
157
|
</Elements>
|
|
153
158
|
</div>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState } from 'react'
|
|
1
|
+
import React, { useState, useEffect } from 'react'
|
|
2
2
|
import {
|
|
3
3
|
useStripe,
|
|
4
4
|
useElements,
|
|
@@ -8,9 +8,11 @@ import {
|
|
|
8
8
|
} from '@stripe/react-stripe-js'
|
|
9
9
|
import { StripeCardNumberElementOptions } from '@stripe/stripe-js'
|
|
10
10
|
import _identity from 'lodash/identity'
|
|
11
|
+
import _get from 'lodash/get'
|
|
11
12
|
|
|
12
13
|
import './style.css'
|
|
13
14
|
import { getCurrencySymbolByCurrency } from '../../normalizers'
|
|
15
|
+
import CircularProgress from '@mui/material/CircularProgress'
|
|
14
16
|
|
|
15
17
|
const options: StripeCardNumberElementOptions = {
|
|
16
18
|
style: {
|
|
@@ -38,6 +40,8 @@ export interface ICheckoutForm {
|
|
|
38
40
|
stripeCardOptions?: StripeCardNumberElementOptions;
|
|
39
41
|
stripe_client_secret: string;
|
|
40
42
|
billing_info: { [key: string]: any };
|
|
43
|
+
isLoading: any;
|
|
44
|
+
handleSetLoading: (loading: any) => void;
|
|
41
45
|
}
|
|
42
46
|
|
|
43
47
|
interface AddressTypes {
|
|
@@ -55,6 +59,8 @@ const CheckoutForm = ({
|
|
|
55
59
|
stripe_client_secret,
|
|
56
60
|
currency,
|
|
57
61
|
billing_info,
|
|
62
|
+
isLoading = false,
|
|
63
|
+
handleSetLoading = () => {}
|
|
58
64
|
}: ICheckoutForm) => {
|
|
59
65
|
const stripe = useStripe()
|
|
60
66
|
const elements = useElements()
|
|
@@ -62,17 +68,20 @@ const CheckoutForm = ({
|
|
|
62
68
|
const [stripeError, setStripeError] = useState<any>(null)
|
|
63
69
|
|
|
64
70
|
const handleSubmit = async (event: React.SyntheticEvent) => {
|
|
71
|
+
handleSetLoading(true)
|
|
65
72
|
try {
|
|
66
73
|
event.preventDefault()
|
|
67
74
|
|
|
68
75
|
if(!postalCode) {
|
|
69
76
|
setStripeError("Please enter your zip code.")
|
|
77
|
+
handleSetLoading(false)
|
|
70
78
|
return
|
|
71
79
|
}
|
|
72
80
|
|
|
73
81
|
if (!stripe || !elements) {
|
|
74
82
|
// Stripe.js has not loaded yet. Make sure to disable
|
|
75
83
|
// form submission until Stripe.js has loaded.
|
|
84
|
+
handleSetLoading(false)
|
|
76
85
|
return
|
|
77
86
|
}
|
|
78
87
|
|
|
@@ -94,6 +103,7 @@ const CheckoutForm = ({
|
|
|
94
103
|
|
|
95
104
|
if (paymentMethodReq.error) {
|
|
96
105
|
setStripeError(paymentMethodReq.error.message || null)
|
|
106
|
+
handleSetLoading(false)
|
|
97
107
|
return
|
|
98
108
|
}
|
|
99
109
|
|
|
@@ -103,6 +113,7 @@ const CheckoutForm = ({
|
|
|
103
113
|
|
|
104
114
|
if (error) {
|
|
105
115
|
setStripeError(error.message)
|
|
116
|
+
handleSetLoading(false)
|
|
106
117
|
return
|
|
107
118
|
}
|
|
108
119
|
|
|
@@ -115,10 +126,18 @@ const CheckoutForm = ({
|
|
|
115
126
|
|
|
116
127
|
const onChangePostalCode = (e: any) => {
|
|
117
128
|
setPostalCode(e.target.value)
|
|
118
|
-
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
useEffect(() => {
|
|
132
|
+
if (typeof window !== 'undefined') {
|
|
133
|
+
const userData = JSON.parse(window.localStorage.getItem('user_data') || '')
|
|
134
|
+
const zipCode = _get(userData, 'zip', '')
|
|
135
|
+
zipCode && setPostalCode(zipCode)
|
|
136
|
+
}
|
|
137
|
+
}, [])
|
|
119
138
|
|
|
120
139
|
return (
|
|
121
|
-
<div>
|
|
140
|
+
<div className="stripe_payment_container">
|
|
122
141
|
{!!stripeError && (
|
|
123
142
|
<div className="checkout_error_block">{stripeError}</div>
|
|
124
143
|
)}
|
|
@@ -153,8 +172,8 @@ const CheckoutForm = ({
|
|
|
153
172
|
</label>
|
|
154
173
|
</div>
|
|
155
174
|
<div className="payment_button">
|
|
156
|
-
<button disabled={!stripe || !!error} type="submit">
|
|
157
|
-
{`Pay ${getCurrencySymbolByCurrency(currency)}${total}`}
|
|
175
|
+
<button disabled={!stripe || !!error || isLoading} type="submit">
|
|
176
|
+
{isLoading ? <CircularProgress /> : `Pay ${getCurrencySymbolByCurrency(currency)}${total}`}
|
|
158
177
|
</button>
|
|
159
178
|
</div>
|
|
160
179
|
</form>
|
|
@@ -128,6 +128,9 @@ const renderTiers = (
|
|
|
128
128
|
? 'SOLD OUT'
|
|
129
129
|
: `$ ${(+tier.cost || +tier.price).toFixed(2)}`}
|
|
130
130
|
</p>
|
|
131
|
+
{!isSoldOut && (
|
|
132
|
+
<p className='fees'>{tier.taxesIncluded ? '(incl. Fees)' : '(excl. Fees)'}</p>
|
|
133
|
+
)}
|
|
131
134
|
</div>
|
|
132
135
|
<div className="event-detail__tier-state" style={{ minWidth: 55 }}>
|
|
133
136
|
{computeTierStateLabel(
|
|
@@ -303,11 +306,11 @@ export const TicketsContainer = ({
|
|
|
303
306
|
handleTicketSelect,
|
|
304
307
|
promoCodeIsApplied
|
|
305
308
|
)}
|
|
306
|
-
{promoCodeIsApplied
|
|
309
|
+
{promoCodeIsApplied ? (
|
|
307
310
|
<div className="alert-info">
|
|
308
311
|
Your promo code was applied successfully.
|
|
309
312
|
</div>
|
|
310
|
-
)}
|
|
313
|
+
) : null}
|
|
311
314
|
{showPromoInput && (
|
|
312
315
|
<div className="promo-code-block">
|
|
313
316
|
<input
|
|
@@ -315,6 +318,11 @@ export const TicketsContainer = ({
|
|
|
315
318
|
onChange={e => {
|
|
316
319
|
setPromoCode(e.target.value)
|
|
317
320
|
}}
|
|
321
|
+
onKeyPress={event => {
|
|
322
|
+
if (event.key === 'Enter') {
|
|
323
|
+
setPromoCodeUpdated(promoCode)
|
|
324
|
+
}
|
|
325
|
+
}}
|
|
318
326
|
/>
|
|
319
327
|
<Button
|
|
320
328
|
className="promo-apply-button"
|
|
@@ -14,9 +14,6 @@ body {
|
|
|
14
14
|
font-weight: 700;
|
|
15
15
|
line-height: 1.3;
|
|
16
16
|
text-transform: uppercase;
|
|
17
|
-
text-overflow: ellipsis;
|
|
18
|
-
overflow: hidden;
|
|
19
|
-
white-space: nowrap;
|
|
20
17
|
padding-right: 20%;
|
|
21
18
|
color: black;
|
|
22
19
|
font-size: 0.85rem;
|
|
@@ -71,6 +68,13 @@ body {
|
|
|
71
68
|
margin: 0;
|
|
72
69
|
}
|
|
73
70
|
|
|
71
|
+
.event-detail__tier-price .fees {
|
|
72
|
+
font-size: 14px;
|
|
73
|
+
font-weight: normal;
|
|
74
|
+
text-align: left;
|
|
75
|
+
margin-top: 4px;
|
|
76
|
+
}
|
|
77
|
+
|
|
74
78
|
.event-detail__tier-price .old-price {
|
|
75
79
|
margin-bottom: 5px;
|
|
76
80
|
color: #f00;
|
|
@@ -101,6 +105,12 @@ body {
|
|
|
101
105
|
text-align: right;
|
|
102
106
|
text-transform: uppercase;
|
|
103
107
|
}
|
|
108
|
+
|
|
109
|
+
.promo-code-block input {
|
|
110
|
+
font-size: 14px;
|
|
111
|
+
padding: 1px 8px;
|
|
112
|
+
}
|
|
113
|
+
|
|
104
114
|
.book-button {
|
|
105
115
|
background-color: #212529;
|
|
106
116
|
display: block;
|
|
@@ -119,6 +129,10 @@ body {
|
|
|
119
129
|
line-height: 1.5;
|
|
120
130
|
margin: 25px auto 10px auto;
|
|
121
131
|
}
|
|
132
|
+
.book-button:hover {
|
|
133
|
+
background-color: #505050;
|
|
134
|
+
border-color: #505050;
|
|
135
|
+
}
|
|
122
136
|
.loader-container {
|
|
123
137
|
height: 100%;
|
|
124
138
|
width: 100%;
|