ordering-ui-react-native 0.22.43 → 0.22.44

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,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-ui-react-native",
3
- "version": "0.22.43",
3
+ "version": "0.22.44",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -15,7 +15,7 @@ const LogoutButtonUI = (props: any) => {
15
15
  const data = await _retrieveStoreData('notification_state');
16
16
  const res = await handleLogoutClick(data);
17
17
  if (res) {
18
- _clearStoreData({ excludedKeys: ['isTutorial'] });
18
+ _clearStoreData({ excludedKeys: ['isTutorial', 'language'] });
19
19
  }
20
20
  };
21
21
 
@@ -191,13 +191,13 @@ export const OrderItem = React.memo((props: any) => {
191
191
  {order?.external_id ?? t('NO_EXTERNAL_ID', 'No external Id ') + t('NO', 'Order No.') + order?.id}
192
192
  </OText>
193
193
  )}
194
- {!showExternalId && <OText
194
+ <OText
195
195
  style={styles.date}
196
196
  color={theme.colors.unselectText}
197
197
  numberOfLines={1}
198
198
  adjustsFontSizeToFit
199
199
  >
200
- {((!!order?.order_group_id && order?.order_group && isLogisticOrder
200
+ {!showExternalId && ((!!order?.order_group_id && order?.order_group && isLogisticOrder
201
201
  ? `${order?.order_group?.orders?.length} ${t('ORDERS', 'Orders')}`
202
202
  : (t('NO', 'Order No.') + order?.id)
203
203
  ) + ' · ')}
@@ -205,7 +205,6 @@ export const OrderItem = React.memo((props: any) => {
205
205
  ? parseDate(order?.delivery_datetime_utc)
206
206
  : parseDate(order?.delivery_datetime, { utc: false })}
207
207
  </OText>
208
- }
209
208
  {((currentTabSelected === 'pending' || currentTabSelected === 'inProgress') && allowColumns?.timer) && (
210
209
  <>
211
210
  {!showExternalId && <OText> · </OText>}
@@ -66,7 +66,8 @@ const AddressFormUI = (props: AddressFormParams) => {
66
66
  isFromProductsList,
67
67
  hasAddressDefault,
68
68
  afterSignup,
69
- businessSlug
69
+ businessSlug,
70
+ isFromCheckout
70
71
  } = props;
71
72
 
72
73
  const theme = useTheme();
@@ -383,9 +384,11 @@ const AddressFormUI = (props: AddressFormParams) => {
383
384
  auth &&
384
385
  !afterSignup
385
386
  ) {
386
- !isFromProductsList
387
- ? navigation.navigate('BottomTab')
388
- : navigation.navigate('Business');
387
+ isFromCheckout
388
+ ? navigation.goBack()
389
+ : !isFromProductsList
390
+ ? navigation.navigate('BottomTab')
391
+ : navigation.navigate('Business');
389
392
  }
390
393
  }, [orderState?.options?.address]);
391
394
 
@@ -217,7 +217,8 @@ const AddressListUI = (props: AddressListParams) => {
217
217
  onSaveAddress: handleSaveAddress,
218
218
  isSelectedAfterAdd: true,
219
219
  isFromProductsList: isFromProductsList,
220
- hasAddressDefault: !!orderState.options?.address?.location
220
+ hasAddressDefault: !!orderState.options?.address?.location,
221
+ isFromCheckout: route?.params?.isFromCheckout
221
222
  }
222
223
  ) : onNavigationRedirect(
223
224
  'AddressFormInitial',
@@ -228,7 +229,8 @@ const AddressListUI = (props: AddressListParams) => {
228
229
  onSaveAddress: handleSaveAddress,
229
230
  isSelectedAfterAdd: true,
230
231
  isFromProductsList: isFromProductsList,
231
- hasAddressDefault: !!orderState.options?.address?.location
232
+ hasAddressDefault: !!orderState.options?.address?.location,
233
+ isFromCheckout: route?.params?.isFromCheckout
232
234
  })}
233
235
  >
234
236
  <OIcon src={theme.images.general.pencil} width={16} style={{ marginHorizontal: 4 }} />
@@ -305,7 +307,8 @@ const AddressListUI = (props: AddressListParams) => {
305
307
  addressesList: addressList?.addresses,
306
308
  nopadding: true,
307
309
  isSelectedAfterAdd: true,
308
- hasAddressDefault: !!orderState.options?.address?.location
310
+ hasAddressDefault: !!orderState.options?.address?.location,
311
+ isFromCheckout: route?.params?.isFromCheckout
309
312
  }) : onNavigationRedirect(
310
313
  'AddressFormInitial',
311
314
  {
@@ -314,7 +317,8 @@ const AddressListUI = (props: AddressListParams) => {
314
317
  addressesList: addressList?.addresses,
315
318
  nopadding: true,
316
319
  isSelectedAfterAdd: true,
317
- hasAddressDefault: !!orderState.options?.address?.location
320
+ hasAddressDefault: !!orderState.options?.address?.location,
321
+ isFormCheckout: route?.params?.isFromCheckout
318
322
  })}
319
323
  />
320
324
  </>
@@ -103,7 +103,8 @@ const CheckoutUI = (props: any) => {
103
103
  setPlaceSpotNumber,
104
104
  maxDate,
105
105
  androidAppId,
106
- urlscheme
106
+ urlscheme,
107
+ checkoutFieldsState
107
108
  } = props
108
109
 
109
110
  const theme = useTheme();
@@ -178,6 +179,7 @@ const CheckoutUI = (props: any) => {
178
179
  const containerRef = useRef<any>()
179
180
  const cardsMethods = ['credomatic']
180
181
  const stripePaymethods: any = ['stripe', 'stripe_direct', 'stripe_connect', 'stripe_redirect']
182
+ const notFields = ['coupon', 'driver_tip', 'mobile_phone', 'address', 'zipcode', 'address_notes', 'comments']
181
183
  const placeSpotTypes = [3, 4, 5]
182
184
  const placeSpotsEnabled = placeSpotTypes.includes(options?.type)
183
185
  const businessConfigs = businessDetails?.business?.configs ?? []
@@ -270,7 +272,7 @@ const CheckoutUI = (props: any) => {
270
272
  return
271
273
  }
272
274
 
273
- if (!userErrors.length && (!requiredFields?.length || allowedGuest) || forcePlace) {
275
+ if (!userErrors.length && (!requiredFields?.length) || forcePlace) {
274
276
  vibrateApp()
275
277
  handlerClickPlaceOrder && handlerClickPlaceOrder(null, { isNative: true }, confirmPayment, NativeStripeSdk?.dismissPlatformPay)
276
278
  return
@@ -310,7 +312,6 @@ const CheckoutUI = (props: any) => {
310
312
  const checkValidationFields = () => {
311
313
  setUserErrors([])
312
314
  const errors = []
313
- const notFields = ['coupon', 'driver_tip', 'mobile_phone', 'address', 'zipcode', 'address_notes', 'comments']
314
315
  const _requiredFields: any = []
315
316
 
316
317
  Object.values(validationFields?.fields?.checkout).map((field: any) => {
@@ -338,6 +339,27 @@ const CheckoutUI = (props: any) => {
338
339
  setUserErrors(errors)
339
340
  }
340
341
 
342
+ const checkGuestValidationFields = () => {
343
+ const userSelected = user
344
+ const _requiredFields = checkoutFieldsState?.fields
345
+ .filter((field: any) => (field?.order_type_id === options?.type) && field?.enabled && field?.required &&
346
+ !notFields.includes(field?.validation_field?.code) &&
347
+ userSelected && !userSelected[field?.validation_field?.code])
348
+ .map((item: any) => item?.validation_field?.code)
349
+ const guestCheckoutCellPhone = checkoutFieldsState?.fields?.find((field: any) => field.order_type_id === options?.type && field?.validation_field?.code === 'mobile_phone')
350
+
351
+ if (
352
+ userSelected &&
353
+ !userSelected?.cellphone &&
354
+ ((guestCheckoutCellPhone?.enabled &&
355
+ guestCheckoutCellPhone?.required) ||
356
+ configs?.verification_phone_required?.value === '1')
357
+ ) {
358
+ _requiredFields.push('cellphone')
359
+ }
360
+ setRequiredFields(_requiredFields)
361
+ }
362
+
341
363
  const togglePhoneUpdate = (val: boolean) => {
342
364
  setPhoneUpdate(val)
343
365
  }
@@ -347,11 +369,16 @@ const CheckoutUI = (props: any) => {
347
369
  }
348
370
 
349
371
  useEffect(() => {
350
- if (validationFields && validationFields?.fields?.checkout) {
372
+ if (validationFields && validationFields?.fields?.checkout && !user?.guest_id) {
351
373
  checkValidationFields()
352
374
  }
353
375
  }, [validationFields, user])
354
376
 
377
+ useEffect(() => {
378
+ if (checkoutFieldsState?.loading || !user?.guest_id) return
379
+ checkGuestValidationFields()
380
+ }, [user, checkoutFieldsState])
381
+
355
382
  useEffect(() => {
356
383
  if (errors) {
357
384
  const errorText = manageErrorsToShow(errors)
@@ -108,7 +108,7 @@ const LoginFormUI = (props: LoginParams) => {
108
108
 
109
109
  const googleLoginEnabled = configs?.google_login_enabled?.value === '1' || !configs?.google_login_enabled?.enabled
110
110
  const facebookLoginEnabled = configs?.facebook_login_enabled?.value === '1' || !configs?.facebook_login_enabled?.enabled
111
- const appleLoginEnabled = Platform.OS === 'ios' && configs?.apple_login_enabled?.value === '1' || !configs?.apple_login_enabled?.enabled
111
+ const appleLoginEnabled = Platform.OS === 'ios' && (configs?.apple_login_enabled?.value === '1' || !configs?.apple_login_enabled?.enabled)
112
112
 
113
113
  const loginStyle = StyleSheet.create({
114
114
  btnOutline: {
@@ -802,7 +802,7 @@ const LoginFormUI = (props: LoginParams) => {
802
802
  handleSuccessGoogleLogin={handleSuccessFacebook}
803
803
  />
804
804
  )}
805
- {(configs?.apple_login_client_id?.value !== '' && configs?.google_login_client_id?.value !== null) && appleLoginEnabled && (
805
+ {(configs?.apple_login_client_id?.value !== '' && configs?.apple_login_client_id?.value !== null) && appleLoginEnabled && (
806
806
  <AppleLogin
807
807
  notificationState={notificationState}
808
808
  handleErrors={(err: any) => { showToast(ToastType.Error, err), vibrateApp() }}
@@ -155,7 +155,7 @@ const SignupFormUI = (props: SignupParams) => {
155
155
  const showInputPhoneNumber = (validationFields?.fields?.checkout?.cellphone?.enabled ?? false) || configs?.verification_phone_required?.value === '1'
156
156
  const googleLoginEnabled = configs?.google_login_enabled?.value === '1' || !configs?.google_login_enabled?.enabled
157
157
  const facebookLoginEnabled = configs?.facebook_login_enabled?.value === '1' || !configs?.facebook_login_enabled?.enabled
158
- const appleLoginEnabled = configs?.apple_login_enabled?.value === '1' || !configs?.apple_login_enabled?.enabled
158
+ const appleLoginEnabled = Platform.OS === 'ios' && (configs?.apple_login_enabled?.value === '1' || !configs?.apple_login_enabled?.enabled)
159
159
 
160
160
  const closeAlert = () => {
161
161
  setAlertState({
@@ -381,7 +381,7 @@ export const UserFormDetailsUI = (props: any) => {
381
381
  ))
382
382
  },
383
383
  )}
384
- {showInputBirthday && (
384
+ {showInputBirthday && ((requiredFields && requiredFields?.includes?.('birthdate')) || !requiredFields) && (
385
385
  <>
386
386
  <WrapperBirthdate>
387
387
  <OText size={14} lineHeight={21} color={theme.colors.textNormal} weight={'500'} style={{ textTransform: 'capitalize', alignSelf: 'flex-start' }}>
@@ -396,7 +396,7 @@ export const UserFormDetailsUI = (props: any) => {
396
396
  <DatePickerUI open={showDatePicker} birthdate={birthdate} onConfirm={_handleChangeDate} onCancel={() => setShowDatePicker(false)} />
397
397
  </>
398
398
  )}
399
- {!!showInputPhoneNumber && ((requiredFields && requiredFields.includes('cellphone')) || !requiredFields) && (
399
+ {!!showInputPhoneNumber && ((requiredFields && requiredFields?.includes?.('cellphone')) || !requiredFields) && (
400
400
  <WrapperPhone>
401
401
  <OText size={14} lineHeight={21} weight={'500'} color={theme.colors.textNormal}>{t('PHONE', 'Phone')}</OText>
402
402
  <PhoneInputNumber
@@ -523,10 +523,10 @@ export const UserFormDetailsUI = (props: any) => {
523
523
  borderColor: !user?.guest_id && (formState.loading || !isValid) ? theme.colors.white : theme.colors.primary,
524
524
  opacity: !user?.guest_id && (formState.loading || !isValid) ? 0.3 : 1,
525
525
  }}
526
- onClick={!user?.guest_id ? handleSubmit(onSubmit) : () => setIsModalOpen(true)}
526
+ onClick={handleSubmit(onSubmit)}
527
527
  />
528
528
  )}
529
- {isCheckout && !!user?.guest_id && (
529
+ {isCheckout && !!user?.guest_id && !requiredFields && (
530
530
  <TouchableOpacity style={{ marginTop: 10 }} onPress={() => handlePlaceOrderAsGuest()}>
531
531
  <OText color={theme.colors.primary} style={{ textAlign: 'center' }}>{t('PLACE_ORDER_AS_GUEST', 'Place order as guest')}</OText>
532
532
  </TouchableOpacity>