tf-checkout-react 1.6.3 → 1.6.4
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/tf-checkout-react.cjs.development.js +1 -1
- 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 +1 -1
- package/dist/tf-checkout-react.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/billing-info-container/index.tsx +69 -69
package/package.json
CHANGED
|
@@ -133,72 +133,72 @@ const LogicRunner: FC<{
|
|
|
133
133
|
shouldFetchCountries,
|
|
134
134
|
brandOptIn,
|
|
135
135
|
}) => {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
136
|
+
const prevCountry = useRef(values.country)
|
|
137
|
+
useEffect(() => {
|
|
138
|
+
const fetchStates = async () => {
|
|
139
|
+
try {
|
|
140
|
+
const res = await getStates(values.country)
|
|
141
|
+
const mappedStates = _map(res.data, (item, key) => ({
|
|
142
|
+
label: item,
|
|
143
|
+
value: key,
|
|
144
|
+
}))
|
|
145
|
+
setStates(mappedStates)
|
|
146
|
+
if (prevCountry.current !== values.country) {
|
|
147
|
+
const stateExists = mappedStates.find(
|
|
148
|
+
state => state.value === values.state
|
|
149
|
+
)?.value
|
|
150
|
+
setFieldValue('state', stateExists ?? mappedStates[0]?.value ?? '')
|
|
151
|
+
prevCountry.current = values.country
|
|
152
|
+
}
|
|
153
|
+
onGetStatesSuccess(res.data)
|
|
154
|
+
} catch (e) {
|
|
155
|
+
if (axios.isAxiosError(e)) {
|
|
156
|
+
onGetStatesError(e)
|
|
157
|
+
}
|
|
157
158
|
}
|
|
158
159
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
160
|
+
shouldFetchCountries && fetchStates()
|
|
161
|
+
}, [values.country, setStates, setFieldValue])
|
|
162
|
+
const userDataEncoded = isBrowser ? window.localStorage.getItem('user_data') : ''
|
|
163
|
+
useEffect(() => {
|
|
164
|
+
// set user data from local storage
|
|
165
|
+
const getStoredUserData = () => {
|
|
166
|
+
if (isBrowser) {
|
|
167
|
+
if (userDataEncoded) {
|
|
168
|
+
try {
|
|
169
|
+
const parsedData = JSON.parse(userDataEncoded)
|
|
170
|
+
const mappedValues = {
|
|
171
|
+
firstName: parsedData?.first_name || parsedData?.firstName || '',
|
|
172
|
+
lastName: parsedData?.last_name || parsedData?.lastName || '',
|
|
173
|
+
email: parsedData?.email || '',
|
|
174
|
+
phone: parsedData?.phone || '',
|
|
175
|
+
confirmEmail: parsedData?.email || '',
|
|
176
|
+
state: parsedData?.state || '',
|
|
177
|
+
street_address: parsedData?.street_address || '',
|
|
178
|
+
country: parsedData?.country || '1',
|
|
179
|
+
zip: parsedData?.zip || '',
|
|
180
|
+
brand_opt_in: brandOptIn ? brandOptIn : parsedData?.brand_opt_in || false,
|
|
181
|
+
city: parsedData?.city || '',
|
|
182
|
+
confirmPassword: '',
|
|
183
|
+
password: '',
|
|
184
|
+
'holderFirstName-0': parsedData?.first_name || parsedData?.firstName || '',
|
|
185
|
+
'holderLastName-0': parsedData?.last_name || parsedData?.lastName || '',
|
|
186
|
+
'holderEmail-0': parsedData?.email || '',
|
|
187
|
+
}
|
|
188
188
|
|
|
189
|
-
|
|
190
|
-
|
|
189
|
+
const extraDataJSON = window.localStorage.getItem('extraData')
|
|
190
|
+
const extraData = extraDataJSON ? JSON.parse(extraDataJSON) : null
|
|
191
191
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
192
|
+
setValues({ ...values, ...mappedValues, ...(extraData ?? {}) })
|
|
193
|
+
setUserValues(mappedValues)
|
|
194
|
+
} catch (e) {}
|
|
195
|
+
}
|
|
195
196
|
}
|
|
196
197
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
198
|
+
getStoredUserData()
|
|
199
|
+
}, [userDataEncoded, setValues, setUserValues])
|
|
200
|
+
return null
|
|
201
|
+
}
|
|
202
202
|
|
|
203
203
|
const BillingInfoContainer = React.memo(
|
|
204
204
|
({
|
|
@@ -593,7 +593,7 @@ const BillingInfoContainer = React.memo(
|
|
|
593
593
|
const initialCountry = selectedCountry.id || _get(userData, 'countryId', '') || '1'
|
|
594
594
|
|
|
595
595
|
const pageUrl = isBrowser ? window.location.href.split('?')[0] : ''
|
|
596
|
-
usePixel(eventId ||
|
|
596
|
+
usePixel(eventId || cartInfoData?.eventId, { page: 'billing', pageUrl })
|
|
597
597
|
if (isTable) {
|
|
598
598
|
dataWithUniqueIds[0].label = 'Get Your Tables'
|
|
599
599
|
}
|
|
@@ -963,7 +963,7 @@ const BillingInfoContainer = React.memo(
|
|
|
963
963
|
<div
|
|
964
964
|
className={`${element.className} ${
|
|
965
965
|
props?.errors[element.name] || ''
|
|
966
|
-
|
|
966
|
+
}`}
|
|
967
967
|
>
|
|
968
968
|
{element.component ? (
|
|
969
969
|
element.component
|
|
@@ -972,7 +972,7 @@ const BillingInfoContainer = React.memo(
|
|
|
972
972
|
{...element}
|
|
973
973
|
type={
|
|
974
974
|
element.type === 'radio' ||
|
|
975
|
-
|
|
975
|
+
element.type === 'checkbox'
|
|
976
976
|
? undefined
|
|
977
977
|
: element.type
|
|
978
978
|
}
|
|
@@ -994,11 +994,11 @@ const BillingInfoContainer = React.memo(
|
|
|
994
994
|
selectOptions={
|
|
995
995
|
element.name === 'country'
|
|
996
996
|
? _map(countries, item => ({
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
997
|
+
value: item.id,
|
|
998
|
+
label: item.name,
|
|
999
|
+
}))
|
|
1000
1000
|
: element.name === 'state'
|
|
1001
|
-
|
|
1001
|
+
? [
|
|
1002
1002
|
{
|
|
1003
1003
|
label: element.label,
|
|
1004
1004
|
value: '',
|
|
@@ -1006,7 +1006,7 @@ const BillingInfoContainer = React.memo(
|
|
|
1006
1006
|
},
|
|
1007
1007
|
...states,
|
|
1008
1008
|
]
|
|
1009
|
-
|
|
1009
|
+
: element.selectOptions || []
|
|
1010
1010
|
}
|
|
1011
1011
|
theme={theme}
|
|
1012
1012
|
defaultCountry={
|
|
@@ -1046,7 +1046,7 @@ const BillingInfoContainer = React.memo(
|
|
|
1046
1046
|
{...element}
|
|
1047
1047
|
type={
|
|
1048
1048
|
element.type === 'radio' ||
|
|
1049
|
-
|
|
1049
|
+
element.type === 'checkbox'
|
|
1050
1050
|
? undefined
|
|
1051
1051
|
: element.type
|
|
1052
1052
|
}
|