tf-checkout-react 1.0.41 → 1.0.45
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/index.d.ts +22 -3
- package/dist/components/billing-info-container/utils.d.ts +1 -1
- package/dist/components/confirmationContainer/index.d.ts +4 -1
- package/dist/components/loginModal/index.d.ts +8 -4
- package/dist/components/paymentContainer/index.d.ts +5 -1
- package/dist/components/registerModal/index.d.ts +3 -0
- package/dist/components/ticketsContainer/index.d.ts +5 -1
- package/dist/index.d.ts +1 -0
- package/dist/tf-checkout-react.cjs.development.css +1 -1
- package/dist/tf-checkout-react.cjs.development.js +412 -144
- 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 +417 -150
- package/dist/tf-checkout-react.esm.js.map +1 -1
- package/dist/types/billing-info-data.d.ts +2 -1
- package/package.json +3 -1
- package/src/api/index.ts +2 -2
- package/src/components/billing-info-container/index.tsx +224 -55
- package/src/components/billing-info-container/style.css +15 -0
- package/src/components/billing-info-container/utils.ts +38 -11
- package/src/components/common/CustomField.tsx +15 -0
- package/src/components/confirmationContainer/index.tsx +8 -3
- package/src/components/loginModal/index.tsx +46 -13
- package/src/components/paymentContainer/index.tsx +10 -0
- package/src/components/registerModal/index.tsx +20 -3
- package/src/components/ticketsContainer/index.tsx +14 -2
- package/src/index.ts +2 -1
- package/src/types/billing-info-data.ts +2 -1
- package/src/.DS_Store +0 -0
- package/src/components/.DS_Store +0 -0
|
@@ -7,6 +7,7 @@ import _get from 'lodash/get'
|
|
|
7
7
|
|
|
8
8
|
import { IReferralPromotion } from '../../types'
|
|
9
9
|
import { getConfirmationData } from '../../api'
|
|
10
|
+
import { AxiosError } from 'axios'
|
|
10
11
|
|
|
11
12
|
export interface IShareButton {
|
|
12
13
|
mainLabel: string;
|
|
@@ -26,6 +27,8 @@ export interface IConfirmationPage {
|
|
|
26
27
|
shareLink: string;
|
|
27
28
|
isReferralEnabled: boolean;
|
|
28
29
|
shareButtons: IShareButton[];
|
|
30
|
+
onGetConfirmationDataSuccess: (res: any) => void;
|
|
31
|
+
onGetConfirmationDataError: (e: AxiosError) => void;
|
|
29
32
|
}
|
|
30
33
|
|
|
31
34
|
const defaultSvg =
|
|
@@ -35,6 +38,8 @@ export const ConfirmationContainer = ({
|
|
|
35
38
|
referralPromotions = [],
|
|
36
39
|
shareButtons = [],
|
|
37
40
|
shareLink = '',
|
|
41
|
+
onGetConfirmationDataSuccess = () => {},
|
|
42
|
+
onGetConfirmationDataError = () => {},
|
|
38
43
|
}: IConfirmationPage) => {
|
|
39
44
|
const inputRef = useRef(null)
|
|
40
45
|
const [data, setData] = useState<any>({})
|
|
@@ -55,14 +60,14 @@ export const ConfirmationContainer = ({
|
|
|
55
60
|
try {
|
|
56
61
|
const response = await getConfirmationData(hash)
|
|
57
62
|
const data = _get(response, 'data.data.attributes')
|
|
58
|
-
|
|
59
63
|
setData(data)
|
|
64
|
+
onGetConfirmationDataSuccess(response.data)
|
|
60
65
|
} catch (error) {
|
|
61
|
-
|
|
66
|
+
onGetConfirmationDataError(error.response)
|
|
62
67
|
}
|
|
63
68
|
}
|
|
64
69
|
})()
|
|
65
|
-
}, [])
|
|
70
|
+
}, [onGetConfirmationDataSuccess, onGetConfirmationDataError])
|
|
66
71
|
|
|
67
72
|
return (
|
|
68
73
|
<div className="confirmation-page">
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { FC, useState } from 'react'
|
|
2
|
+
import { AxiosError } from 'axios'
|
|
2
3
|
import {
|
|
3
4
|
authorize,
|
|
4
5
|
getAccessToken,
|
|
@@ -18,9 +19,12 @@ import axios from 'axios'
|
|
|
18
19
|
interface Props {
|
|
19
20
|
onClose: () => void;
|
|
20
21
|
onLogin: () => void;
|
|
21
|
-
alreadyHasUser
|
|
22
|
-
userExpired
|
|
23
|
-
|
|
22
|
+
alreadyHasUser?: boolean;
|
|
23
|
+
userExpired?: boolean;
|
|
24
|
+
onAuthorizeSuccess?: (res: any) => void;
|
|
25
|
+
onAuthorizeError?: (e: AxiosError) => void;
|
|
26
|
+
onGetProfileDataSuccess?: (res: any) => void;
|
|
27
|
+
onGetProfileDataError?: (e: AxiosError) => void;
|
|
24
28
|
}
|
|
25
29
|
|
|
26
30
|
const style: React.CSSProperties = {
|
|
@@ -37,9 +41,12 @@ const style: React.CSSProperties = {
|
|
|
37
41
|
export const LoginModal: FC<Props> = ({
|
|
38
42
|
onClose,
|
|
39
43
|
onLogin,
|
|
40
|
-
alreadyHasUser,
|
|
41
|
-
userExpired,
|
|
42
|
-
|
|
44
|
+
alreadyHasUser = false,
|
|
45
|
+
userExpired = false,
|
|
46
|
+
onAuthorizeSuccess = () => {},
|
|
47
|
+
onAuthorizeError = () => {},
|
|
48
|
+
onGetProfileDataSuccess = () => {},
|
|
49
|
+
onGetProfileDataError = () => {},
|
|
43
50
|
}) => {
|
|
44
51
|
const [error, setError] = useState('')
|
|
45
52
|
return (
|
|
@@ -58,8 +65,8 @@ export const LoginModal: FC<Props> = ({
|
|
|
58
65
|
const bodyFormData = new FormData()
|
|
59
66
|
bodyFormData.append('email', email)
|
|
60
67
|
bodyFormData.append('password', password)
|
|
61
|
-
const resAutorize = await authorize(bodyFormData)
|
|
62
68
|
|
|
69
|
+
const resAutorize = await authorize(bodyFormData)
|
|
63
70
|
const bodyFormDataToken = new FormData()
|
|
64
71
|
bodyFormDataToken.append('code', resAutorize.data.data.code)
|
|
65
72
|
bodyFormDataToken.append('scope', 'profile')
|
|
@@ -73,22 +80,48 @@ export const LoginModal: FC<Props> = ({
|
|
|
73
80
|
ENV.CLIENT_SECRET ||
|
|
74
81
|
'b89c191eff22fdcf84ac9bfd88d005355a151ec2c83b26b9'
|
|
75
82
|
)
|
|
76
|
-
|
|
83
|
+
|
|
84
|
+
let resAccessToken = null
|
|
85
|
+
|
|
86
|
+
try {
|
|
87
|
+
resAccessToken = await getAccessToken(bodyFormDataToken)
|
|
88
|
+
onAuthorizeSuccess(resAccessToken.data)
|
|
89
|
+
} catch (e) {
|
|
90
|
+
if (axios.isAxiosError(e)) {
|
|
91
|
+
onAuthorizeError(e)
|
|
92
|
+
}
|
|
93
|
+
return
|
|
94
|
+
}
|
|
95
|
+
|
|
77
96
|
const accessToken = _get(resAccessToken, 'data.access_token')
|
|
78
97
|
handleSetAccessToken(accessToken)
|
|
79
|
-
|
|
80
|
-
|
|
98
|
+
|
|
99
|
+
let profileResponse = null
|
|
100
|
+
|
|
101
|
+
try {
|
|
102
|
+
profileResponse = await getProfileData(accessToken)
|
|
103
|
+
onGetProfileDataSuccess(profileResponse.data)
|
|
104
|
+
} catch (e) {
|
|
105
|
+
if (axios.isAxiosError(e)) {
|
|
106
|
+
onGetProfileDataError(e)
|
|
107
|
+
}
|
|
108
|
+
return
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const profileSpecifiedData = _get(profileResponse, 'data.data')
|
|
81
112
|
const profileDataObj = {
|
|
82
113
|
id: profileSpecifiedData.id,
|
|
83
114
|
first_name: profileSpecifiedData.firstName,
|
|
84
115
|
last_name: profileSpecifiedData.lastName,
|
|
85
|
-
email: profileSpecifiedData.email
|
|
116
|
+
email: profileSpecifiedData.email,
|
|
86
117
|
}
|
|
87
118
|
if (typeof window !== 'undefined') {
|
|
88
|
-
window.localStorage.setItem(
|
|
119
|
+
window.localStorage.setItem(
|
|
120
|
+
'user_data',
|
|
121
|
+
JSON.stringify(profileDataObj)
|
|
122
|
+
)
|
|
89
123
|
window.localStorage.setItem('access_token', accessToken)
|
|
90
124
|
}
|
|
91
|
-
setUserExpired(false)
|
|
92
125
|
onLogin()
|
|
93
126
|
} catch (e) {
|
|
94
127
|
if (axios.isAxiosError(e)) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react'
|
|
2
|
+
import { AxiosError } from 'axios'
|
|
2
3
|
import Container from '@mui/material/Container'
|
|
3
4
|
import Alert from '@mui/material/Alert'
|
|
4
5
|
import { Elements } from '@stripe/react-stripe-js'
|
|
@@ -26,6 +27,9 @@ export interface IPaymentPage {
|
|
|
26
27
|
formTitle?: string;
|
|
27
28
|
errorText?: string;
|
|
28
29
|
onErrorClose?: () => void;
|
|
30
|
+
onGetPaymentDataSuccess: (value: any) => void;
|
|
31
|
+
onGetPaymentDataError: (value: AxiosError) => void;
|
|
32
|
+
onPaymentError: (value: AxiosError) => void;
|
|
29
33
|
}
|
|
30
34
|
|
|
31
35
|
const initialOrderValues: IOrderData = {
|
|
@@ -53,6 +57,9 @@ export const PaymentContainer = ({
|
|
|
53
57
|
errorText,
|
|
54
58
|
checkoutData,
|
|
55
59
|
onErrorClose = _identity,
|
|
60
|
+
onGetPaymentDataSuccess = () => {},
|
|
61
|
+
onGetPaymentDataError = () => {},
|
|
62
|
+
onPaymentError = () => {}
|
|
56
63
|
}: IPaymentPage) => {
|
|
57
64
|
const [reviewData, setReviewData] = useState(initialReviewValues)
|
|
58
65
|
const [orderData, setOrderData] = useState(initialOrderValues)
|
|
@@ -83,9 +90,11 @@ export const PaymentContainer = ({
|
|
|
83
90
|
currency: order_details?.currency,
|
|
84
91
|
}
|
|
85
92
|
setOrderData(orderData)
|
|
93
|
+
onGetPaymentDataSuccess(response.data)
|
|
86
94
|
}
|
|
87
95
|
} catch (e) {
|
|
88
96
|
setError(_get(e, 'response.data.message'))
|
|
97
|
+
onGetPaymentDataError(e.response)
|
|
89
98
|
}
|
|
90
99
|
})()
|
|
91
100
|
}, [checkoutData])
|
|
@@ -109,6 +118,7 @@ export const PaymentContainer = ({
|
|
|
109
118
|
}
|
|
110
119
|
} catch (e) {
|
|
111
120
|
setError(_get(e, 'response.data.message'))
|
|
121
|
+
onPaymentError(e.response)
|
|
112
122
|
}
|
|
113
123
|
}
|
|
114
124
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { FC } from 'react'
|
|
2
|
+
import { AxiosError } from 'axios'
|
|
2
3
|
import './style.css'
|
|
3
4
|
import { getProfileData, handleSetAccessToken, register } from '../../api'
|
|
4
5
|
import { Field, Form, Formik } from 'formik'
|
|
@@ -10,9 +11,15 @@ import { ENV } from '../../env'
|
|
|
10
11
|
interface Props {
|
|
11
12
|
onClose: () => void;
|
|
12
13
|
onRegister: () => void;
|
|
14
|
+
onGetProfileDataSuccess: (res: any) => void;
|
|
15
|
+
onGetProfileDataError: (e: AxiosError) => void;
|
|
13
16
|
}
|
|
14
17
|
|
|
15
|
-
export const RegisterModal: FC<Props> = ({
|
|
18
|
+
export const RegisterModal: FC<Props> = ({
|
|
19
|
+
onClose,
|
|
20
|
+
onGetProfileDataSuccess = () => {},
|
|
21
|
+
onGetProfileDataError = () => {},
|
|
22
|
+
}) => (
|
|
16
23
|
<div
|
|
17
24
|
style={{
|
|
18
25
|
display: 'flex',
|
|
@@ -63,8 +70,18 @@ export const RegisterModal: FC<Props> = ({ onClose }) => (
|
|
|
63
70
|
'data.data.attributes.access_token'
|
|
64
71
|
)
|
|
65
72
|
handleSetAccessToken(access_token)
|
|
66
|
-
|
|
67
|
-
|
|
73
|
+
|
|
74
|
+
let profileResponse = null
|
|
75
|
+
|
|
76
|
+
try {
|
|
77
|
+
profileResponse = await getProfileData(access_token)
|
|
78
|
+
onGetProfileDataSuccess(profileResponse.data)
|
|
79
|
+
} catch (e) {
|
|
80
|
+
onGetProfileDataError(e.response)
|
|
81
|
+
return
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const profileSpecifiedData = _get(profileResponse, 'data.data')
|
|
68
85
|
const profileDataObj = {
|
|
69
86
|
id: profileSpecifiedData.id,
|
|
70
87
|
first_name: profileSpecifiedData.firstName,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { useState, useEffect } from 'react'
|
|
2
|
+
import axios, { AxiosError } from 'axios'
|
|
2
3
|
import './style.css'
|
|
3
4
|
|
|
4
5
|
import { getTickets, addToCart, setCustomHeader } from '../../api'
|
|
@@ -166,6 +167,9 @@ export interface IGetTickets {
|
|
|
166
167
|
onAddToCartSuccess: (response: CartSuccess) => void;
|
|
167
168
|
getTicketsLabel?: string;
|
|
168
169
|
contentStyle?: React.CSSProperties;
|
|
170
|
+
onAddToCartError: (e: AxiosError) => void;
|
|
171
|
+
onGetTicketsSuccess: (response: any) => void;
|
|
172
|
+
onGetTicketsError: (e: AxiosError) => void;
|
|
169
173
|
}
|
|
170
174
|
|
|
171
175
|
export interface ITicket {
|
|
@@ -182,6 +186,9 @@ export const TicketsContainer = ({
|
|
|
182
186
|
eventId,
|
|
183
187
|
onAddToCartSuccess,
|
|
184
188
|
contentStyle = {},
|
|
189
|
+
onAddToCartError = () => {},
|
|
190
|
+
onGetTicketsSuccess = () => {},
|
|
191
|
+
onGetTicketsError = () => {},
|
|
185
192
|
}: IGetTickets) => {
|
|
186
193
|
const [selectedTickets, setSelectedTickets] = useState(
|
|
187
194
|
{} as ISelectedTickets
|
|
@@ -221,9 +228,12 @@ export const TicketsContainer = ({
|
|
|
221
228
|
item => _isObject(item)
|
|
222
229
|
)
|
|
223
230
|
setTickets(tickets)
|
|
231
|
+
onGetTicketsSuccess(response.data)
|
|
224
232
|
}
|
|
225
233
|
} catch (e) {
|
|
226
|
-
|
|
234
|
+
if (axios.isAxiosError(e)) {
|
|
235
|
+
onGetTicketsError(e)
|
|
236
|
+
}
|
|
227
237
|
} finally {
|
|
228
238
|
setIsLoading(false)
|
|
229
239
|
}
|
|
@@ -283,7 +293,9 @@ export const TicketsContainer = ({
|
|
|
283
293
|
})
|
|
284
294
|
}
|
|
285
295
|
} catch (e) {
|
|
286
|
-
|
|
296
|
+
if (axios.isAxiosError(e)) {
|
|
297
|
+
onAddToCartError(e)
|
|
298
|
+
}
|
|
287
299
|
} finally {
|
|
288
300
|
setHandleBookIsLoading(false)
|
|
289
301
|
}
|
package/src/index.ts
CHANGED
|
@@ -2,4 +2,5 @@ export { BillingInfoContainer } from './components/billing-info-container/index'
|
|
|
2
2
|
export { PaymentContainer } from './components/paymentContainer/index'
|
|
3
3
|
export { ConfirmationContainer } from './components/confirmationContainer/index'
|
|
4
4
|
export { TicketsContainer } from './components/ticketsContainer/index'
|
|
5
|
-
export { currencyNormalizerCreator, createFixedFloatNormalizer } from './normalizers'
|
|
5
|
+
export { currencyNormalizerCreator, createFixedFloatNormalizer } from './normalizers'
|
|
6
|
+
export { LoginModal } from './components/loginModal'
|
|
@@ -9,7 +9,7 @@ export interface IGroupItem {
|
|
|
9
9
|
className?: string;
|
|
10
10
|
required?: boolean;
|
|
11
11
|
component?: ReactNode | JSX.Element | HTMLElement;
|
|
12
|
-
onValidate
|
|
12
|
+
onValidate?: (value: any) => void;
|
|
13
13
|
|
|
14
14
|
// aditional props
|
|
15
15
|
[key: string]: any;
|
|
@@ -22,6 +22,7 @@ export interface IFieldData {
|
|
|
22
22
|
groupClassname?: string;
|
|
23
23
|
groupLabel?: string | JSX.Element | HTMLElement;
|
|
24
24
|
groupLabelClassName?: string;
|
|
25
|
+
id: number;
|
|
25
26
|
}
|
|
26
27
|
export interface IBillingInfoData {
|
|
27
28
|
id: number | string;
|
package/src/.DS_Store
DELETED
|
Binary file
|
package/src/components/.DS_Store
DELETED
|
Binary file
|