ordering-ui-react-native 0.22.54 → 0.22.55-release

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.
Files changed (130) hide show
  1. package/package.json +5 -7
  2. package/src/DeliveryApp.tsx +1 -1
  3. package/src/components/BusinessesListing/index.tsx +1 -1
  4. package/src/components/Checkout/index.tsx +40 -39
  5. package/src/components/VerifyPhone/styles.tsx +1 -2
  6. package/src/context/OfflineActions/index.tsx +236 -0
  7. package/src/providers/AlertProvider.tsx +3 -1
  8. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +9 -6
  9. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +1 -0
  10. package/themes/business/src/components/BusinessController/index.tsx +8 -3
  11. package/themes/business/src/components/BusinessProductList/index.tsx +3 -2
  12. package/themes/business/src/components/Chat/index.tsx +15 -3
  13. package/themes/business/src/components/DriverMap/index.tsx +44 -33
  14. package/themes/business/src/components/FloatingButton/index.tsx +3 -2
  15. package/themes/business/src/components/LanguageSelector/index.tsx +1 -1
  16. package/themes/business/src/components/LoginForm/index.tsx +123 -98
  17. package/themes/business/src/components/LogoutButton/index.tsx +13 -4
  18. package/themes/business/src/components/MapView/index.tsx +22 -17
  19. package/themes/business/src/components/NewOrderNotification/index.tsx +25 -14
  20. package/themes/business/src/components/OrderDetails/Business.tsx +56 -20
  21. package/themes/business/src/components/OrderDetails/Delivery.tsx +134 -53
  22. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +155 -45
  23. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +51 -28
  24. package/themes/business/src/components/OrderDetails/styles.tsx +39 -3
  25. package/themes/business/src/components/OrderDetails/usePrinterCommands.tsx +17 -16
  26. package/themes/business/src/components/OrderDetailsLogistic/index.tsx +3 -2
  27. package/themes/business/src/components/OrderSummary/index.tsx +271 -176
  28. package/themes/business/src/components/OrdersListManager/index.tsx +13 -1
  29. package/themes/business/src/components/OrdersOption/index.tsx +345 -231
  30. package/themes/business/src/components/OrdersOption/styles.tsx +14 -0
  31. package/themes/business/src/components/PreviousMessages/index.tsx +26 -3
  32. package/themes/business/src/components/PreviousOrders/OrderItem.tsx +30 -18
  33. package/themes/business/src/components/PreviousOrders/index.tsx +74 -66
  34. package/themes/business/src/components/PreviousOrders/styles.tsx +2 -1
  35. package/themes/business/src/components/PrinterEdition/MessageAlert.tsx +33 -0
  36. package/themes/business/src/components/PrinterEdition/index.tsx +143 -75
  37. package/themes/business/src/components/PrinterEdition/printerList.tsx +23 -0
  38. package/themes/business/src/components/PrinterSettings/index.tsx +1 -1
  39. package/themes/business/src/components/ProductItemAccordion/index.tsx +3 -2
  40. package/themes/business/src/components/ReviewCustomer/index.tsx +2 -0
  41. package/themes/business/src/components/StoresList/index.tsx +2 -2
  42. package/themes/business/src/components/UserProfileForm/index.tsx +48 -10
  43. package/themes/business/src/components/UserProfileForm/styles.tsx +7 -0
  44. package/themes/business/src/components/WebsocketStatus/index.tsx +2 -2
  45. package/themes/business/src/config/currency.tsx +1010 -0
  46. package/themes/business/src/hooks/useLocation.tsx +16 -12
  47. package/themes/business/src/layouts/SafeAreaContainer.tsx +35 -19
  48. package/themes/business/src/types/index.tsx +22 -7
  49. package/themes/business/src/utils/index.tsx +28 -3
  50. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  51. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  52. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  53. package/themes/kiosk/src/components/Checkout/index.tsx +9 -5
  54. package/themes/kiosk/src/components/CustomerName/index.tsx +1 -1
  55. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  56. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  57. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
  58. package/themes/kiosk/src/components/PaymentOptions/index.tsx +121 -57
  59. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  60. package/themes/original/index.tsx +9 -1
  61. package/themes/original/src/components/AddressForm/index.tsx +19 -8
  62. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  63. package/themes/original/src/components/BusinessBasicInformation/index.tsx +1 -1
  64. package/themes/original/src/components/BusinessController/index.tsx +4 -2
  65. package/themes/original/src/components/BusinessItemAccordion/index.tsx +10 -4
  66. package/themes/original/src/components/BusinessListingSearch/BusinessSearchFooter.tsx +103 -92
  67. package/themes/original/src/components/BusinessListingSearch/BusinessSearchHeader.tsx +7 -3
  68. package/themes/original/src/components/BusinessListingSearch/index.tsx +8 -13
  69. package/themes/original/src/components/BusinessPreorder/index.tsx +34 -15
  70. package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/index.tsx +73 -70
  71. package/themes/original/src/components/BusinessProductsList/index.tsx +6 -7
  72. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  73. package/themes/original/src/components/BusinessProductsListing/index.tsx +10 -6
  74. package/themes/original/src/components/BusinessTypeFilter/index.tsx +9 -8
  75. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +2 -1
  76. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +1 -1
  77. package/themes/original/src/components/BusinessesListing/index.tsx +0 -1
  78. package/themes/original/src/components/Cart/index.tsx +48 -13
  79. package/themes/original/src/components/CartContent/index.tsx +2 -3
  80. package/themes/original/src/components/Checkout/index.tsx +104 -80
  81. package/themes/original/src/components/Favorite/index.tsx +1 -5
  82. package/themes/original/src/components/ForgotPasswordForm/index.tsx +1 -2
  83. package/themes/original/src/components/GoogleMap/index.tsx +39 -18
  84. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +1 -1
  85. package/themes/original/src/components/Home/index.tsx +35 -16
  86. package/themes/original/src/components/LoginForm/index.tsx +12 -5
  87. package/themes/original/src/components/MessageListing/index.tsx +1 -1
  88. package/themes/original/src/components/Messages/index.tsx +20 -13
  89. package/themes/original/src/components/MomentOption/TimeListItem.tsx +56 -0
  90. package/themes/original/src/components/MomentOption/index.tsx +72 -51
  91. package/themes/original/src/components/MomentSelector/index.tsx +5 -2
  92. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +1 -0
  93. package/themes/original/src/components/MultiCheckout/index.tsx +55 -26
  94. package/themes/original/src/components/MyOrders/index.tsx +2 -2
  95. package/themes/original/src/components/NavBar/index.tsx +6 -2
  96. package/themes/original/src/components/OrderDetails/OrderEta.tsx +4 -3
  97. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +11 -4
  98. package/themes/original/src/components/OrderDetails/index.tsx +44 -19
  99. package/themes/original/src/components/OrderDetails/styles.tsx +0 -1
  100. package/themes/original/src/components/OrderProgress/index.tsx +4 -3
  101. package/themes/original/src/components/OrderSummary/index.tsx +32 -11
  102. package/themes/original/src/components/OrderTypeSelector/index.tsx +4 -3
  103. package/themes/original/src/components/OrdersOption/index.tsx +3 -6
  104. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  105. package/themes/original/src/components/PaymentOptions/index.tsx +462 -459
  106. package/themes/original/src/components/PhoneInputNumber/index.tsx +92 -7
  107. package/themes/original/src/components/ProductForm/ActionButton.tsx +6 -10
  108. package/themes/original/src/components/ProductItemAccordion/index.tsx +28 -37
  109. package/themes/original/src/components/ProductOptionSubOption/index.tsx +16 -8
  110. package/themes/original/src/components/ServiceForm/index.tsx +1 -1
  111. package/themes/original/src/components/SignupForm/index.tsx +41 -24
  112. package/themes/original/src/components/SingleOrderCard/index.tsx +7 -4
  113. package/themes/original/src/components/SingleProductCard/index.tsx +3 -4
  114. package/themes/original/src/components/SingleProductCard/styles.tsx +0 -3
  115. package/themes/original/src/components/StripeCardsList/index.tsx +16 -3
  116. package/themes/original/src/components/StripeElementsForm/index.tsx +6 -3
  117. package/themes/original/src/components/StripeElementsForm/naked.tsx +1 -1
  118. package/themes/original/src/components/TaxInformation/index.tsx +3 -2
  119. package/themes/original/src/components/UpsellingProducts/UpsellingContent.tsx +7 -2
  120. package/themes/original/src/components/UserDetails/index.tsx +17 -16
  121. package/themes/original/src/components/UserFormDetails/index.tsx +109 -67
  122. package/themes/original/src/components/UserProfile/index.tsx +9 -1
  123. package/themes/original/src/components/UserVerification/index.tsx +18 -5
  124. package/themes/original/src/components/shared/OAlert.tsx +2 -1
  125. package/themes/original/src/components/shared/OButton.tsx +2 -2
  126. package/themes/original/src/components/shared/OInput.tsx +4 -8
  127. package/themes/original/src/components/shared/OModal.tsx +7 -2
  128. package/themes/original/src/types/index.tsx +12 -4
  129. package/themes/original/src/utils/index.tsx +29 -0
  130. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
@@ -1,4 +1,4 @@
1
- import React, { useState, useEffect, useCallback, useRef } from 'react';
1
+ import React, { useState, useEffect, useCallback, useRef, useMemo } from 'react';
2
2
  import { View, StyleSheet, TouchableOpacity, Platform, I18nManager, ScrollView, Keyboard, BackHandler, SafeAreaView } from 'react-native';
3
3
  import { initStripe, useConfirmPayment } from '@stripe/stripe-react-native';
4
4
  import NativeStripeSdk from '@stripe/stripe-react-native/src/NativeStripeSdk'
@@ -7,7 +7,7 @@ import MaterialIcons from 'react-native-vector-icons/MaterialIcons'
7
7
  import IconAntDesign from 'react-native-vector-icons/AntDesign';
8
8
  import { useIsFocused } from '@react-navigation/native';
9
9
 
10
- import ReactNativeHapticFeedback from "react-native-haptic-feedback";
10
+ import ReactNativeHapticFeedback, { HapticFeedbackTypes } from "react-native-haptic-feedback";
11
11
  import {
12
12
  Checkout as CheckoutController,
13
13
  useOrder,
@@ -15,7 +15,6 @@ import {
15
15
  useApi,
16
16
  useLanguage,
17
17
  useUtils,
18
- useValidationFields,
19
18
  useConfig,
20
19
  useToast,
21
20
  ToastType,
@@ -146,12 +145,11 @@ const CheckoutUI = (props: any) => {
146
145
 
147
146
  const [, { showToast }] = useToast();
148
147
  const [, t] = useLanguage();
149
- const [{ user, token }, { login }] = useSession();
148
+ const [{ user, token, loading: userLoading }, { login }] = useSession();
150
149
  const [ordering] = useApi()
151
150
  const [{ configs }] = useConfig();
152
151
  const [{ parsePrice, parseDate }] = useUtils();
153
152
  const [{ options, carts, loading }, { confirmCart }] = useOrder();
154
- const [validationFields] = useValidationFields();
155
153
  const [events] = useEvent()
156
154
  const [orientationState] = useDeviceOrientation();
157
155
  const [isReadMore, setIsReadMore] = useState(false)
@@ -177,10 +175,20 @@ const CheckoutUI = (props: any) => {
177
175
  const [showTitle, setShowTitle] = useState(false)
178
176
  const [cardList, setCardList] = useState<any>({ cards: [], loading: false, error: null })
179
177
  const [isGiftCardCart, setIsGiftCardCart] = useState(!cart?.business_id)
178
+ const [userHasCards, setUserHasCards] = useState(false)
180
179
  const containerRef = useRef<any>()
181
180
  const cardsMethods = ['credomatic']
182
- const stripePaymethods: any = ['stripe', 'stripe_direct', 'stripe_connect', 'stripe_redirect']
183
- const notFields = ['coupon', 'mobile_phone', 'address', 'zipcode', 'address_notes']
181
+ const stripePaymethods: any = ['stripe', 'stripe_connect', 'stripe_redirect']
182
+ const cardsPaymethods: any = ['stripe', 'stripe_connect']
183
+
184
+ const notFields = ['coupon', 'driver_tip', 'mobile_phone', 'address', 'zipcode', 'address_notes', 'comments']
185
+
186
+ const checkoutFields = useMemo(() => checkoutFieldsState?.fields?.filter((field: any) => field.order_type_id === options?.type), [checkoutFieldsState, options])
187
+ const guestCheckoutDriveTip = useMemo(() => checkoutFields?.find((field: any) => field.order_type_id === 1 && field?.validation_field?.code === 'driver_tip'), [JSON.stringify(checkoutFields), options])
188
+ const guestCheckoutComment = useMemo(() => checkoutFields?.find((field: any) => field.order_type_id === options?.type && field?.validation_field?.code === 'comments'), [JSON.stringify(checkoutFields), options])
189
+ const guestCheckoutCoupon = useMemo(() => checkoutFields?.find((field: any) => field.order_type_id === options?.type && field?.validation_field?.code === 'coupon'), [JSON.stringify(checkoutFields), options])
190
+ const guestCheckoutZipcode = useMemo(() => checkoutFields?.find((field: any) => field.order_type_id === options?.type && field?.validation_field?.code === 'zipcode'), [JSON.stringify(checkoutFields), options])
191
+
184
192
  const placeSpotTypes = [3, 4, 5]
185
193
  const placeSpotsEnabled = placeSpotTypes.includes(options?.type)
186
194
  const businessConfigs = businessDetails?.business?.configs ?? []
@@ -198,6 +206,7 @@ const CheckoutUI = (props: any) => {
198
206
  const creditPointPlanOnBusiness = creditPointPlan?.businesses?.find((b: any) => b.business_id === cart?.business_id && b.accumulates)
199
207
  const methodsPay = ['google_pay', 'apple_pay']
200
208
 
209
+ const commentDelayTime = 1500
201
210
  const isPreOrder = configs?.preorder_status_enabled?.value === '1'
202
211
  const subtotalWithTaxes = cart?.taxes?.reduce((acc: any, item: any) => {
203
212
  if (item?.type === 1)
@@ -205,27 +214,28 @@ const CheckoutUI = (props: any) => {
205
214
  return acc = acc
206
215
  }, cart?.subtotal)
207
216
 
208
- const validateCommentsCartField = validationFields?.fields?.checkout?.comments?.enabled && validationFields?.fields?.checkout?.comments?.required && (cart?.comment === null || cart?.comment?.trim().length === 0)
209
- const validateZipcodeCard = validationFields?.fields?.card?.zipcode?.enabled &&
210
- validationFields?.fields?.card?.zipcode?.required &&
211
- paymethodSelected?.data?.card &&
212
- !paymethodSelected?.data?.card?.zipcode &&
213
- paymethodSelected?.gateway === 'stripe'
217
+ const validateCommentsCartField = (guestCheckoutComment?.enabled && (user?.guest_id ? guestCheckoutComment?.required_with_guest : guestCheckoutComment?.required)) && (cart?.comment === null || cart?.comment?.trim().length === 0)
218
+ const validateDriverTipField = options.type === 1 && (guestCheckoutDriveTip?.enabled && (user?.guest_id ? guestCheckoutDriveTip?.required_with_guest : guestCheckoutDriveTip?.required)) && (Number(cart?.driver_tip) <= 0)
219
+ const validateCouponField = (guestCheckoutCoupon?.enabled && (user?.guest_id ? guestCheckoutCoupon?.required_with_guest : guestCheckoutCoupon?.required)) && !cart?.offers?.some((offer: any) => offer?.type === 2)
220
+ const validateZipcodeCard = (guestCheckoutZipcode?.enabled && (user?.guest_id ? guestCheckoutZipcode?.required_with_guest : guestCheckoutZipcode?.required)) && paymethodSelected?.gateway === 'stripe' && paymethodSelected?.data?.card && !paymethodSelected?.data?.card?.zipcode
214
221
 
215
222
  const isDisabledButtonPlace = loading || !cart?.valid || (!paymethodSelected && cart?.balance > 0) ||
216
223
  placing || errorCash || subtotalWithTaxes < cart?.minimum ||
217
224
  (cardsMethods.includes(paymethodSelected?.gateway) && cardList?.cards?.length === 0) ||
218
- (options.type === 1 && !isGiftCardCart &&
219
- validationFields?.fields?.checkout?.driver_tip?.enabled &&
220
- validationFields?.fields?.checkout?.driver_tip?.required &&
221
- (Number(cart?.driver_tip) <= 0)) ||
222
225
  (validateCommentsCartField) ||
223
- (validateZipcodeCard)
224
- || (methodsPay.includes(paymethodSelected?.gateway) && (!methodPaySupported.enabled || methodPaySupported.loading))
226
+ (validateDriverTipField && !isGiftCardCart) ||
227
+ (validateZipcodeCard) ||
228
+ (methodsPay.includes(paymethodSelected?.gateway) && (!methodPaySupported.enabled || methodPaySupported.loading)) ||
229
+ validateCommentsCartField ||
230
+ validateDriverTipField ||
231
+ validateCouponField ||
232
+ validateZipcodeCard ||
233
+ (!userHasCards && cardsPaymethods.includes(paymethodSelected?.gateway))
225
234
 
226
235
  const driverTipsOptions = typeof configs?.driver_tip_options?.value === 'string'
227
236
  ? JSON.parse(configs?.driver_tip_options?.value) || []
228
237
  : configs?.driver_tip_options?.value || []
238
+ const driverTipsField = !cartState.loading && cart && cart?.business_id && options.type === 1 && cart?.status !== 2 && (guestCheckoutDriveTip?.enabled) && driverTipsOptions.length > 0
229
239
 
230
240
  const configTypes = configs?.order_types_allowed?.value.split('|').map((value: any) => Number(value)) || []
231
241
 
@@ -246,7 +256,7 @@ const CheckoutUI = (props: any) => {
246
256
  }
247
257
  }
248
258
 
249
- const vibrateApp = (impact?: string) => {
259
+ const vibrateApp = (impact?: HapticFeedbackTypes) => {
250
260
  const options = {
251
261
  enableVibrateFallback: true,
252
262
  ignoreAndroidSystemSettings: false
@@ -254,12 +264,11 @@ const CheckoutUI = (props: any) => {
254
264
  ReactNativeHapticFeedback.trigger(impact || "impactLight", options);
255
265
  }
256
266
 
257
- const handleSuccessSignup = (user: any) => {
258
- login({
267
+ const handleSuccessSignup = async (user: any) => {
268
+ await login({
259
269
  user,
260
270
  token: user?.session?.access_token
261
271
  })
262
- openModal?.isGuest && handlePlaceOrderAsGuest()
263
272
  setOpenModal({ ...openModal, signup: false, isGuest: false })
264
273
  }
265
274
 
@@ -312,31 +321,32 @@ const CheckoutUI = (props: any) => {
312
321
 
313
322
  const checkValidationFields = () => {
314
323
  setUserErrors([])
315
- const errors = []
316
- const _requiredFields: any = []
317
-
318
- Object.values(validationFields?.fields?.checkout).map((field: any) => {
319
- if (field?.required && !notFields.includes(field.code) && field?.enabled) {
320
- if (!user[field?.code]) {
321
- _requiredFields.push(field?.code)
324
+ const errors: Array<string> = []
325
+ const userSelected = user
326
+ const _requiredFields: Array<string> = []
327
+ Object.values(checkoutFieldsState?.fields).map((field: any) => {
328
+ if (options?.type === field?.order_type_id &&
329
+ field?.enabled &&
330
+ field?.required &&
331
+ !notFields.includes(field?.validation_field?.code)
332
+ ) {
333
+ if (userSelected && !userSelected[field?.validation_field?.code]) {
334
+ _requiredFields.push(field?.validation_field?.code)
322
335
  }
323
336
  }
324
337
  })
325
-
338
+ const mobilePhoneField: any = Object.values(checkoutFieldsState?.fields)?.find((field: any) => field?.order_type_id === options?.type && field?.validation_field?.code === 'mobile_phone')
326
339
  if (
327
- !user?.cellphone &&
328
- ((validationFields?.fields?.checkout?.cellphone?.enabled &&
329
- validationFields?.fields?.checkout?.cellphone?.required) ||
340
+ userSelected &&
341
+ !userSelected?.cellphone &&
342
+ ((mobilePhoneField?.enabled &&
343
+ mobilePhoneField?.required) ||
330
344
  configs?.verification_phone_required?.value === '1')
331
345
  ) {
332
346
  _requiredFields.push('cellphone')
333
347
  }
334
348
  setRequiredFields(_requiredFields)
335
349
 
336
- if (phoneUpdate) {
337
- errors.push(t('NECESSARY_UPDATE_COUNTRY_PHONE_CODE', 'It is necessary to update your phone number'))
338
- }
339
-
340
350
  setUserErrors(errors)
341
351
  }
342
352
 
@@ -345,20 +355,29 @@ const CheckoutUI = (props: any) => {
345
355
  const _requiredFields = checkoutFieldsState?.fields
346
356
  .filter((field: any) => (field?.order_type_id === options?.type) && field?.enabled && field?.required_with_guest &&
347
357
  !notFields.includes(field?.validation_field?.code) &&
358
+ field?.validation_field?.code !== 'email' &&
348
359
  userSelected && !userSelected[field?.validation_field?.code])
349
360
  const requiredFieldsCode = _requiredFields.map((item: any) => item?.validation_field?.code)
350
361
  const guestCheckoutCellPhone = checkoutFieldsState?.fields?.find((field: any) => field.order_type_id === options?.type && field?.validation_field?.code === 'mobile_phone')
362
+ const guestCheckoutEmail = checkoutFieldsState?.fields?.find((field: any) => field.order_type_id === options?.type && field?.validation_field?.code === 'email')
351
363
  if (
352
364
  userSelected &&
353
- !userSelected?.cellphone &&
365
+ !userSelected?.guest_cellphone &&
354
366
  ((guestCheckoutCellPhone?.enabled &&
355
367
  guestCheckoutCellPhone?.required_with_guest) ||
356
368
  configs?.verification_phone_required?.value === '1')
357
369
  ) {
358
370
  requiredFieldsCode.push('cellphone')
359
371
  }
372
+ if (
373
+ userSelected &&
374
+ !userSelected?.guest_email &&
375
+ guestCheckoutEmail?.enabled &&
376
+ guestCheckoutEmail?.required_with_guest
377
+ ) {
378
+ requiredFieldsCode.push('email')
379
+ }
360
380
  setRequiredFields(requiredFieldsCode)
361
- setOrderTypeValidationFields(_requiredFields)
362
381
  }
363
382
 
364
383
  const togglePhoneUpdate = (val: boolean) => {
@@ -369,16 +388,20 @@ const CheckoutUI = (props: any) => {
369
388
  setShowTitle(contentOffset.y > 30)
370
389
  }
371
390
 
391
+ const handleRedirect = () => {
392
+ props.fromProductsList
393
+ ? navigation?.goBack()
394
+ : onNavigationRedirect('BottomTab', { screen: 'Cart' }, !props.fromMulti)
395
+ }
396
+
372
397
  useEffect(() => {
373
- if (validationFields && validationFields?.fields?.checkout && !user?.guest_id) {
398
+ if (checkoutFieldsState?.loading || userLoading) return
399
+ if (user?.guest_id) {
400
+ checkGuestValidationFields()
401
+ } else {
374
402
  checkValidationFields()
375
403
  }
376
- }, [validationFields, user])
377
-
378
- useEffect(() => {
379
- if (checkoutFieldsState?.loading || !user?.guest_id) return
380
- checkGuestValidationFields()
381
- }, [user, checkoutFieldsState])
404
+ }, [checkoutFieldsState, user, options?.type])
382
405
 
383
406
  useEffect(() => {
384
407
  if (errors) {
@@ -388,12 +411,14 @@ const CheckoutUI = (props: any) => {
388
411
  }, [errors])
389
412
 
390
413
  useEffect(() => {
391
- if (cart?.products?.length === 0) {
392
- if (cart?.business_id !== null) {
393
- onNavigationRedirect('Business', { store: cart?.business?.slug, header: null, logo: null, fromMulti: props.fromMulti })
394
- } else if (isGiftCardCart) {
395
- onNavigationRedirect('Wallets')
396
- }
414
+ if (cart?.products?.length === 0 || !userLoading) return
415
+ if (cart?.business_id !== null) {
416
+ onNavigationRedirect('Business', { store: cart?.business?.slug, header: null, logo: null, fromMulti: props.fromMulti })
417
+ return
418
+ }
419
+ if (isGiftCardCart) {
420
+ onNavigationRedirect('Wallets')
421
+ return
397
422
  }
398
423
  }, [cart?.products?.length])
399
424
 
@@ -455,15 +480,6 @@ const CheckoutUI = (props: any) => {
455
480
  }
456
481
  }, [cartState?.error, cartState?.cart, cartState?.loading, isFocused])
457
482
 
458
- useEffect(() => {
459
- const keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', () => {
460
- containerRef?.current?.scrollToEnd && containerRef.current.scrollToEnd({ animated: true })
461
- })
462
- return () => {
463
- keyboardDidShowListener.remove()
464
- }
465
- }, [])
466
-
467
483
  useEffect(() => {
468
484
  const onBackFunction = () => {
469
485
  if (webviewPaymethod?.gateway === 'paypal' && showGateway.open) {
@@ -484,7 +500,7 @@ const CheckoutUI = (props: any) => {
484
500
  <SafeAreaView style={{ backgroundColor: theme.colors.backgroundPage }}>
485
501
  <View style={styles.wrapperNavbar}>
486
502
  <TopHeader>
487
- <TopActions onPress={() => onNavigationRedirect('BottomTab', { screen: 'Cart' }, !props.fromMulti)}>
503
+ <TopActions onPress={() => handleRedirect()}>
488
504
  <IconAntDesign
489
505
  name='arrowleft'
490
506
  size={26}
@@ -510,7 +526,7 @@ const CheckoutUI = (props: any) => {
510
526
  hideArrowLeft
511
527
  title={t('CHECKOUT', 'Checkout')}
512
528
  titleAlign={'center'}
513
- onActionLeft={() => onNavigationRedirect('BottomTab', { screen: 'Cart' }, !props.fromMulti)}
529
+ onActionLeft={() => handleRedirect()}
514
530
  showCall={false}
515
531
  btnStyle={{ paddingLeft: 0, paddingTop: Platform.OS == 'ios' ? 0 : 2 }}
516
532
  titleWrapStyle={{ paddingHorizontal: 0 }}
@@ -676,6 +692,9 @@ const CheckoutUI = (props: any) => {
676
692
  isCheckout
677
693
  phoneUpdate={phoneUpdate}
678
694
  togglePhoneUpdate={togglePhoneUpdate}
695
+ isOrderTypeValidationField
696
+ requiredFields={requiredFields}
697
+ checkoutFields={checkoutFields}
679
698
  />
680
699
  )
681
700
  )}
@@ -773,6 +792,7 @@ const CheckoutUI = (props: any) => {
773
792
  </Placeholder>
774
793
  ) : (
775
794
  <AddressDetails
795
+ cart={cart}
776
796
  navigation={navigation}
777
797
  location={options?.address?.location}
778
798
  businessLogo={businessDetails?.business?.logo}
@@ -788,14 +808,7 @@ const CheckoutUI = (props: any) => {
788
808
  </ChSection>
789
809
  )}
790
810
 
791
- {!cartState.loading &&
792
- cart &&
793
- cart?.valid &&
794
- options.type === 1 &&
795
- cart?.status !== 2 &&
796
- validationFields?.fields?.checkout?.driver_tip?.enabled &&
797
- driverTipsOptions && driverTipsOptions?.length > 0 &&
798
- cart?.business_id &&
811
+ {driverTipsField &&
799
812
  (
800
813
  <ChSection>
801
814
  <ChDriverTips>
@@ -855,6 +868,7 @@ const CheckoutUI = (props: any) => {
855
868
  openUserModal={setIsOpen}
856
869
  paymethodClicked={paymethodClicked}
857
870
  setPaymethodClicked={setPaymethodClicked}
871
+ setUserHasCards={setUserHasCards}
858
872
  />
859
873
  </ChPaymethods>
860
874
  </ChSection>
@@ -933,6 +947,7 @@ const CheckoutUI = (props: any) => {
933
947
  cart={cart}
934
948
  isCartPending={cart?.status === 2}
935
949
  onNavigationRedirect={onNavigationRedirect}
950
+ commentDelayTime={commentDelayTime}
936
951
  placeSpotTypes={placeSpotTypes}
937
952
  businessConfigs={businessConfigs}
938
953
  maxDate={maxDate}
@@ -940,6 +955,8 @@ const CheckoutUI = (props: any) => {
940
955
  creditPointPlanOnBusiness?.accumulation_rate ??
941
956
  (!!creditPointPlanOnBusiness && creditPointPlan?.accumulation_rate) ?? 0
942
957
  }
958
+ hideCommentsByValidationCheckout={!guestCheckoutComment?.enabled}
959
+ hideCouponByValidationCheckout={!guestCheckoutCoupon?.enabled}
943
960
  />
944
961
  </>
945
962
  )}
@@ -986,10 +1003,8 @@ const CheckoutUI = (props: any) => {
986
1003
  {t('INVALID_CART_MOMENT', 'Selected schedule time is invalid, please select a schedule into the business schedule interval.')}
987
1004
  </OText>
988
1005
  )}
989
- {options.type === 1 && !isGiftCardCart &&
990
- validationFields?.fields?.checkout?.driver_tip?.enabled &&
991
- validationFields?.fields?.checkout?.driver_tip?.required &&
992
- (Number(cart?.driver_tip) <= 0) && (
1006
+ {validateDriverTipField && !isGiftCardCart &&
1007
+ (
993
1008
  <OText
994
1009
  color={theme.colors.error}
995
1010
  size={12}
@@ -997,7 +1012,6 @@ const CheckoutUI = (props: any) => {
997
1012
  {t('WARNING_INVALID_DRIVER_TIP', 'Driver Tip is required.')}
998
1013
  </OText>
999
1014
  )}
1000
-
1001
1015
  {validateCommentsCartField && (
1002
1016
  <OText
1003
1017
  color={theme.colors.error}
@@ -1015,6 +1029,15 @@ const CheckoutUI = (props: any) => {
1015
1029
  {t('WARNING_CARD_ZIPCODE_REQUIRED', 'Your card selected has not zipcode')}
1016
1030
  </OText>
1017
1031
  )}
1032
+ {validateCouponField &&
1033
+ (
1034
+ <OText
1035
+ color={theme.colors.error}
1036
+ size={12}
1037
+ >
1038
+ {t('WARNING_INVALID_COUPON_FIELD', 'Coupon is required.')}
1039
+ </OText>
1040
+ )}
1018
1041
  </ChErrors>
1019
1042
  </View>
1020
1043
  )}
@@ -1032,24 +1055,25 @@ const CheckoutUI = (props: any) => {
1032
1055
  <OModal
1033
1056
  open={isOpen}
1034
1057
  onClose={() => setIsOpen(false)}
1058
+ showToastInsideModal
1035
1059
  >
1036
1060
  <View style={styles.detailWrapper}>
1037
1061
  <UserDetails
1038
1062
  isUserDetailsEdit
1039
1063
  cartStatus={cart?.status}
1040
1064
  businessId={cart?.business_id}
1041
- useValidationFields
1042
1065
  useDefualtSessionManager
1043
1066
  useSessionUser
1044
1067
  isCheckout
1045
1068
  isEdit
1046
1069
  phoneUpdate={phoneUpdate}
1047
1070
  togglePhoneUpdate={togglePhoneUpdate}
1071
+ isOrderTypeValidationField
1048
1072
  requiredFields={requiredFields}
1049
- orderTypeValidationFields={orderTypeValidationFields}
1073
+ checkoutFields={checkoutFields}
1074
+ isCheckoutPlace
1050
1075
  hideUpdateButton
1051
1076
  handlePlaceOrderAsGuest={handlePlaceOrderAsGuest}
1052
- isGuest={!!user?.guest_id}
1053
1077
  onClose={() => {
1054
1078
  setIsOpen(false)
1055
1079
  if (paymethodClicked) {
@@ -14,8 +14,7 @@ import {
14
14
 
15
15
  export const Favorite = (props: any) => {
16
16
  const {
17
- navigation,
18
- franchiseId
17
+ navigation
19
18
  } = props
20
19
  const [, t] = useLanguage()
21
20
  const theme = useTheme()
@@ -72,7 +71,6 @@ export const Favorite = (props: any) => {
72
71
  originalURL='business'
73
72
  location={`${orderState.options?.address?.location?.lat},${orderState.options?.address?.location?.lng}`}
74
73
  propsToFetch={['id', 'name', 'header', 'logo', 'location', 'address', 'ribbon', 'timezone', 'schedule', 'open', 'delivery_price', 'distance', 'delivery_time', 'pickup_time', 'reviews', 'featured', 'offers', 'food', 'laundry', 'alcohol', 'groceries', 'slug']}
75
- franchiseId={franchiseId}
76
74
  />
77
75
  )}
78
76
  {tabSelected === 'products' && (
@@ -81,7 +79,6 @@ export const Favorite = (props: any) => {
81
79
  originalURL='products'
82
80
  onNavigationRedirect={onRedirect}
83
81
  isProduct
84
- franchiseId={franchiseId}
85
82
  />
86
83
  )}
87
84
  {tabSelected === 'orders' && (
@@ -90,7 +87,6 @@ export const Favorite = (props: any) => {
90
87
  favoriteURL='favorite_orders'
91
88
  originalURL='orders'
92
89
  isOrder
93
- franchiseId={franchiseId}
94
90
  />
95
91
  )}
96
92
  </Container>
@@ -208,8 +208,7 @@ const ForgotPasswordUI = (props: any) => {
208
208
 
209
209
  <OButton
210
210
  text={emailSent && !formState.result?.error ? t('LINK_SEND_FORGOT_PASSWORD', 'Link Sent') : t('FRONT_RECOVER_PASSWORD', 'Recover Password')}
211
- bgColor={emailSent && !formState.result?.error ? theme.colors.disabled : theme.colors.primary}
212
- borderColor={emailSent && !formState.result?.error ? theme.colors.disabled : theme.colors.primary}
211
+ isDisabled={formState.loading || emailSent && !formState.result?.error}
213
212
  isLoading={formState.loading}
214
213
  imgRightSrc={null}
215
214
  onClick={emailSent && !formState.result?.error ? () => { } : handleSubmit(onSubmit)}
@@ -8,7 +8,6 @@ import Alert from '../../../../../src/providers/AlertProvider'
8
8
  import { OIcon } from '../shared';
9
9
 
10
10
  export const GoogleMap = (props: GoogleMapsParams) => {
11
-
12
11
  const {
13
12
  location,
14
13
  handleChangeAddressMap,
@@ -21,7 +20,10 @@ export const GoogleMap = (props: GoogleMapsParams) => {
21
20
  locations,
22
21
  isIntGeoCoder,
23
22
  businessZones,
24
- delta
23
+ delta,
24
+ autoCompleteAddress,
25
+ setAutoCompleteAddress,
26
+ manualZoom
25
27
  } = props
26
28
 
27
29
  const [, t] = useLanguage()
@@ -59,7 +61,7 @@ export const GoogleMap = (props: GoogleMapsParams) => {
59
61
  strokeWidth: 2
60
62
  }
61
63
 
62
- const geocodePosition = (pos: { latitude: number, longitude: number }, isMovingRegion ?: boolean) => {
64
+ const geocodePosition = (pos: { latitude: number, longitude: number }, isMovingRegion?: boolean) => {
63
65
  Geocoder.from({
64
66
  latitude: pos.latitude,
65
67
  longitude: pos.longitude
@@ -84,7 +86,7 @@ export const GoogleMap = (props: GoogleMapsParams) => {
84
86
  }
85
87
  handleChangeAddressMap && handleChangeAddressMap(address, details)
86
88
  setSaveLocation && setSaveLocation(false)
87
- if(!isMovingRegion){
89
+ if (!isMovingRegion) {
88
90
  handleToggleMap && handleToggleMap()
89
91
  }
90
92
  } else {
@@ -95,7 +97,7 @@ export const GoogleMap = (props: GoogleMapsParams) => {
95
97
  })
96
98
  }
97
99
 
98
- const validateResult = (curPos: { latitude: number, longitude: number }) => {
100
+ const validateResult = (curPos: any) => {
99
101
  const loc1 = center
100
102
  const loc2 = curPos
101
103
  const distance = calculateDistance(loc1, loc2)
@@ -103,25 +105,33 @@ export const GoogleMap = (props: GoogleMapsParams) => {
103
105
  if (!maxLimitLocation) {
104
106
  geocodePosition(curPos)
105
107
  setMarkerPosition(curPos)
106
- setRegion({ ...region, longitude: curPos.longitude, latitude: curPos.latitude })
108
+ if (!autoCompleteAddress) {
109
+ setRegion({ longitude: curPos?.longitude || 0, latitude: curPos?.latitude || 0, latitudeDelta: curPos?.latitudeDelta || 0.0010, longitudeDelta: curPos?.longitudeDelta || (delta ?? 0.0010) * ASPECT_RATIO })
110
+ } else {
111
+ setRegion({ longitude: curPos?.longitude, latitude: curPos?.latitude, latitudeDelta: delta ?? 0.0010, longitudeDelta: (delta ?? 0.0010) * ASPECT_RATIO })
112
+ }
107
113
  return
108
114
  }
109
115
 
110
116
  const _maxLimitLocation = typeof maxLimitLocation === 'string' ? parseInt(maxLimitLocation, 10) : maxLimitLocation
111
117
 
112
118
  if (distance <= _maxLimitLocation) {
113
- if (!aproxEqual(curPos.latitude, center.lat) || !aproxEqual(curPos.longitude, center.lng)){
119
+ if (!aproxEqual(curPos?.latitude, center.lat) || !aproxEqual(curPos?.longitude, center.lng)) {
114
120
  geocodePosition(curPos, true)
115
121
  }
116
122
  setMarkerPosition(curPos)
117
- setRegion({ ...region, longitude: curPos.longitude, latitude: curPos.latitude })
123
+ if (!autoCompleteAddress) {
124
+ setRegion({ longitude: curPos?.longitude || 0, latitude: curPos?.latitude || 0, latitudeDelta: curPos?.latitudeDelta || 0.0010, longitudeDelta: curPos?.longitudeDelta || (delta ?? 0.0010) * ASPECT_RATIO })
125
+ } else {
126
+ setRegion({ longitude: curPos?.longitude, latitude: curPos?.latitude, latitudeDelta: delta ?? 0.0010, longitudeDelta: (delta ?? 0.0010) * ASPECT_RATIO })
127
+ }
118
128
  } else {
119
129
  setMapErrors && setMapErrors('ERROR_MAX_LIMIT_LOCATION')
120
130
  setMarkerPosition({ latitude: center.lat, longitude: center.lng })
121
131
  }
122
132
  }
123
133
 
124
- const aproxEqual = (n1 : number, n2 : number, epsilon = 0.000001) => {
134
+ const aproxEqual = (n1: number, n2: number, epsilon = 0.000001) => {
125
135
  return Math.abs(n1 - n2) < epsilon
126
136
  }
127
137
 
@@ -182,11 +192,21 @@ export const GoogleMap = (props: GoogleMapsParams) => {
182
192
  }, [isIntGeoCoder])
183
193
 
184
194
  useEffect(() => {
185
- mapRef.current.animateToRegion({
186
- ...region,
195
+ const regionConfig = {
187
196
  latitude: location?.lat,
188
197
  longitude: location?.lng,
189
- })
198
+ latitudeDelta: region?.latitudeDelta ?? delta ?? 0.0010,
199
+ longitudeDelta: region?.longitudeDelta ?? (delta ?? 0.0010) * ASPECT_RATIO
200
+ }
201
+
202
+ mapRef.current.animateToRegion(autoCompleteAddress
203
+ ? regionConfig
204
+ : { ...region, ...regionConfig }
205
+ )
206
+
207
+ if (autoCompleteAddress) {
208
+ setAutoCompleteAddress && setAutoCompleteAddress(false)
209
+ }
190
210
  }, [location])
191
211
 
192
212
  useEffect(() => {
@@ -197,11 +217,12 @@ export const GoogleMap = (props: GoogleMapsParams) => {
197
217
 
198
218
  useEffect(() => {
199
219
  const interval = setInterval(() => {
200
- if (mapRef.current && locations) {
220
+ if (mapRef.current && locations && !manualZoom) {
201
221
  fitAllMarkers()
202
222
  }
203
223
  }, 1000)
204
224
  if (locations) {
225
+ fitAllMarkers()
205
226
  SETMARKERS(locations)
206
227
  }
207
228
  return () => clearInterval(interval)
@@ -213,7 +234,7 @@ export const GoogleMap = (props: GoogleMapsParams) => {
213
234
  provider={PROVIDER_GOOGLE}
214
235
  initialRegion={region}
215
236
  style={styles.map}
216
- onRegionChangeComplete={!readOnly ? (coordinates) => handleChangeRegion(coordinates) : () => { }}
237
+ onRegionChangeComplete={!readOnly ? (coordinates) => { handleChangeRegion(coordinates) } : () => { }}
217
238
  zoomTapEnabled
218
239
  zoomEnabled
219
240
  zoomControlEnabled
@@ -249,7 +270,7 @@ export const GoogleMap = (props: GoogleMapsParams) => {
249
270
  <React.Fragment key={i}>
250
271
  {businessZone?.type === 2 && Array.isArray(businessZone?.data) && (
251
272
  <Polygon
252
- coordinates={businessZone?.data.map((item: any) => ({ latitude: item.lat, longitude: item.lng}))}
273
+ coordinates={businessZone?.data.map((item: any) => ({ latitude: item.lat, longitude: item.lng }))}
253
274
  fillColor={fillStyles.fillColor}
254
275
  strokeColor={fillStyles.strokeColor}
255
276
  strokeWidth={fillStyles.strokeWidth}
@@ -257,7 +278,7 @@ export const GoogleMap = (props: GoogleMapsParams) => {
257
278
  )}
258
279
  {(businessZone.type === 1 && businessZone?.data?.center && businessZone?.data?.radio) && (
259
280
  <Circle
260
- center={{ latitude: businessZone?.data?.center.lat, longitude: businessZone?.data?.center.lng}}
281
+ center={{ latitude: businessZone?.data?.center.lat, longitude: businessZone?.data?.center.lng }}
261
282
  radius={businessZone?.data.radio * 1000}
262
283
  fillColor={fillStyles.fillColor}
263
284
  strokeColor={fillStyles.strokeColor}
@@ -266,7 +287,7 @@ export const GoogleMap = (props: GoogleMapsParams) => {
266
287
  )}
267
288
  {(businessZone.type === 5 && businessZone?.data?.distance) && (
268
289
  <Circle
269
- center={{ latitude: center.lat, longitude: center.lng}}
290
+ center={{ latitude: center.lat, longitude: center.lng }}
270
291
  radius={businessZone?.data.distance * units[businessZone?.data?.unit]}
271
292
  fillColor={fillStyles.fillColor}
272
293
  strokeColor={fillStyles.strokeColor}
@@ -275,7 +296,7 @@ export const GoogleMap = (props: GoogleMapsParams) => {
275
296
  )}
276
297
  </React.Fragment>
277
298
  ))}
278
- </MapView>
299
+ </MapView >
279
300
  <Alert
280
301
  open={alertState.open}
281
302
  onAccept={closeAlert}
@@ -162,4 +162,4 @@ export const HighestRatedBusinesses = (props: any) => {
162
162
  };
163
163
 
164
164
  return <BusinessesListingController {...highestRatedBusinessesProps} />;
165
- };
165
+ };