tf-checkout-react 1.5.9 → 1.6.0
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/adapters/customFields.d.ts +11 -0
- package/dist/adapters/index.d.ts +1 -0
- package/dist/api/index.d.ts +6 -0
- package/dist/components/billing-info-container/index.d.ts +5 -2
- package/dist/components/billing-info-container/utils.d.ts +7 -5
- package/dist/components/common/Checkbox.d.ts +11 -0
- package/dist/components/common/CheckboxField/index.d.ts +9 -0
- package/dist/components/common/index.d.ts +1 -0
- package/dist/components/orderDetailsContainer/CustomFieldsForm.d.ts +12 -0
- package/dist/components/orderDetailsContainer/TicketHolderCustomFields.d.ts +10 -0
- package/dist/components/orderDetailsContainer/index.d.ts +29 -1
- package/dist/components/orderDetailsContainer/ticketsTable.d.ts +4 -1
- package/dist/components/orderDetailsContainer/utils/index.d.ts +6 -0
- package/dist/hoc/CustomFields/index.d.ts +3 -0
- package/dist/hoc/index.d.ts +1 -0
- package/dist/images/edit.svg +10 -0
- package/dist/tf-checkout-react.cjs.development.js +922 -210
- 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 +924 -212
- package/dist/tf-checkout-react.esm.js.map +1 -1
- package/dist/types/billing-info-data.d.ts +2 -2
- package/dist/utils/createCheckoutDataBodyWithDefaultHolder.d.ts +3 -0
- package/dist/utils/customFields.d.ts +24 -0
- package/dist/utils/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/adapters/customFields.ts +79 -0
- package/src/adapters/index.ts +1 -0
- package/src/api/index.ts +43 -0
- package/src/assets/images/edit.svg +10 -0
- package/src/components/billing-info-container/index.tsx +106 -60
- package/src/components/billing-info-container/utils.ts +29 -5
- package/src/components/common/{CheckboxField.tsx → Checkbox.tsx} +3 -3
- package/src/components/common/CheckboxField/index.tsx +41 -0
- package/src/components/common/CustomField.tsx +1 -1
- package/src/components/common/RadioGroupField/index.tsx +1 -1
- package/src/components/common/SelectField/index.tsx +1 -1
- package/src/components/common/index.tsx +1 -0
- package/src/components/orderDetailsContainer/CustomFieldsForm.tsx +75 -0
- package/src/components/orderDetailsContainer/TicketHolderCustomFields.tsx +100 -0
- package/src/components/orderDetailsContainer/index.tsx +175 -20
- package/src/components/orderDetailsContainer/ticketsTable.tsx +55 -33
- package/src/components/orderDetailsContainer/utils/index.tsx +55 -0
- package/src/components/paymentContainer/PaymentPlanSection.tsx +52 -35
- package/src/components/paymentContainer/index.tsx +2 -2
- package/src/components/stripePayment/index.tsx +2 -2
- package/src/components/ticketResale/index.tsx +4 -1
- package/src/components/ticketsContainer/index.tsx +1 -0
- package/src/hoc/CustomFields/index.tsx +77 -0
- package/src/hoc/index.ts +1 -0
- package/src/types/billing-info-data.ts +2 -2
- package/src/utils/createCheckoutDataBodyWithDefaultHolder.ts +3 -0
- package/src/utils/customFields.ts +58 -0
- package/src/utils/index.ts +1 -0
- package/dist/components/common/CheckboxField.d.ts +0 -11
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
|
|
3
|
-
import {createFixedFloatNormalizer, currencyNormalizerCreator} from '../../normalizers'
|
|
4
|
-
import {IPaymentPlanConfig} from '../../types/payment-plan-configuration'
|
|
5
|
-
import {
|
|
3
|
+
import { createFixedFloatNormalizer, currencyNormalizerCreator } from '../../normalizers'
|
|
4
|
+
import { IPaymentPlanConfig } from '../../types/payment-plan-configuration'
|
|
5
|
+
import { Checkbox } from '../common'
|
|
6
6
|
|
|
7
7
|
interface PaymentPlanSectionProps {
|
|
8
8
|
paymentPlanConfig: IPaymentPlanConfig;
|
|
@@ -26,55 +26,67 @@ export const PaymentPlanSection = (props: PaymentPlanSectionProps) => {
|
|
|
26
26
|
<div className="payment_plan_text">
|
|
27
27
|
By clicking on the “Confirm Payment Plan” button, you are starting your payment
|
|
28
28
|
plan of{' '}
|
|
29
|
-
<span className="payment_plan_highlight">
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
<span className="payment_plan_highlight">
|
|
30
|
+
{paymentPlanConfig.total_installments}
|
|
31
|
+
</span>{' '}
|
|
32
|
+
payments of{' '}
|
|
33
|
+
<span className="payment_plan_highlight">
|
|
34
|
+
{currencyNormalizerCreator(
|
|
35
|
+
createFixedFloatNormalizer(2)(paymentPlanConfig.price_per_installment),
|
|
36
|
+
currency
|
|
37
|
+
)}
|
|
38
|
+
</span>
|
|
35
39
|
, which will be drawn from your account every {paymentPlanConfig.interval} days,
|
|
36
40
|
with the first payment taken later today.
|
|
37
41
|
</div>
|
|
38
42
|
{paymentPlanConfig.has_admin_fee && (
|
|
39
43
|
<div className="payment_plan_text">
|
|
40
44
|
This includes a non-refundable admin fee of{' '}
|
|
41
|
-
<span className="payment_plan_highlight">
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
<span className="payment_plan_highlight">
|
|
46
|
+
{currencyNormalizerCreator(
|
|
47
|
+
createFixedFloatNormalizer(2)(paymentPlanConfig.admin_fee),
|
|
48
|
+
currency
|
|
49
|
+
)}
|
|
50
|
+
</span>{' '}
|
|
45
51
|
per payment.
|
|
46
52
|
</div>
|
|
47
53
|
)}
|
|
48
54
|
{paymentPlanConfig.requires_deposit && (
|
|
49
55
|
<div className="payment_plan_text">
|
|
50
56
|
You will also be charged a single, non-refundable deposit of{' '}
|
|
51
|
-
<span className="payment_plan_highlight">
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
57
|
+
<span className="payment_plan_highlight">
|
|
58
|
+
{currencyNormalizerCreator(
|
|
59
|
+
createFixedFloatNormalizer(2)(paymentPlanConfig.deposit),
|
|
60
|
+
currency
|
|
61
|
+
)}
|
|
62
|
+
</span>
|
|
55
63
|
.
|
|
56
64
|
</div>
|
|
57
65
|
)}
|
|
58
66
|
<div className="payment_plan_text payment_plan_note payment_plan_highlight">
|
|
59
|
-
NOTE: If today’s payment fails, your plan will not activate. Your
|
|
60
|
-
|
|
67
|
+
NOTE: If today’s payment fails, your plan will not activate. Your tickets will
|
|
68
|
+
not be issued until you complete your final payment.
|
|
61
69
|
</div>
|
|
62
70
|
{!paymentPlanConfig.non_refundable_type && (
|
|
63
71
|
<div className="payment_plan_text">
|
|
64
72
|
If you do not complete your payments, your order will be canceled. Your{' '}
|
|
65
|
-
<span className="payment_plan_highlight">
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
73
|
+
<span className="payment_plan_highlight">
|
|
74
|
+
first payment of{' '}
|
|
75
|
+
{currencyNormalizerCreator(
|
|
76
|
+
createFixedFloatNormalizer(2)(paymentPlanConfig.price_per_installment),
|
|
77
|
+
currency
|
|
78
|
+
)}
|
|
79
|
+
</span>
|
|
70
80
|
{paymentPlanConfig.has_admin_fee && (
|
|
71
81
|
<>
|
|
72
82
|
, plus the{' '}
|
|
73
|
-
<span className="payment_plan_highlight">
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
83
|
+
<span className="payment_plan_highlight">
|
|
84
|
+
non-refundable admin-fee of{' '}
|
|
85
|
+
{currencyNormalizerCreator(
|
|
86
|
+
createFixedFloatNormalizer(2)(paymentPlanConfig.admin_fee),
|
|
87
|
+
currency
|
|
88
|
+
)}
|
|
89
|
+
</span>
|
|
78
90
|
</>
|
|
79
91
|
)}{' '}
|
|
80
92
|
will not be refunded.
|
|
@@ -84,9 +96,12 @@ export const PaymentPlanSection = (props: PaymentPlanSectionProps) => {
|
|
|
84
96
|
<div className="payment_plan_text">
|
|
85
97
|
If you do not complete your payments, you will receive{' '}
|
|
86
98
|
<span className="payment_plan_highlight">
|
|
87
|
-
{createFixedFloatNormalizer(0)(
|
|
88
|
-
|
|
89
|
-
|
|
99
|
+
{createFixedFloatNormalizer(0)(
|
|
100
|
+
100 - paymentPlanConfig.non_refundable_amount
|
|
101
|
+
)}
|
|
102
|
+
%
|
|
103
|
+
</span>{' '}
|
|
104
|
+
of your money back
|
|
90
105
|
{paymentPlanConfig.requires_deposit && (
|
|
91
106
|
<>
|
|
92
107
|
, excluding your{' '}
|
|
@@ -131,12 +146,14 @@ export const PaymentPlanSection = (props: PaymentPlanSectionProps) => {
|
|
|
131
146
|
<div className="payment_plan_text">
|
|
132
147
|
{' '}
|
|
133
148
|
Your payment will proceed with the card ending in ****{' '}
|
|
134
|
-
<span className="payment_plan_highlight">
|
|
149
|
+
<span className="payment_plan_highlight">
|
|
150
|
+
{'' + paymentPlanConfig.saved_card.last_4_digits}
|
|
151
|
+
</span>
|
|
135
152
|
</div>
|
|
136
153
|
)}
|
|
137
154
|
<div>
|
|
138
|
-
<
|
|
139
|
-
label={<span className=
|
|
155
|
+
<Checkbox
|
|
156
|
+
label={<span className="payment_plan_toggle_label">Use this card</span>}
|
|
140
157
|
required={true}
|
|
141
158
|
onChange={() => {
|
|
142
159
|
setPaymentPlanUseSavedCard(!paymentPlanUseSavedCard)
|
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
} from '../../types/payment-plan-configuration'
|
|
39
39
|
import { CONFIGS, isBrowser } from '../../utils'
|
|
40
40
|
import { getQueryVariable } from '../../utils/getQueryVariable'
|
|
41
|
-
import {
|
|
41
|
+
import { Checkbox, Loader } from '../common/index'
|
|
42
42
|
import StripePayment from '../stripePayment'
|
|
43
43
|
import TimerWidget from '../timerWidget'
|
|
44
44
|
import { PaymentPlanSection } from './PaymentPlanSection'
|
|
@@ -514,7 +514,7 @@ export const PaymentContainer = ({
|
|
|
514
514
|
</div>
|
|
515
515
|
{!isFreeTickets && paymentPlanIsAvailable && (
|
|
516
516
|
<div className="payment_toggle">
|
|
517
|
-
<
|
|
517
|
+
<Checkbox
|
|
518
518
|
label={
|
|
519
519
|
<span className="payment_plan_toggle_label">
|
|
520
520
|
Click to checkout using Payment Plan
|
|
@@ -17,7 +17,7 @@ import { refreshSeatReservation } from '../../api'
|
|
|
17
17
|
import { getCurrencySymbolByCurrency } from '../../normalizers'
|
|
18
18
|
import { getQueryVariable } from '../../utils'
|
|
19
19
|
import { adaptStripeError } from '../../utils/adaptStripeErrors'
|
|
20
|
-
import {
|
|
20
|
+
import { Checkbox } from '../common/index'
|
|
21
21
|
import ConfirmModal from '../confirmModal'
|
|
22
22
|
|
|
23
23
|
const options: StripeCardNumberElementOptions = {
|
|
@@ -249,7 +249,7 @@ const CheckoutForm = ({
|
|
|
249
249
|
{checkboxes?.map((checkbox: any) => (
|
|
250
250
|
<div className={'billing-info-container__singleField'} key={checkbox.id}>
|
|
251
251
|
<div className="conditions-block">
|
|
252
|
-
<
|
|
252
|
+
<Checkbox
|
|
253
253
|
name={checkbox.id}
|
|
254
254
|
label={checkbox.text}
|
|
255
255
|
required={true}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AxiosError } from 'axios'
|
|
2
|
+
import _get from 'lodash/get'
|
|
2
3
|
import React, { useEffect, useState } from 'react'
|
|
3
4
|
|
|
4
5
|
import { declineInvitation, processTicket } from '../../api'
|
|
@@ -49,8 +50,10 @@ export const TicketResaleContainer = ({
|
|
|
49
50
|
|
|
50
51
|
try {
|
|
51
52
|
const response = await processTicket(hash)
|
|
53
|
+
const event_id = _get(response.data.data.attributes, 'event_id')
|
|
54
|
+
|
|
52
55
|
onProcessTicketSuccess(response.data)
|
|
53
|
-
window.location.href = `${billingPath ?? '/billing/billing-info
|
|
56
|
+
window.location.href = `${billingPath ?? '/billing/billing-info'}?event_id=${event_id}`
|
|
54
57
|
} catch (error) {
|
|
55
58
|
setError(error?.response?.data?.message)
|
|
56
59
|
onProcessTicketError(error.response)
|
|
@@ -306,6 +306,7 @@ export const TicketsContainer = ({
|
|
|
306
306
|
}
|
|
307
307
|
|
|
308
308
|
const handleTicketSelect = (key: string, value: number | string, isTable = false) => {
|
|
309
|
+
localStorage.setItem('selectedTicketsQuantity', value.toString())
|
|
309
310
|
setSelectedTickets(prevState => {
|
|
310
311
|
if (Object.keys(prevState)[0] !== key && !value) {
|
|
311
312
|
return prevState
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { CircularProgress } from '@mui/material'
|
|
2
|
+
import _get from 'lodash/get'
|
|
3
|
+
import _identity from 'lodash/identity'
|
|
4
|
+
import React, { useEffect, useState } from 'react'
|
|
5
|
+
|
|
6
|
+
import { getCustomFields } from '../../api'
|
|
7
|
+
import {
|
|
8
|
+
getDataWithCustomFields,
|
|
9
|
+
getFieldsKeys,
|
|
10
|
+
getQueryVariable,
|
|
11
|
+
} from '../../utils'
|
|
12
|
+
|
|
13
|
+
const withCustomFields = (Children: any) => (props: any) => {
|
|
14
|
+
const {
|
|
15
|
+
data = [],
|
|
16
|
+
ticketHoldersFields = {
|
|
17
|
+
id: 1,
|
|
18
|
+
fields: [],
|
|
19
|
+
},
|
|
20
|
+
skipCustomFields = true,
|
|
21
|
+
onGetCustomFieldsError = _identity,
|
|
22
|
+
onGetCustomFieldsSuccess = _identity,
|
|
23
|
+
...args
|
|
24
|
+
} = props
|
|
25
|
+
|
|
26
|
+
const [lodaing, setLoading] = useState(!skipCustomFields)
|
|
27
|
+
const [customFieldsData, setCustomFieldsData] = useState({} as any)
|
|
28
|
+
const [customFieldsOrderKeys, setCustomFieldsOrderKeys] = useState([] as any)
|
|
29
|
+
const [customFieldsTicketHolderKeys, setCustomFieldsTicketHolderKeys] = useState([] as any)
|
|
30
|
+
|
|
31
|
+
const getFields = async () => {
|
|
32
|
+
try {
|
|
33
|
+
const eventId = getQueryVariable('event_id') || ''
|
|
34
|
+
const customFields = await getCustomFields(eventId)
|
|
35
|
+
|
|
36
|
+
const orderFieldsKeys = getFieldsKeys(_get(customFields, 'orderFields', []))
|
|
37
|
+
const ticketHoldersFieldsKeys = getFieldsKeys(_get(customFields, 'ticketsFields', []))
|
|
38
|
+
|
|
39
|
+
setCustomFieldsTicketHolderKeys(ticketHoldersFieldsKeys)
|
|
40
|
+
setCustomFieldsOrderKeys(orderFieldsKeys)
|
|
41
|
+
setCustomFieldsData(customFields)
|
|
42
|
+
|
|
43
|
+
onGetCustomFieldsSuccess(customFields)
|
|
44
|
+
} catch (e) {
|
|
45
|
+
onGetCustomFieldsError(e)
|
|
46
|
+
} finally {
|
|
47
|
+
setLoading(false)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (!skipCustomFields) {
|
|
53
|
+
getFields()
|
|
54
|
+
}
|
|
55
|
+
}, [])
|
|
56
|
+
|
|
57
|
+
const {
|
|
58
|
+
dataWithCustomFields,
|
|
59
|
+
ticketHoldersWithCustomFields,
|
|
60
|
+
} = getDataWithCustomFields(data, ticketHoldersFields, customFieldsData)
|
|
61
|
+
|
|
62
|
+
if (lodaing) {
|
|
63
|
+
return <CircularProgress size={50} />
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<Children
|
|
68
|
+
{...args}
|
|
69
|
+
data={dataWithCustomFields}
|
|
70
|
+
ticketHoldersFields={ticketHoldersWithCustomFields}
|
|
71
|
+
customFieldsOrderKeys={customFieldsOrderKeys}
|
|
72
|
+
customFieldsTicketHolderKeys={customFieldsTicketHolderKeys}
|
|
73
|
+
/>
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export { withCustomFields }
|
package/src/hoc/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { withCustomFields } from './CustomFields'
|
|
@@ -23,14 +23,14 @@ export interface IFieldData {
|
|
|
23
23
|
groupClassname?: string;
|
|
24
24
|
groupLabel?: string | JSX.Element | HTMLElement;
|
|
25
25
|
groupLabelClassName?: string;
|
|
26
|
-
id
|
|
26
|
+
id?: number;
|
|
27
27
|
uniqueId?: string;
|
|
28
28
|
}
|
|
29
29
|
export interface IBillingInfoData {
|
|
30
|
-
id: number | string;
|
|
31
30
|
fields: IFieldData[];
|
|
32
31
|
|
|
33
32
|
// optional
|
|
33
|
+
id?: number | string;
|
|
34
34
|
label?: string | JSX.Element;
|
|
35
35
|
labelClassName?: string;
|
|
36
36
|
uniqueId?: string;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import _isEmpty from 'lodash/isEmpty'
|
|
2
|
+
import _map from 'lodash/map'
|
|
3
|
+
|
|
4
|
+
import { IBillingInfoData } from '../types'
|
|
5
|
+
|
|
6
|
+
export const getDataWithCustomFields = (
|
|
7
|
+
initialData: IBillingInfoData[],
|
|
8
|
+
ticketHoldersFields: IBillingInfoData,
|
|
9
|
+
customFields: any
|
|
10
|
+
) => {
|
|
11
|
+
// Custom Fields are not specified case
|
|
12
|
+
if (_isEmpty(customFields)) {
|
|
13
|
+
const dataWithCustomFields = { ...initialData }
|
|
14
|
+
const ticketHoldersWithCustomFields = { ...ticketHoldersFields }
|
|
15
|
+
return { dataWithCustomFields, ticketHoldersWithCustomFields }
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Add Custom Fields for Order
|
|
19
|
+
const orderWithCustomFields = {
|
|
20
|
+
groupClassname: 'billing-info-container__customFields',
|
|
21
|
+
groupItems: [...customFields.orderFields],
|
|
22
|
+
}
|
|
23
|
+
const initialDataFields = [...initialData[0].fields]
|
|
24
|
+
|
|
25
|
+
// Add Custom Fields to penultimate position
|
|
26
|
+
initialDataFields.splice(initialDataFields.length - 1, 0, {
|
|
27
|
+
...orderWithCustomFields,
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
const dataWithCustomFields = [
|
|
31
|
+
{
|
|
32
|
+
...initialData[0],
|
|
33
|
+
fields: initialDataFields,
|
|
34
|
+
},
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
// Add Custom Fields for Ticket Holders
|
|
38
|
+
const ticketHoldersFieldsArr = ticketHoldersFields.fields || []
|
|
39
|
+
|
|
40
|
+
const ticketHoldersCustomFieldsBlueprint = {
|
|
41
|
+
id: ticketHoldersFieldsArr.length + 1,
|
|
42
|
+
customFields: true,
|
|
43
|
+
groupClassname: 'billing-info-container__customFields',
|
|
44
|
+
groupItems: [...customFields.ticketsFields],
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const ticketHoldersWithCustomFields = {
|
|
48
|
+
...ticketHoldersFields,
|
|
49
|
+
fields: _isEmpty(ticketHoldersFieldsArr)
|
|
50
|
+
? []
|
|
51
|
+
: [...ticketHoldersFieldsArr, ticketHoldersCustomFieldsBlueprint],
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return { dataWithCustomFields, ticketHoldersWithCustomFields }
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export const getFieldsKeys = (customFields: any) =>
|
|
58
|
+
_map(customFields, field => field.name)
|
package/src/utils/index.ts
CHANGED
|
@@ -10,5 +10,6 @@ export { replaceVarInString } from './replaceVarInString'
|
|
|
10
10
|
export { isBrowser } from './isBrowser'
|
|
11
11
|
export { getFormInitialValues } from './form'
|
|
12
12
|
export { setLoggedUserData } from './auth'
|
|
13
|
+
export { getDataWithCustomFields, getFieldsKeys } from './customFields'
|
|
13
14
|
export { createElementFromHTML } from './htmlNodeFromString'
|
|
14
15
|
export { isJson } from './jsonUtils'
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { FieldInputProps } from 'formik';
|
|
3
|
-
export interface ICheckboxField {
|
|
4
|
-
label: string | number | JSX.Element;
|
|
5
|
-
field?: FieldInputProps<any>;
|
|
6
|
-
}
|
|
7
|
-
interface IOtherProps {
|
|
8
|
-
[key: string]: any;
|
|
9
|
-
}
|
|
10
|
-
export declare const CheckboxField: ({ label, field, selectOptions, theme, setFieldValue, disableDropdown, setPhoneValidationIsLoading, defaultCountry, required, uniqueId, dateFormat, datePlaceholder, isCountryCodeEditable, ...rest }: ICheckboxField & IOtherProps) => JSX.Element;
|
|
11
|
-
export {};
|