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
|
@@ -44,8 +44,7 @@ export const getInitialValues = (
|
|
|
44
44
|
const initialValues: IValues = {}
|
|
45
45
|
_forEach(results, groupItem => {
|
|
46
46
|
const { name, value } = groupItem
|
|
47
|
-
initialValues[name] =
|
|
48
|
-
value || propsInitialValues[name] || userValues[name] || ''
|
|
47
|
+
initialValues[name] = value || propsInitialValues[name] || userValues[name] || ''
|
|
49
48
|
})
|
|
50
49
|
|
|
51
50
|
// set logged in user as first ticket holder
|
|
@@ -53,8 +52,7 @@ export const getInitialValues = (
|
|
|
53
52
|
propsInitialValues.firstName || userValues.firstName || ''
|
|
54
53
|
initialValues['holderLastName-0'] =
|
|
55
54
|
propsInitialValues.lastName || userValues.lastName || ''
|
|
56
|
-
initialValues['holderEmail-0'] =
|
|
57
|
-
propsInitialValues.email || userValues.email || ''
|
|
55
|
+
initialValues['holderEmail-0'] = propsInitialValues.email || userValues.email || ''
|
|
58
56
|
|
|
59
57
|
return initialValues
|
|
60
58
|
}
|
|
@@ -100,22 +98,6 @@ interface ICheckoutBody {
|
|
|
100
98
|
};
|
|
101
99
|
}
|
|
102
100
|
|
|
103
|
-
interface IUserData {
|
|
104
|
-
id: string;
|
|
105
|
-
firstName: string;
|
|
106
|
-
lastName: string;
|
|
107
|
-
email: string;
|
|
108
|
-
city?: string;
|
|
109
|
-
country?: string;
|
|
110
|
-
countryId?: string;
|
|
111
|
-
phone?: string;
|
|
112
|
-
streetAddress?: string;
|
|
113
|
-
state?: string;
|
|
114
|
-
zip?: string;
|
|
115
|
-
zipCode?: string;
|
|
116
|
-
stateId?: string;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
101
|
interface IticketHolder {
|
|
120
102
|
first_name?: string;
|
|
121
103
|
last_name?: string;
|
|
@@ -123,34 +105,14 @@ interface IticketHolder {
|
|
|
123
105
|
email?: string;
|
|
124
106
|
}
|
|
125
107
|
|
|
126
|
-
export const setLoggedUserData = (data: IUserData) => ({
|
|
127
|
-
id: data.id,
|
|
128
|
-
first_name: data.firstName,
|
|
129
|
-
last_name: data.lastName,
|
|
130
|
-
email: data.email,
|
|
131
|
-
confirmEmail: data.email,
|
|
132
|
-
city: data?.city || '',
|
|
133
|
-
country: data?.countryId || data?.country || '',
|
|
134
|
-
phone: data?.phone || '',
|
|
135
|
-
street_address: data?.streetAddress || '',
|
|
136
|
-
state: data?.stateId || '',
|
|
137
|
-
zip: data?.zip || data?.zipCode || '',
|
|
138
|
-
})
|
|
139
|
-
|
|
140
108
|
export const createCheckoutDataBody = (
|
|
141
109
|
ticketsQuantity: number,
|
|
142
110
|
values: IValues = {},
|
|
143
111
|
logedInValues: ILoggedInValues = {},
|
|
144
112
|
includeDob = false
|
|
145
113
|
): ICheckoutBody => {
|
|
146
|
-
const {
|
|
147
|
-
|
|
148
|
-
lastName,
|
|
149
|
-
holderAge,
|
|
150
|
-
confirmEmail,
|
|
151
|
-
confirmPassword,
|
|
152
|
-
...restValues
|
|
153
|
-
} = values
|
|
114
|
+
const { firstName, lastName, holderAge, confirmEmail, confirmPassword, ...restValues } =
|
|
115
|
+
values
|
|
154
116
|
|
|
155
117
|
const holders = []
|
|
156
118
|
let ticket_holders: IticketHolder[] = []
|
|
@@ -162,9 +124,7 @@ export const createCheckoutDataBody = (
|
|
|
162
124
|
holders.push(individualHolder)
|
|
163
125
|
}
|
|
164
126
|
|
|
165
|
-
const filteredHolders = holders.filter(
|
|
166
|
-
holder => Object.entries(holder).length > 0
|
|
167
|
-
)
|
|
127
|
+
const filteredHolders = holders.filter(holder => Object.entries(holder).length > 0)
|
|
168
128
|
ticket_holders = filteredHolders.map((item, index) => ({
|
|
169
129
|
first_name: !index
|
|
170
130
|
? item[`holderFirstName-${index}`] || logedInValues.firstNameLogged || ''
|
|
@@ -214,10 +174,7 @@ export const getValidateFunctions = (
|
|
|
214
174
|
const validationFunctions: any[] = []
|
|
215
175
|
|
|
216
176
|
if (element.required) {
|
|
217
|
-
if (
|
|
218
|
-
element.name !== 'state' ||
|
|
219
|
-
(element.name === 'state' && states.length)
|
|
220
|
-
) {
|
|
177
|
+
if (element.name !== 'state' || (element.name === 'state' && states.length)) {
|
|
221
178
|
validationFunctions.push(requiredValidator)
|
|
222
179
|
}
|
|
223
180
|
}
|
|
@@ -234,17 +191,13 @@ export const getValidateFunctions = (
|
|
|
234
191
|
|
|
235
192
|
if (element.name === 'confirmEmail') {
|
|
236
193
|
const isSameEmail = (confirmEmail?: string) =>
|
|
237
|
-
values.email !== confirmEmail
|
|
238
|
-
? 'Please confirm your email address correctly'
|
|
239
|
-
: null
|
|
194
|
+
values.email !== confirmEmail ? 'Please confirm your email address correctly' : null
|
|
240
195
|
validationFunctions.push(isSameEmail)
|
|
241
196
|
}
|
|
242
197
|
|
|
243
198
|
if (element.name === 'confirmPassword') {
|
|
244
199
|
const isSame = (confirmPassword?: string) =>
|
|
245
|
-
values.password !== confirmPassword
|
|
246
|
-
? 'Password confirmation does not match'
|
|
247
|
-
: null
|
|
200
|
+
values.password !== confirmPassword ? 'Password confirmation does not match' : null
|
|
248
201
|
validationFunctions.push(isSame)
|
|
249
202
|
}
|
|
250
203
|
|
|
@@ -258,10 +211,7 @@ export const assingUniqueIds = (data: any): any => {
|
|
|
258
211
|
|
|
259
212
|
return _map(data, (item: any) => {
|
|
260
213
|
_forEach(item, (itemValue: string, key) => {
|
|
261
|
-
if (
|
|
262
|
-
_isArray(itemValue) &&
|
|
263
|
-
!itemValue.some(item => typeof item === 'string')
|
|
264
|
-
) {
|
|
214
|
+
if (_isArray(itemValue) && !itemValue.some(item => typeof item === 'string')) {
|
|
265
215
|
item[key] = assingUniqueIds(itemValue)
|
|
266
216
|
}
|
|
267
217
|
})
|
|
@@ -28,13 +28,12 @@ export const CheckboxField = ({
|
|
|
28
28
|
uniqueId,
|
|
29
29
|
dateFormat,
|
|
30
30
|
datePlaceholder,
|
|
31
|
+
isCountryCodeEditable,
|
|
31
32
|
...rest
|
|
32
33
|
}: ICheckboxField & IOtherProps) => {
|
|
33
34
|
const customTheme: any = useTheme()
|
|
34
35
|
return (
|
|
35
|
-
<FormControl
|
|
36
|
-
error={!!(rest?.form?.errors && rest.form.errors[field?.name ?? ''])}
|
|
37
|
-
>
|
|
36
|
+
<FormControl error={!!(rest?.form?.errors && rest.form.errors[field?.name ?? ''])}>
|
|
38
37
|
<FormGroup>
|
|
39
38
|
<FormControlLabel
|
|
40
39
|
control={<Checkbox {...field} {...rest} />}
|
|
@@ -44,7 +43,7 @@ export const CheckboxField = ({
|
|
|
44
43
|
}}
|
|
45
44
|
/>
|
|
46
45
|
</FormGroup>
|
|
47
|
-
{
|
|
46
|
+
{rest?.form?.errors && rest.form.errors[field?.name ?? ''] ? (
|
|
48
47
|
<FormHelperText>Required</FormHelperText>
|
|
49
48
|
) : null}
|
|
50
49
|
</FormControl>
|
|
@@ -108,11 +108,7 @@ export const CustomField = ({
|
|
|
108
108
|
>
|
|
109
109
|
{isSelectField
|
|
110
110
|
? _map(selectOptions, option => (
|
|
111
|
-
<option
|
|
112
|
-
key={option.value}
|
|
113
|
-
value={option.value}
|
|
114
|
-
disabled={option.disabled}
|
|
115
|
-
>
|
|
111
|
+
<option key={option.value} value={option.value} disabled={option.disabled}>
|
|
116
112
|
{option.label}
|
|
117
113
|
</option>
|
|
118
114
|
))
|
|
@@ -73,11 +73,7 @@ export const NativeSelectField = ({
|
|
|
73
73
|
}}
|
|
74
74
|
>
|
|
75
75
|
{_map(selectOptions, option => (
|
|
76
|
-
<option
|
|
77
|
-
key={option.value}
|
|
78
|
-
value={option.value}
|
|
79
|
-
disabled={option.disabled}
|
|
80
|
-
>
|
|
76
|
+
<option key={option.value} value={option.value} disabled={option.disabled}>
|
|
81
77
|
{option.label}
|
|
82
78
|
</option>
|
|
83
79
|
))}
|
|
@@ -88,9 +88,7 @@ function SelectField({
|
|
|
88
88
|
>
|
|
89
89
|
{options?.map((option: ISelectOption) => (
|
|
90
90
|
<MenuItem key={option.label} value={option.value}>
|
|
91
|
-
{isMultiple && (
|
|
92
|
-
<Checkbox checked={value.indexOf(option.value) > -1} />
|
|
93
|
-
)}
|
|
91
|
+
{isMultiple && <Checkbox checked={value.indexOf(option.value) > -1} />}
|
|
94
92
|
<ListItemText primary={option.label} />
|
|
95
93
|
</MenuItem>
|
|
96
94
|
))}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/* eslint-disable max-len */
|
|
2
|
-
/* eslint-disable react/no-unescaped-entities */
|
|
3
2
|
import './style.css'
|
|
4
3
|
|
|
5
4
|
import Modal from '@mui/material/Modal'
|
|
@@ -19,7 +18,12 @@ export interface IShareButton {
|
|
|
19
18
|
mainLabel: string;
|
|
20
19
|
subLabel: string;
|
|
21
20
|
platform: string;
|
|
22
|
-
shareData:
|
|
21
|
+
shareData: {
|
|
22
|
+
quote?: string;
|
|
23
|
+
url?: string;
|
|
24
|
+
title?: string;
|
|
25
|
+
appId?: string;
|
|
26
|
+
};
|
|
23
27
|
}
|
|
24
28
|
|
|
25
29
|
export interface IConfirmationLabels {
|
|
@@ -37,7 +41,7 @@ export interface IConfirmationPage {
|
|
|
37
41
|
showDefaultShareButtons: boolean;
|
|
38
42
|
messengerAppId: string;
|
|
39
43
|
shareButtons: IShareButton[];
|
|
40
|
-
onGetConfirmationDataSuccess: (res:
|
|
44
|
+
onGetConfirmationDataSuccess: (res: ICheckoutCompleteData) => void;
|
|
41
45
|
onGetConfirmationDataError: (e: AxiosError) => void;
|
|
42
46
|
onLinkCopied: () => void;
|
|
43
47
|
orderHash?: string;
|
|
@@ -65,7 +69,7 @@ export const ConfirmationContainer = ({
|
|
|
65
69
|
showPricingNoteSection = false,
|
|
66
70
|
}: IConfirmationPage) => {
|
|
67
71
|
const inputRef = useRef(null)
|
|
68
|
-
const [data, setData] = useState<
|
|
72
|
+
const [data, setData] = useState<ICheckoutCompleteData | null>(null)
|
|
69
73
|
const dataEncoded = (isBrowser && window.localStorage.getItem('checkoutData')) || ''
|
|
70
74
|
const dataDecoded = dataEncoded ? JSON.parse(dataEncoded) : { hash: orderHash }
|
|
71
75
|
const { hash } = dataDecoded
|
|
@@ -75,19 +79,19 @@ export const ConfirmationContainer = ({
|
|
|
75
79
|
(async () => {
|
|
76
80
|
if (hash) {
|
|
77
81
|
try {
|
|
78
|
-
const
|
|
79
|
-
const data =
|
|
80
|
-
data.personal_share_sales = data.personal_share_sales.map(
|
|
82
|
+
const confirmationDataResponse = await getConfirmationData(hash)
|
|
83
|
+
const data = confirmationDataResponse.data.attributes
|
|
84
|
+
data.personal_share_sales = data.personal_share_sales.map(salesItem => {
|
|
81
85
|
const salesData: IReferralPromotion = {
|
|
82
|
-
label: `If your friends buy ${
|
|
86
|
+
label: `If your friends buy ${salesItem.sales} tickets`,
|
|
83
87
|
price: '',
|
|
84
88
|
}
|
|
85
|
-
if (
|
|
89
|
+
if (salesItem.price === 0) {
|
|
86
90
|
salesData.subLabel = 'Your ticket becomes'
|
|
87
91
|
salesData.price = 'FREE!'
|
|
88
92
|
} else {
|
|
89
93
|
salesData.subLabel = 'Your ticket goes down to'
|
|
90
|
-
salesData.price = data.currency.symbol +
|
|
94
|
+
salesData.price = data.currency.symbol + Number(salesItem.price).toFixed(2)
|
|
91
95
|
}
|
|
92
96
|
|
|
93
97
|
return salesData
|
|
@@ -97,13 +101,13 @@ export const ConfirmationContainer = ({
|
|
|
97
101
|
price: data.currency.symbol + data.product_price?.toFixed(2),
|
|
98
102
|
})
|
|
99
103
|
setData(data)
|
|
100
|
-
onGetConfirmationDataSuccess(
|
|
104
|
+
onGetConfirmationDataSuccess(confirmationDataResponse.data.attributes)
|
|
101
105
|
} catch (error) {
|
|
102
106
|
onGetConfirmationDataError(error.response)
|
|
103
107
|
}
|
|
104
108
|
}
|
|
105
109
|
})()
|
|
106
|
-
}, [])
|
|
110
|
+
}, [hash])
|
|
107
111
|
|
|
108
112
|
const [showCopyModal, setShowCopyModal] = useState(false)
|
|
109
113
|
|
|
@@ -112,7 +116,10 @@ export const ConfirmationContainer = ({
|
|
|
112
116
|
}
|
|
113
117
|
|
|
114
118
|
const onChangeShareLink = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
115
|
-
const newData = {
|
|
119
|
+
const newData = {
|
|
120
|
+
...data,
|
|
121
|
+
personal_share_link: e.target.value,
|
|
122
|
+
} as ICheckoutCompleteData
|
|
116
123
|
setData(newData)
|
|
117
124
|
}
|
|
118
125
|
const {
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
GetNetverifyUrlResponseData,
|
|
15
15
|
VerificationStatusResponseData,
|
|
16
16
|
} from '../../types/verification'
|
|
17
|
-
import { getQueryVariable, isJson } from '../../utils'
|
|
17
|
+
import { getQueryVariable, isBrowser, isJson } from '../../utils'
|
|
18
18
|
import Modal from '../common/ModalComponent'
|
|
19
19
|
import { VERIFICATION_MESSAGES, VERIFICATION_STATUSES } from './constants'
|
|
20
20
|
|
|
@@ -48,9 +48,7 @@ export const IDVerification = (props: IDVerificationProps) => {
|
|
|
48
48
|
} = props
|
|
49
49
|
|
|
50
50
|
const [loadingStatus, setLoadingStatus] = useState(true)
|
|
51
|
-
const [verificationStatus, setVerificationStatus] = useState<string | null>(
|
|
52
|
-
null
|
|
53
|
-
)
|
|
51
|
+
const [verificationStatus, setVerificationStatus] = useState<string | null>(null)
|
|
54
52
|
const [showModal, setShowModal] = useState(false)
|
|
55
53
|
const [netverifyUrl, setNetverifyUrl] = useState<string | null>(null)
|
|
56
54
|
const [modalData, setModalData] = useState({
|
|
@@ -171,9 +169,7 @@ export const IDVerification = (props: IDVerificationProps) => {
|
|
|
171
169
|
getVerificationStatus()
|
|
172
170
|
}, 10000)
|
|
173
171
|
} catch (error) {
|
|
174
|
-
if (
|
|
175
|
-
error.response?.data?.message === VERIFICATION_MESSAGES.WRONG_CUSTOMER
|
|
176
|
-
) {
|
|
172
|
+
if (error.response?.data?.message === VERIFICATION_MESSAGES.WRONG_CUSTOMER) {
|
|
177
173
|
setVerificationStatus(VERIFICATION_STATUSES.WRONG_CUSTOMER)
|
|
178
174
|
setModalData({
|
|
179
175
|
displaModal: true,
|
|
@@ -199,18 +195,12 @@ export const IDVerification = (props: IDVerificationProps) => {
|
|
|
199
195
|
}
|
|
200
196
|
|
|
201
197
|
useEffect(() => {
|
|
202
|
-
const isWindowDefined = typeof window !== 'undefined'
|
|
203
198
|
const orderHash = getQueryVariable('order_hash')
|
|
204
199
|
|
|
205
|
-
if (
|
|
206
|
-
const checkoutData = JSON.parse(
|
|
207
|
-
window.localStorage.getItem('checkoutData') || '{}'
|
|
208
|
-
)
|
|
200
|
+
if (isBrowser) {
|
|
201
|
+
const checkoutData = JSON.parse(window.localStorage.getItem('checkoutData') || '{}')
|
|
209
202
|
if (_isEmpty(checkoutData) && orderHash) {
|
|
210
|
-
window.localStorage.setItem(
|
|
211
|
-
'checkoutData',
|
|
212
|
-
JSON.stringify({ hash: orderHash })
|
|
213
|
-
)
|
|
203
|
+
window.localStorage.setItem('checkoutData', JSON.stringify({ hash: orderHash }))
|
|
214
204
|
}
|
|
215
205
|
}
|
|
216
206
|
}, [])
|
|
@@ -226,9 +216,7 @@ export const IDVerification = (props: IDVerificationProps) => {
|
|
|
226
216
|
</div>
|
|
227
217
|
)}
|
|
228
218
|
{verificationStatus === VERIFICATION_STATUSES.PENDING && (
|
|
229
|
-
<div className="verify-message">
|
|
230
|
-
{VERIFICATION_MESSAGES.PENDING}
|
|
231
|
-
</div>
|
|
219
|
+
<div className="verify-message">{VERIFICATION_MESSAGES.PENDING}</div>
|
|
232
220
|
)}
|
|
233
221
|
{!isAccountVerifiedOrPending && (
|
|
234
222
|
<Button
|
|
@@ -5,11 +5,7 @@ import _identity from 'lodash/identity'
|
|
|
5
5
|
import React, { FC, useState } from 'react'
|
|
6
6
|
|
|
7
7
|
import { authorize, getProfileData } from '../../api'
|
|
8
|
-
import {
|
|
9
|
-
combineValidators,
|
|
10
|
-
emailValidator,
|
|
11
|
-
requiredValidator,
|
|
12
|
-
} from '../../validators'
|
|
8
|
+
import { combineValidators, emailValidator, requiredValidator } from '../../validators'
|
|
13
9
|
import { CustomField } from '../common'
|
|
14
10
|
|
|
15
11
|
export interface ILoginFormProps {
|
|
@@ -30,34 +26,34 @@ export interface ILoginFormProps {
|
|
|
30
26
|
showSignUpButton?: boolean;
|
|
31
27
|
}
|
|
32
28
|
|
|
33
|
-
interface IUserData {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
29
|
+
// interface IUserData {
|
|
30
|
+
// id: string;
|
|
31
|
+
// firstName: string;
|
|
32
|
+
// lastName: string;
|
|
33
|
+
// email: string;
|
|
34
|
+
// city?: string;
|
|
35
|
+
// country?: string;
|
|
36
|
+
// countryId?: string;
|
|
37
|
+
// phone?: string;
|
|
38
|
+
// streetAddress?: string;
|
|
39
|
+
// state?: string;
|
|
40
|
+
// zip?: string;
|
|
41
|
+
// zipCode?: string;
|
|
42
|
+
// stateId?: string;
|
|
43
|
+
// }
|
|
48
44
|
|
|
49
|
-
export const setLoggedUserData = (data:
|
|
45
|
+
export const setLoggedUserData = (data: IProfileData) => ({
|
|
50
46
|
id: data.id,
|
|
51
47
|
first_name: data.firstName,
|
|
52
48
|
last_name: data.lastName,
|
|
53
49
|
email: data.email,
|
|
54
50
|
confirmEmail: data.email,
|
|
55
51
|
city: data?.city || '',
|
|
56
|
-
country: data?.countryId ||
|
|
52
|
+
country: data?.countryId || '',
|
|
57
53
|
phone: data?.phone || '',
|
|
58
54
|
street_address: data?.streetAddress || '',
|
|
59
55
|
state: data?.stateId || '',
|
|
60
|
-
zip: data?.
|
|
56
|
+
zip: data?.zipCode || '',
|
|
61
57
|
})
|
|
62
58
|
|
|
63
59
|
export const LoginForm: FC<ILoginFormProps> = ({
|
|
@@ -79,7 +75,7 @@ export const LoginForm: FC<ILoginFormProps> = ({
|
|
|
79
75
|
}) => {
|
|
80
76
|
const [error, setError] = useState('')
|
|
81
77
|
return (
|
|
82
|
-
<div className=
|
|
78
|
+
<div className="login-modal">
|
|
83
79
|
<Formik
|
|
84
80
|
initialValues={{ email: '', password: '' }}
|
|
85
81
|
onSubmit={async ({ email, password }) => {
|
|
@@ -89,7 +85,7 @@ export const LoginForm: FC<ILoginFormProps> = ({
|
|
|
89
85
|
let profileResponse = null
|
|
90
86
|
try {
|
|
91
87
|
profileResponse = await getProfileData()
|
|
92
|
-
onGetProfileDataSuccess(_get(profileResponse, 'data
|
|
88
|
+
onGetProfileDataSuccess(_get(profileResponse, 'data'))
|
|
93
89
|
} catch (e) {
|
|
94
90
|
if (axios.isAxiosError(e)) {
|
|
95
91
|
onGetProfileDataError(e)
|
|
@@ -97,17 +93,14 @@ export const LoginForm: FC<ILoginFormProps> = ({
|
|
|
97
93
|
return
|
|
98
94
|
}
|
|
99
95
|
|
|
100
|
-
const profileSpecifiedData = _get(profileResponse, 'data
|
|
96
|
+
const profileSpecifiedData = _get(profileResponse, 'data')
|
|
101
97
|
const profileDataObj = setLoggedUserData(profileSpecifiedData)
|
|
102
98
|
if (typeof window !== 'undefined') {
|
|
103
|
-
window.localStorage.setItem(
|
|
104
|
-
'user_data',
|
|
105
|
-
JSON.stringify(profileDataObj)
|
|
106
|
-
)
|
|
99
|
+
window.localStorage.setItem('user_data', JSON.stringify(profileDataObj))
|
|
107
100
|
const event = new window.CustomEvent('tf-login')
|
|
108
101
|
window.document.dispatchEvent(event)
|
|
109
102
|
}
|
|
110
|
-
onLoginSuccess(_get(authRes, 'data
|
|
103
|
+
onLoginSuccess(_get(authRes, 'data'))
|
|
111
104
|
} catch (e) {
|
|
112
105
|
if (axios.isAxiosError(e)) {
|
|
113
106
|
const error = e?.response?.data?.message || 'Error'
|
|
@@ -135,8 +128,8 @@ export const LoginForm: FC<ILoginFormProps> = ({
|
|
|
135
128
|
<div className="server_auth__error">{error}</div>
|
|
136
129
|
{alreadyHasUser && (
|
|
137
130
|
<p className="info-text-for-login">
|
|
138
|
-
It appears this email is already attached to an account. Please
|
|
139
|
-
|
|
131
|
+
It appears this email is already attached to an account. Please log in
|
|
132
|
+
here to complete your registration.
|
|
140
133
|
</p>
|
|
141
134
|
)}
|
|
142
135
|
{userExpired && (
|
|
@@ -151,10 +144,7 @@ export const LoginForm: FC<ILoginFormProps> = ({
|
|
|
151
144
|
label="Email"
|
|
152
145
|
type="email"
|
|
153
146
|
component={CustomField}
|
|
154
|
-
validate={combineValidators(
|
|
155
|
-
requiredValidator,
|
|
156
|
-
emailValidator
|
|
157
|
-
)}
|
|
147
|
+
validate={combineValidators(requiredValidator, emailValidator)}
|
|
158
148
|
/>
|
|
159
149
|
</div>
|
|
160
150
|
<div className="login-modal-body__password">
|
|
@@ -171,10 +161,7 @@ export const LoginForm: FC<ILoginFormProps> = ({
|
|
|
171
161
|
</div>
|
|
172
162
|
{showForgotPasswordButton && (
|
|
173
163
|
<div className="forgot-password">
|
|
174
|
-
<span
|
|
175
|
-
aria-hidden="true"
|
|
176
|
-
onClick={onForgotPasswordButtonClick}
|
|
177
|
-
>
|
|
164
|
+
<span aria-hidden="true" onClick={onForgotPasswordButtonClick}>
|
|
178
165
|
Forgot password?
|
|
179
166
|
</span>
|
|
180
167
|
</div>
|
|
@@ -5,14 +5,11 @@ import Box from '@mui/material/Box'
|
|
|
5
5
|
import Modal from '@mui/material/Modal'
|
|
6
6
|
import axios, { AxiosError } from 'axios'
|
|
7
7
|
import { Field, Form, Formik } from 'formik'
|
|
8
|
-
import _get from 'lodash/get'
|
|
9
8
|
import _identity from 'lodash/identity'
|
|
10
9
|
import React, { FC, useState } from 'react'
|
|
11
10
|
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
getProfileData,
|
|
15
|
-
} from '../../api'
|
|
11
|
+
import { authorize, getProfileData } from '../../api'
|
|
12
|
+
import { isBrowser, setLoggedUserData } from '../../utils'
|
|
16
13
|
import { requiredValidator } from '../../validators'
|
|
17
14
|
import { PoweredBy } from '../common/PoweredBy'
|
|
18
15
|
|
|
@@ -44,35 +41,6 @@ const style: React.CSSProperties = {
|
|
|
44
41
|
border: '1px solid white',
|
|
45
42
|
outline: 'none',
|
|
46
43
|
}
|
|
47
|
-
interface IUserData {
|
|
48
|
-
id: string;
|
|
49
|
-
firstName: string;
|
|
50
|
-
lastName: string;
|
|
51
|
-
email: string;
|
|
52
|
-
city?: string;
|
|
53
|
-
country?: string;
|
|
54
|
-
countryId?: string;
|
|
55
|
-
phone?: string;
|
|
56
|
-
streetAddress?: string;
|
|
57
|
-
state?: string;
|
|
58
|
-
zip?: string;
|
|
59
|
-
zipCode?: string;
|
|
60
|
-
stateId?: string;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export const setLoggedUserData = (data: IUserData) => ({
|
|
64
|
-
id: data.id,
|
|
65
|
-
first_name: data.firstName,
|
|
66
|
-
last_name: data.lastName,
|
|
67
|
-
email: data.email,
|
|
68
|
-
confirmEmail: data.email,
|
|
69
|
-
city: data?.city || '',
|
|
70
|
-
country: data?.countryId || data?.country || '',
|
|
71
|
-
phone: data?.phone || '',
|
|
72
|
-
street_address: data?.streetAddress || '',
|
|
73
|
-
state: data?.stateId || '',
|
|
74
|
-
zip: data?.zip || data?.zipCode || '',
|
|
75
|
-
})
|
|
76
44
|
|
|
77
45
|
export const LoginModal: FC<Props> = ({
|
|
78
46
|
onClose,
|
|
@@ -117,13 +85,10 @@ export const LoginModal: FC<Props> = ({
|
|
|
117
85
|
return
|
|
118
86
|
}
|
|
119
87
|
|
|
120
|
-
const profileSpecifiedData =
|
|
88
|
+
const profileSpecifiedData = profileResponse.data
|
|
121
89
|
const profileDataObj = setLoggedUserData(profileSpecifiedData)
|
|
122
|
-
if (
|
|
123
|
-
window.localStorage.setItem(
|
|
124
|
-
'user_data',
|
|
125
|
-
JSON.stringify(profileDataObj)
|
|
126
|
-
)
|
|
90
|
+
if (isBrowser) {
|
|
91
|
+
window.localStorage.setItem('user_data', JSON.stringify(profileDataObj))
|
|
127
92
|
const event = new window.CustomEvent('tf-login')
|
|
128
93
|
window.document.dispatchEvent(event)
|
|
129
94
|
}
|
|
@@ -141,18 +106,21 @@ export const LoginModal: FC<Props> = ({
|
|
|
141
106
|
{props => (
|
|
142
107
|
<Form onSubmit={props.handleSubmit}>
|
|
143
108
|
<div className="modal-title">Login</div>
|
|
144
|
-
<div className=
|
|
109
|
+
<div className="login-logo-container">
|
|
145
110
|
<img
|
|
146
111
|
className="login-logo-tff"
|
|
147
|
-
src={
|
|
112
|
+
src={
|
|
113
|
+
logo ||
|
|
114
|
+
'https://www.ticketfairy.com/resources/images/logo-ttf-black.svg'
|
|
115
|
+
}
|
|
148
116
|
alt="logo"
|
|
149
117
|
/>
|
|
150
118
|
</div>
|
|
151
119
|
<div className="server_auth__error">{error}</div>
|
|
152
120
|
{alreadyHasUser && (
|
|
153
121
|
<p className="info-text-for-login">
|
|
154
|
-
It appears this email is already attached to an account.
|
|
155
|
-
|
|
122
|
+
It appears this email is already attached to an account. Please log in
|
|
123
|
+
here to complete your registration.
|
|
156
124
|
</p>
|
|
157
125
|
)}
|
|
158
126
|
{userExpired && (
|
|
@@ -194,12 +162,16 @@ export const LoginModal: FC<Props> = ({
|
|
|
194
162
|
</div>
|
|
195
163
|
{showForgotPasswordButton && (
|
|
196
164
|
<div className="forgot-password">
|
|
197
|
-
<span aria-hidden="true" onClick={onForgotPassword}>
|
|
165
|
+
<span aria-hidden="true" onClick={onForgotPassword}>
|
|
166
|
+
Forgot password?
|
|
167
|
+
</span>
|
|
198
168
|
</div>
|
|
199
169
|
)}
|
|
200
170
|
{showSignUpButton && (
|
|
201
171
|
<div className="forgot-password">
|
|
202
|
-
<span aria-hidden="true" onClick={onSignup}>
|
|
172
|
+
<span aria-hidden="true" onClick={onSignup}>
|
|
173
|
+
Sign up
|
|
174
|
+
</span>
|
|
203
175
|
</div>
|
|
204
176
|
)}
|
|
205
177
|
{showPoweredByImage ? <PoweredBy /> : null}
|
|
@@ -73,7 +73,7 @@ export const MyTicketsContainer = ({
|
|
|
73
73
|
const response = await getOrders(page, limit, filter)
|
|
74
74
|
onGetOrdersSuccess(response)
|
|
75
75
|
|
|
76
|
-
const data = _get(response, 'data.
|
|
76
|
+
const data = _get(response, 'data.attributes')
|
|
77
77
|
data.page -= 1
|
|
78
78
|
|
|
79
79
|
setData(data)
|
|
@@ -108,7 +108,7 @@ export const OrderDetailsContainer = ({
|
|
|
108
108
|
const response = await getOrderDetails(String(orderId))
|
|
109
109
|
onGetOrdersSuccess(response)
|
|
110
110
|
|
|
111
|
-
const data = _get(response, 'data.
|
|
111
|
+
const data = _get(response, 'data.attributes')
|
|
112
112
|
setData(data)
|
|
113
113
|
} catch (error) {
|
|
114
114
|
onGetOrdersError(error)
|
|
@@ -154,7 +154,7 @@ export const OrderDetailsContainer = ({
|
|
|
154
154
|
const response = await getOrderDetails(orderId)
|
|
155
155
|
onGetOrdersSuccess(response)
|
|
156
156
|
|
|
157
|
-
const data = _get(response, 'data.
|
|
157
|
+
const data = _get(response, 'data.attributes')
|
|
158
158
|
const updatedData = { ...data }
|
|
159
159
|
updatedData?.tickets?.forEach((ticket: ITicketTypes) => {
|
|
160
160
|
if (ticket.hash === activeTicket.hash) {
|
|
@@ -194,7 +194,7 @@ export const OrderDetailsContainer = ({
|
|
|
194
194
|
const response = await getOrderDetails(orderId)
|
|
195
195
|
onGetOrdersSuccess(response)
|
|
196
196
|
|
|
197
|
-
const data = _get(response, 'data.
|
|
197
|
+
const data = _get(response, 'data.attributes')
|
|
198
198
|
const updatedData = { ...data }
|
|
199
199
|
updatedData?.tickets?.forEach((ticket: ITicketTypes) => {
|
|
200
200
|
if (ticket.hash === activeTicket.hash) {
|