tf-checkout-react 1.0.51 → 1.0.55
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 +5 -1
- package/dist/components/common/CustomField.d.ts +1 -1
- package/dist/tf-checkout-react.cjs.development.js +78 -53
- 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 +78 -53
- package/dist/tf-checkout-react.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/billing-info-container/index.tsx +58 -80
- package/src/components/billing-info-container/utils.ts +9 -1
- package/src/components/common/CustomField.tsx +2 -4
- package/src/components/common/SelectField.tsx +1 -1
- package/src/components/paymentContainer/index.tsx +1 -0
- package/src/components/stripePayment/index.tsx +31 -3
- package/src/.DS_Store +0 -0
- package/src/components/.DS_Store +0 -0
package/package.json
CHANGED
|
@@ -238,7 +238,6 @@ export const BillingInfoContainer = ({
|
|
|
238
238
|
_get(userData, 'last_name', '') || _get(userValues, 'last_name', '')
|
|
239
239
|
|
|
240
240
|
const showDOB = getQueryVariable('age_required') === 'true'
|
|
241
|
-
const showTicketHolderName = getQueryVariable('names_required') === 'true'
|
|
242
241
|
const eventId = getQueryVariable('event_id')
|
|
243
242
|
const optedInFieldValue: boolean = _get(cartInfoData, 'optedIn', false)
|
|
244
243
|
const hideTtfOptIn: boolean = _get(cartInfoData, 'hide_ttf_opt_in', true)
|
|
@@ -369,7 +368,16 @@ export const BillingInfoContainer = ({
|
|
|
369
368
|
return
|
|
370
369
|
}
|
|
371
370
|
|
|
372
|
-
const
|
|
371
|
+
const checkoutBodyForRegistration = createCheckoutDataBody(
|
|
372
|
+
ticketsQuantity.length,
|
|
373
|
+
values,
|
|
374
|
+
{ emailLogged, firstNameLogged, lastNameLogged },
|
|
375
|
+
showDOB
|
|
376
|
+
)
|
|
377
|
+
const bodyFormData = createRegisterFormData(
|
|
378
|
+
values,
|
|
379
|
+
checkoutBodyForRegistration
|
|
380
|
+
)
|
|
373
381
|
|
|
374
382
|
let access_token_register = null
|
|
375
383
|
try {
|
|
@@ -493,45 +501,16 @@ export const BillingInfoContainer = ({
|
|
|
493
501
|
)}
|
|
494
502
|
{_map(dataWithUniqueIds, item => {
|
|
495
503
|
const { label, labelClassName, fields } = item
|
|
496
|
-
if (
|
|
497
|
-
label === 'Ticket Holders' &&
|
|
498
|
-
!showTicketHolderName &&
|
|
499
|
-
!showDOB
|
|
500
|
-
) {
|
|
501
|
-
return null
|
|
502
|
-
}
|
|
503
504
|
return (
|
|
504
505
|
<React.Fragment key={item.uniqueId}>
|
|
505
506
|
<p className={labelClassName}>{label}</p>
|
|
506
507
|
{_map(fields, group => {
|
|
507
|
-
const {
|
|
508
|
-
groupClassname,
|
|
509
|
-
groupItems,
|
|
510
|
-
groupLabel,
|
|
511
|
-
groupLabelClassName,
|
|
512
|
-
} = group
|
|
508
|
+
const { groupClassname, groupItems } = group
|
|
513
509
|
return (
|
|
514
510
|
<React.Fragment key={group.uniqueId}>
|
|
515
|
-
{!isLoggedIn && (
|
|
516
|
-
<div className={groupLabelClassName}>
|
|
517
|
-
{groupLabel}
|
|
518
|
-
</div>
|
|
519
|
-
)}
|
|
520
511
|
<div className={groupClassname}>
|
|
521
512
|
{_map(
|
|
522
513
|
groupItems.filter(el => {
|
|
523
|
-
if (
|
|
524
|
-
el.name === 'holderFirstName' &&
|
|
525
|
-
!showTicketHolderName
|
|
526
|
-
) {
|
|
527
|
-
return false
|
|
528
|
-
}
|
|
529
|
-
if (
|
|
530
|
-
el.name === 'holderLastName' &&
|
|
531
|
-
!showTicketHolderName
|
|
532
|
-
) {
|
|
533
|
-
return false
|
|
534
|
-
}
|
|
535
514
|
if (el.name === 'holderAge' && !showDOB) {
|
|
536
515
|
return false
|
|
537
516
|
}
|
|
@@ -541,9 +520,12 @@ export const BillingInfoContainer = ({
|
|
|
541
520
|
return true
|
|
542
521
|
}),
|
|
543
522
|
element =>
|
|
544
|
-
[
|
|
545
|
-
|
|
546
|
-
|
|
523
|
+
[
|
|
524
|
+
'password',
|
|
525
|
+
'confirmPassword',
|
|
526
|
+
'password-info',
|
|
527
|
+
].includes(element.name) &&
|
|
528
|
+
isLoggedIn ? null : (
|
|
547
529
|
<React.Fragment key={element.uniqueId}>
|
|
548
530
|
{element.name === 'email' ? (
|
|
549
531
|
<div className="email-checking">
|
|
@@ -592,53 +574,49 @@ export const BillingInfoContainer = ({
|
|
|
592
574
|
</React.Fragment>
|
|
593
575
|
)
|
|
594
576
|
})}
|
|
595
|
-
|
|
596
|
-
<
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
{
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
<div
|
|
607
|
-
{
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
)}
|
|
630
|
-
/>
|
|
631
|
-
</div>
|
|
632
|
-
))}
|
|
577
|
+
<div className="ticket-holders-fields">
|
|
578
|
+
<p>{ticketHoldersFields.label}</p>
|
|
579
|
+
{_map(ticketsQuantity, (_item, index) => (
|
|
580
|
+
<div key={_item}>
|
|
581
|
+
<h5>Ticket {index + 1}</h5>
|
|
582
|
+
{_map(ticketHoldersFields.fields, group => {
|
|
583
|
+
const { groupClassname, groupItems } = group
|
|
584
|
+
return (
|
|
585
|
+
<div key={group.uniqueId}>
|
|
586
|
+
<div className={groupClassname}>
|
|
587
|
+
{_map(groupItems, element => (
|
|
588
|
+
<div
|
|
589
|
+
className={element.className}
|
|
590
|
+
key={element.uniqueId}
|
|
591
|
+
>
|
|
592
|
+
<Field
|
|
593
|
+
name={`${element.name}-${index}`}
|
|
594
|
+
label={element.label}
|
|
595
|
+
type={element.type}
|
|
596
|
+
required={true}
|
|
597
|
+
component={
|
|
598
|
+
element.type === 'checkbox'
|
|
599
|
+
? CheckboxField
|
|
600
|
+
: CustomField
|
|
601
|
+
}
|
|
602
|
+
validate={combineValidators(
|
|
603
|
+
element.required
|
|
604
|
+
? requiredValidator
|
|
605
|
+
: () => {},
|
|
606
|
+
element.onValidate
|
|
607
|
+
? element.onValidate
|
|
608
|
+
: () => {}
|
|
609
|
+
)}
|
|
610
|
+
/>
|
|
633
611
|
</div>
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
)
|
|
612
|
+
))}
|
|
613
|
+
</div>
|
|
614
|
+
</div>
|
|
615
|
+
)
|
|
616
|
+
})}
|
|
639
617
|
</div>
|
|
640
|
-
|
|
641
|
-
|
|
618
|
+
))}
|
|
619
|
+
</div>
|
|
642
620
|
<div className="button-container">
|
|
643
621
|
<LoadingButton
|
|
644
622
|
type="submit"
|
|
@@ -36,7 +36,10 @@ export const getInitialValues = (
|
|
|
36
36
|
return initialValues
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
export const createRegisterFormData = (
|
|
39
|
+
export const createRegisterFormData = (
|
|
40
|
+
values: IValues = {},
|
|
41
|
+
checkoutBody: { attributes: { [key: string]: any } }
|
|
42
|
+
): FormData => {
|
|
40
43
|
const bodyFormData = new FormData()
|
|
41
44
|
bodyFormData.append('first_name', values.firstName)
|
|
42
45
|
bodyFormData.append('last_name', values.lastName)
|
|
@@ -51,6 +54,11 @@ export const createRegisterFormData = (values: IValues = {}): FormData => {
|
|
|
51
54
|
'client_secret',
|
|
52
55
|
ENV.CLIENT_SECRET || 'b89c191eff22fdcf84ac9bfd88d005355a151ec2c83b26b9'
|
|
53
56
|
)
|
|
57
|
+
|
|
58
|
+
_forEach(checkoutBody.attributes, (item: any, key: string) => {
|
|
59
|
+
bodyFormData.append(key, item)
|
|
60
|
+
})
|
|
61
|
+
|
|
54
62
|
return bodyFormData
|
|
55
63
|
}
|
|
56
64
|
|
|
@@ -42,15 +42,14 @@ export const CustomField = ({
|
|
|
42
42
|
type = 'text',
|
|
43
43
|
field,
|
|
44
44
|
selectOptions = [] as ISelectOption[],
|
|
45
|
-
form: { touched, errors },
|
|
45
|
+
form: { touched, errors, submitCount },
|
|
46
46
|
theme,
|
|
47
47
|
}: ICustomField & IOtherProps) => {
|
|
48
48
|
const isSelectField = type === 'select'
|
|
49
|
-
const isShrink = Boolean(field.value) || type === 'date' || type === 'select'
|
|
50
49
|
const error = _get(errors, field.name)
|
|
51
50
|
const isTouched =
|
|
52
51
|
Boolean(_get(touched, field.name)) ||
|
|
53
|
-
(_includes(field.name, 'holder') && !!error)
|
|
52
|
+
(_includes(field.name, 'holder') && !!error && !!submitCount)
|
|
54
53
|
const classes = useStyles()
|
|
55
54
|
|
|
56
55
|
return (
|
|
@@ -62,7 +61,6 @@ export const CustomField = ({
|
|
|
62
61
|
fullWidth={true}
|
|
63
62
|
error={!!error && isTouched}
|
|
64
63
|
helperText={isTouched && error}
|
|
65
|
-
InputLabelProps={{ shrink: isShrink }}
|
|
66
64
|
InputProps={{
|
|
67
65
|
classes: {
|
|
68
66
|
input: classes.input,
|
|
@@ -51,7 +51,7 @@ export const SelectField = ({
|
|
|
51
51
|
|
|
52
52
|
return (
|
|
53
53
|
<FormControl fullWidth={true}>
|
|
54
|
-
<InputLabel htmlFor={field.name} error={!!error && isTouched}>
|
|
54
|
+
<InputLabel htmlFor={field.name} error={!!error && isTouched} shrink={true}>
|
|
55
55
|
{label}
|
|
56
56
|
</InputLabel>
|
|
57
57
|
<Select
|
|
@@ -37,7 +37,6 @@ export interface ICheckoutForm {
|
|
|
37
37
|
total: string;
|
|
38
38
|
currency: string;
|
|
39
39
|
onSubmit: (error: any) => Promise<any>;
|
|
40
|
-
|
|
41
40
|
error?: string | null;
|
|
42
41
|
stripeCardOptions?: StripeCardNumberElementOptions;
|
|
43
42
|
stripe_client_secret: string;
|
|
@@ -70,6 +69,8 @@ const CheckoutForm = ({
|
|
|
70
69
|
const elements = useElements()
|
|
71
70
|
const [postalCode, setPostalCode] = useState<any>('')
|
|
72
71
|
const [stripeError, setStripeError] = useState<any>(null)
|
|
72
|
+
const [checkboxes, setCheckboxes] = useState<any>([])
|
|
73
|
+
const [allowSubmit, setAllowSubmit] = useState(false)
|
|
73
74
|
|
|
74
75
|
const handleSubmit = async (event: React.SyntheticEvent) => {
|
|
75
76
|
handleSetLoading(true)
|
|
@@ -127,6 +128,18 @@ const CheckoutForm = ({
|
|
|
127
128
|
}
|
|
128
129
|
}
|
|
129
130
|
|
|
131
|
+
const handleCheckboxes=(e:any) => {
|
|
132
|
+
const checkbox = e.target
|
|
133
|
+
const updatedCheckedState = checkboxes.map((item:any) =>{
|
|
134
|
+
const value = item.id === checkbox.name ? !item.checked : item.checked
|
|
135
|
+
return {
|
|
136
|
+
...item,
|
|
137
|
+
checked: value
|
|
138
|
+
}
|
|
139
|
+
})
|
|
140
|
+
setCheckboxes(updatedCheckedState)
|
|
141
|
+
}
|
|
142
|
+
|
|
130
143
|
const onChangePostalCode = (e: any) => {
|
|
131
144
|
setPostalCode(e.target.value)
|
|
132
145
|
}
|
|
@@ -141,6 +154,19 @@ const CheckoutForm = ({
|
|
|
141
154
|
}
|
|
142
155
|
}, [])
|
|
143
156
|
|
|
157
|
+
useEffect(() => {
|
|
158
|
+
if(conditions.length){
|
|
159
|
+
setCheckboxes(conditions)
|
|
160
|
+
}
|
|
161
|
+
}, [conditions])
|
|
162
|
+
|
|
163
|
+
useEffect(() => {
|
|
164
|
+
if(checkboxes.length){
|
|
165
|
+
const allChecked = checkboxes.every((item:any)=>item?.checked === true)
|
|
166
|
+
setAllowSubmit(allChecked)
|
|
167
|
+
}
|
|
168
|
+
}, [checkboxes])
|
|
169
|
+
|
|
144
170
|
const buttonIsDiabled = !stripe || !!error || isLoading
|
|
145
171
|
|
|
146
172
|
return (
|
|
@@ -178,7 +204,7 @@ const CheckoutForm = ({
|
|
|
178
204
|
/>
|
|
179
205
|
</label>
|
|
180
206
|
</div>
|
|
181
|
-
{
|
|
207
|
+
{checkboxes?.map((checkbox: any) => (
|
|
182
208
|
<div
|
|
183
209
|
className={'billing-info-container__singleField'}
|
|
184
210
|
key={checkbox.id}
|
|
@@ -188,13 +214,15 @@ const CheckoutForm = ({
|
|
|
188
214
|
name={checkbox.id}
|
|
189
215
|
label={checkbox.text}
|
|
190
216
|
required={true}
|
|
217
|
+
onChange={handleCheckboxes}
|
|
218
|
+
checked={checkbox.checked}
|
|
191
219
|
/>
|
|
192
220
|
</div>
|
|
193
221
|
</div>
|
|
194
222
|
))}
|
|
195
223
|
<div
|
|
196
224
|
className={`payment_button ${
|
|
197
|
-
buttonIsDiabled ? 'disabled-payment-button' : ''
|
|
225
|
+
buttonIsDiabled || !allowSubmit ? 'disabled-payment-button' : ''
|
|
198
226
|
}`}
|
|
199
227
|
>
|
|
200
228
|
<button disabled={buttonIsDiabled} type="submit">
|
package/src/.DS_Store
DELETED
|
Binary file
|
package/src/components/.DS_Store
DELETED
|
Binary file
|