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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.6.3",
2
+ "version": "1.6.4",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -133,72 +133,72 @@ const LogicRunner: FC<{
133
133
  shouldFetchCountries,
134
134
  brandOptIn,
135
135
  }) => {
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)
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
- 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
- }
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
- const extraDataJSON = window.localStorage.getItem('extraData')
190
- const extraData = extraDataJSON ? JSON.parse(extraDataJSON) : null
189
+ const extraDataJSON = window.localStorage.getItem('extraData')
190
+ const extraData = extraDataJSON ? JSON.parse(extraDataJSON) : null
191
191
 
192
- setValues({ ...values, ...mappedValues, ...(extraData ?? {}) })
193
- setUserValues(mappedValues)
194
- } catch (e) {}
192
+ setValues({ ...values, ...mappedValues, ...(extraData ?? {}) })
193
+ setUserValues(mappedValues)
194
+ } catch (e) {}
195
+ }
195
196
  }
196
197
  }
197
- }
198
- getStoredUserData()
199
- }, [userDataEncoded, setValues, setUserValues])
200
- return null
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 || '', { page: 'billing', pageUrl })
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
- element.type === 'checkbox'
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
- value: item.id,
998
- label: item.name,
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
- : element.selectOptions || []
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
- element.type === 'checkbox'
1049
+ element.type === 'checkbox'
1050
1050
  ? undefined
1051
1051
  : element.type
1052
1052
  }