tf-checkout-react 1.0.46 → 1.0.50
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/index.d.ts +1 -0
- package/dist/components/billing-info-container/index.d.ts +1 -1
- package/dist/components/common/CheckboxField.d.ts +2 -2
- package/dist/components/common/CustomField.d.ts +2 -1
- package/dist/components/paymentContainer/index.d.ts +1 -1
- package/dist/components/stripePayment/index.d.ts +2 -1
- package/dist/components/ticketsContainer/index.d.ts +1 -0
- package/dist/tf-checkout-react.cjs.development.css +2 -2
- package/dist/tf-checkout-react.cjs.development.js +268 -181
- 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 +270 -183
- package/dist/tf-checkout-react.esm.js.map +1 -1
- package/dist/types/billing-info-data.d.ts +2 -2
- package/dist/utils/getQueryVariable.d.ts +1 -0
- package/package.json +2 -1
- package/src/api/index.ts +2 -0
- package/src/components/billing-info-container/index.tsx +128 -131
- package/src/components/common/CheckboxField.tsx +7 -2
- package/src/components/common/CustomField.tsx +17 -7
- package/src/components/paymentContainer/index.tsx +31 -3
- package/src/components/paymentContainer/style.css +8 -0
- package/src/components/stripePayment/index.tsx +48 -19
- package/src/components/stripePayment/style.css +6 -0
- package/src/components/ticketsContainer/index.tsx +2 -0
- package/src/components/waitingList/index.tsx +34 -24
- package/src/types/billing-info-data.ts +2 -2
- package/src/utils/getQueryVariable.ts +13 -0
- package/src/.DS_Store +0 -0
- package/src/components/.DS_Store +0 -0
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
import { StripeCardNumberElementOptions } from '@stripe/stripe-js'
|
|
10
10
|
import _identity from 'lodash/identity'
|
|
11
11
|
import _get from 'lodash/get'
|
|
12
|
+
import { CheckboxField } from '../common/CheckboxField'
|
|
12
13
|
|
|
13
14
|
import './style.css'
|
|
14
15
|
import { getCurrencySymbolByCurrency } from '../../normalizers'
|
|
@@ -17,6 +18,7 @@ import CircularProgress from '@mui/material/CircularProgress'
|
|
|
17
18
|
const options: StripeCardNumberElementOptions = {
|
|
18
19
|
style: {
|
|
19
20
|
base: {
|
|
21
|
+
backgroundColor:'#232323',
|
|
20
22
|
fontSize: '18px',
|
|
21
23
|
color: '#ffffff',
|
|
22
24
|
letterSpacing: '1px',
|
|
@@ -42,13 +44,14 @@ export interface ICheckoutForm {
|
|
|
42
44
|
billing_info: { [key: string]: any };
|
|
43
45
|
isLoading: any;
|
|
44
46
|
handleSetLoading: (loading: any) => void;
|
|
47
|
+
conditions: any;
|
|
45
48
|
}
|
|
46
49
|
|
|
47
50
|
interface AddressTypes {
|
|
48
|
-
city: string
|
|
49
|
-
line1: string
|
|
50
|
-
state: string
|
|
51
|
-
postal_code: string
|
|
51
|
+
city: string;
|
|
52
|
+
line1: string;
|
|
53
|
+
state: string;
|
|
54
|
+
postal_code: string;
|
|
52
55
|
}
|
|
53
56
|
|
|
54
57
|
const CheckoutForm = ({
|
|
@@ -60,7 +63,8 @@ const CheckoutForm = ({
|
|
|
60
63
|
currency,
|
|
61
64
|
billing_info,
|
|
62
65
|
isLoading = false,
|
|
63
|
-
handleSetLoading = () => {}
|
|
66
|
+
handleSetLoading = () => {},
|
|
67
|
+
conditions = [],
|
|
64
68
|
}: ICheckoutForm) => {
|
|
65
69
|
const stripe = useStripe()
|
|
66
70
|
const elements = useElements()
|
|
@@ -71,9 +75,9 @@ const CheckoutForm = ({
|
|
|
71
75
|
handleSetLoading(true)
|
|
72
76
|
try {
|
|
73
77
|
event.preventDefault()
|
|
74
|
-
|
|
75
|
-
if(!postalCode) {
|
|
76
|
-
setStripeError(
|
|
78
|
+
|
|
79
|
+
if (!postalCode) {
|
|
80
|
+
setStripeError('Please enter your zip code.')
|
|
77
81
|
handleSetLoading(false)
|
|
78
82
|
return
|
|
79
83
|
}
|
|
@@ -84,7 +88,7 @@ const CheckoutForm = ({
|
|
|
84
88
|
handleSetLoading(false)
|
|
85
89
|
return
|
|
86
90
|
}
|
|
87
|
-
|
|
91
|
+
|
|
88
92
|
const card = elements.getElement(CardNumberElement)
|
|
89
93
|
const address: AddressTypes = {
|
|
90
94
|
city: billing_info.city,
|
|
@@ -100,7 +104,7 @@ const CheckoutForm = ({
|
|
|
100
104
|
address,
|
|
101
105
|
},
|
|
102
106
|
})
|
|
103
|
-
|
|
107
|
+
|
|
104
108
|
if (paymentMethodReq.error) {
|
|
105
109
|
setStripeError(paymentMethodReq.error.message || null)
|
|
106
110
|
handleSetLoading(false)
|
|
@@ -108,7 +112,7 @@ const CheckoutForm = ({
|
|
|
108
112
|
}
|
|
109
113
|
|
|
110
114
|
const { error } = await stripe.confirmCardPayment(stripe_client_secret, {
|
|
111
|
-
payment_method: paymentMethodReq.paymentMethod.id
|
|
115
|
+
payment_method: paymentMethodReq.paymentMethod.id,
|
|
112
116
|
})
|
|
113
117
|
|
|
114
118
|
if (error) {
|
|
@@ -116,26 +120,29 @@ const CheckoutForm = ({
|
|
|
116
120
|
handleSetLoading(false)
|
|
117
121
|
return
|
|
118
122
|
}
|
|
119
|
-
|
|
120
|
-
onSubmit(null)
|
|
121
123
|
|
|
122
|
-
|
|
124
|
+
onSubmit(null)
|
|
125
|
+
} catch (e) {
|
|
123
126
|
onSubmit(e)
|
|
124
127
|
}
|
|
125
128
|
}
|
|
126
129
|
|
|
127
130
|
const onChangePostalCode = (e: any) => {
|
|
128
131
|
setPostalCode(e.target.value)
|
|
129
|
-
}
|
|
132
|
+
}
|
|
130
133
|
|
|
131
134
|
useEffect(() => {
|
|
132
135
|
if (typeof window !== 'undefined') {
|
|
133
|
-
const userData = JSON.parse(
|
|
136
|
+
const userData = JSON.parse(
|
|
137
|
+
window.localStorage.getItem('user_data') || ''
|
|
138
|
+
)
|
|
134
139
|
const zipCode = _get(userData, 'zip', '')
|
|
135
140
|
zipCode && setPostalCode(zipCode)
|
|
136
141
|
}
|
|
137
142
|
}, [])
|
|
138
143
|
|
|
144
|
+
const buttonIsDiabled = !stripe || !!error || isLoading
|
|
145
|
+
|
|
139
146
|
return (
|
|
140
147
|
<div className="stripe_payment_container">
|
|
141
148
|
{!!stripeError && (
|
|
@@ -171,9 +178,31 @@ const CheckoutForm = ({
|
|
|
171
178
|
/>
|
|
172
179
|
</label>
|
|
173
180
|
</div>
|
|
174
|
-
|
|
175
|
-
<
|
|
176
|
-
{
|
|
181
|
+
{conditions?.map((checkbox: any) => (
|
|
182
|
+
<div
|
|
183
|
+
className={'billing-info-container__singleField'}
|
|
184
|
+
key={checkbox.id}
|
|
185
|
+
>
|
|
186
|
+
<div className="conditions-block">
|
|
187
|
+
<CheckboxField
|
|
188
|
+
name={checkbox.id}
|
|
189
|
+
label={checkbox.text}
|
|
190
|
+
required={true}
|
|
191
|
+
/>
|
|
192
|
+
</div>
|
|
193
|
+
</div>
|
|
194
|
+
))}
|
|
195
|
+
<div
|
|
196
|
+
className={`payment_button ${
|
|
197
|
+
buttonIsDiabled ? 'disabled-payment-button' : ''
|
|
198
|
+
}`}
|
|
199
|
+
>
|
|
200
|
+
<button disabled={buttonIsDiabled} type="submit">
|
|
201
|
+
{isLoading ? (
|
|
202
|
+
<CircularProgress />
|
|
203
|
+
) : (
|
|
204
|
+
`Pay ${getCurrencySymbolByCurrency(currency)}${total}`
|
|
205
|
+
)}
|
|
177
206
|
</button>
|
|
178
207
|
</div>
|
|
179
208
|
</form>
|
|
@@ -27,6 +27,7 @@ interface CartSuccess {
|
|
|
27
27
|
skip_billing_page: boolean;
|
|
28
28
|
names_required: boolean;
|
|
29
29
|
age_required: boolean;
|
|
30
|
+
event_id: string;
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
export interface IGetTickets {
|
|
@@ -158,6 +159,7 @@ export const TicketsContainer = ({
|
|
|
158
159
|
names_required:
|
|
159
160
|
result?.data?.data?.attributes?.names_required ?? false,
|
|
160
161
|
age_required: result?.data?.data?.attributes?.age_required ?? false,
|
|
162
|
+
event_id: String(eventId)
|
|
161
163
|
})
|
|
162
164
|
}
|
|
163
165
|
} catch (e) {
|
|
@@ -41,6 +41,8 @@ const WaitingList = ({ tickets = {} }: WaitingListProps) => {
|
|
|
41
41
|
value: d.id,
|
|
42
42
|
}))
|
|
43
43
|
|
|
44
|
+
const showTicketsField = Boolean(ticketTypesList.length)
|
|
45
|
+
|
|
44
46
|
const handleSubmit = async (values: WaitingListFields) => {
|
|
45
47
|
try {
|
|
46
48
|
setLoading(true)
|
|
@@ -83,30 +85,38 @@ const WaitingList = ({ tickets = {} }: WaitingListProps) => {
|
|
|
83
85
|
onSubmit={handleSubmit}
|
|
84
86
|
>
|
|
85
87
|
<Form>
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
88
|
+
{showTicketsField && (
|
|
89
|
+
<>
|
|
90
|
+
<div className="field-item">
|
|
91
|
+
<Field
|
|
92
|
+
name="ticketTypeId"
|
|
93
|
+
label="Ticket types"
|
|
94
|
+
type="select"
|
|
95
|
+
component={CustomField}
|
|
96
|
+
selectOptions={[
|
|
97
|
+
{ label: 'Type of Ticket', value: '', disabled: true },
|
|
98
|
+
...ticketTypesList,
|
|
99
|
+
]}
|
|
100
|
+
/>
|
|
101
|
+
</div>
|
|
102
|
+
<div className="field-item">
|
|
103
|
+
<Field
|
|
104
|
+
name="quantity"
|
|
105
|
+
label="Quantity"
|
|
106
|
+
type="select"
|
|
107
|
+
component={CustomField}
|
|
108
|
+
selectOptions={[
|
|
109
|
+
{
|
|
110
|
+
label: 'Quantity Requested',
|
|
111
|
+
value: '',
|
|
112
|
+
disabled: true,
|
|
113
|
+
},
|
|
114
|
+
...generateQuantity(10),
|
|
115
|
+
]}
|
|
116
|
+
/>
|
|
117
|
+
</div>
|
|
118
|
+
</>
|
|
119
|
+
)}
|
|
110
120
|
<div className="field-item">
|
|
111
121
|
<Field
|
|
112
122
|
name="firstName"
|
|
@@ -2,7 +2,7 @@ import { ReactNode } from 'react'
|
|
|
2
2
|
|
|
3
3
|
export interface IGroupItem {
|
|
4
4
|
name: string;
|
|
5
|
-
label: string;
|
|
5
|
+
label: string | JSX.Element;
|
|
6
6
|
|
|
7
7
|
// optional
|
|
8
8
|
type?: string;
|
|
@@ -29,6 +29,6 @@ export interface IBillingInfoData {
|
|
|
29
29
|
fields: IFieldData[];
|
|
30
30
|
|
|
31
31
|
// optional
|
|
32
|
-
label?: string;
|
|
32
|
+
label?: string | JSX.Element;
|
|
33
33
|
labelClassName?: string;
|
|
34
34
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const getQueryVariable = (variable: string) => {
|
|
2
|
+
if (typeof window !== 'undefined') {
|
|
3
|
+
const query = window.location.search.substring(1)
|
|
4
|
+
const vars = query.split('&')
|
|
5
|
+
for (let i = 0; i < vars.length; i++) {
|
|
6
|
+
const pair = vars[i].split('=')
|
|
7
|
+
if (pair[0] === variable) {
|
|
8
|
+
return pair[1]
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return false
|
|
13
|
+
}
|
package/src/.DS_Store
DELETED
|
Binary file
|
package/src/components/.DS_Store
DELETED
|
Binary file
|