ordering-ui-react-native 0.22.75 → 0.22.76-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 (137) hide show
  1. package/package.json +5 -7
  2. package/src/components/BusinessesListing/index.tsx +1 -1
  3. package/src/components/Checkout/index.tsx +40 -39
  4. package/src/components/VerifyPhone/styles.tsx +1 -2
  5. package/src/context/OfflineActions/index.tsx +236 -0
  6. package/src/providers/AlertProvider.tsx +3 -1
  7. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +5 -3
  8. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +1 -0
  9. package/themes/business/src/components/BusinessController/index.tsx +8 -3
  10. package/themes/business/src/components/BusinessProductList/index.tsx +3 -2
  11. package/themes/business/src/components/Chat/index.tsx +15 -3
  12. package/themes/business/src/components/DriverMap/index.tsx +44 -33
  13. package/themes/business/src/components/FloatingButton/index.tsx +3 -2
  14. package/themes/business/src/components/LanguageSelector/index.tsx +1 -1
  15. package/themes/business/src/components/LoginForm/index.tsx +123 -98
  16. package/themes/business/src/components/LogoutButton/index.tsx +13 -4
  17. package/themes/business/src/components/MapView/RenderMarker.tsx +146 -0
  18. package/themes/business/src/components/MapView/index.tsx +68 -142
  19. package/themes/business/src/components/NewOrderNotification/index.tsx +38 -54
  20. package/themes/business/src/components/OrderDetails/Business.tsx +56 -20
  21. package/themes/business/src/components/OrderDetails/Delivery.tsx +111 -42
  22. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +146 -36
  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 +207 -144
  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 +20 -8
  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 +15 -16
  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 +26 -4
  49. package/themes/business/src/utils/index.tsx +26 -2
  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 +223 -219
  61. package/themes/original/src/components/AddressForm/index.tsx +56 -17
  62. package/themes/original/src/components/AppleLogin/index.tsx +3 -4
  63. package/themes/original/src/components/BusinessController/index.tsx +4 -2
  64. package/themes/original/src/components/BusinessItemAccordion/index.tsx +8 -3
  65. package/themes/original/src/components/BusinessListingSearch/BusinessSearchFooter.tsx +102 -90
  66. package/themes/original/src/components/BusinessListingSearch/BusinessSearchHeader.tsx +7 -3
  67. package/themes/original/src/components/BusinessListingSearch/index.tsx +8 -13
  68. package/themes/original/src/components/BusinessPreorder/index.tsx +30 -17
  69. package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/index.tsx +72 -69
  70. package/themes/original/src/components/BusinessProductsList/index.tsx +4 -5
  71. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  72. package/themes/original/src/components/BusinessProductsListing/index.tsx +5 -4
  73. package/themes/original/src/components/BusinessesListing/Layout/Appointment/styles.tsx +1 -0
  74. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +2 -1
  75. package/themes/original/src/components/Cart/index.tsx +43 -12
  76. package/themes/original/src/components/Checkout/index.tsx +126 -98
  77. package/themes/original/src/components/FloatingButton/index.tsx +1 -1
  78. package/themes/original/src/components/GPSButton/index.tsx +2 -1
  79. package/themes/original/src/components/GoogleMap/index.tsx +3 -2
  80. package/themes/original/src/components/Help/functions.tsx +76 -0
  81. package/themes/original/src/components/Help/index.tsx +74 -29
  82. package/themes/original/src/components/Help/styles.tsx +4 -1
  83. package/themes/original/src/components/HelpOptions/index.tsx +53 -0
  84. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +1 -1
  85. package/themes/original/src/components/Home/index.tsx +36 -11
  86. package/themes/original/src/components/LastOrder/index.tsx +1 -1
  87. package/themes/original/src/components/LoginForm/index.tsx +11 -5
  88. package/themes/original/src/components/MessageListing/index.tsx +1 -1
  89. package/themes/original/src/components/Messages/index.tsx +562 -555
  90. package/themes/original/src/components/MomentOption/TimeListItem.tsx +56 -0
  91. package/themes/original/src/components/MomentOption/index.tsx +141 -61
  92. package/themes/original/src/components/MomentOption/styles.tsx +1 -1
  93. package/themes/original/src/components/MomentSelector/index.tsx +5 -2
  94. package/themes/original/src/components/MultiCheckout/index.tsx +78 -33
  95. package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +2 -2
  96. package/themes/original/src/components/MultiOrdersDetails/index.tsx +2 -2
  97. package/themes/original/src/components/NavBar/index.tsx +6 -2
  98. package/themes/original/src/components/NotFoundSource/index.tsx +40 -39
  99. package/themes/original/src/components/NotFoundSource/styles.tsx +18 -9
  100. package/themes/original/src/components/OrderDetails/OrderEta.tsx +4 -3
  101. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +11 -4
  102. package/themes/original/src/components/OrderDetails/index.tsx +44 -20
  103. package/themes/original/src/components/OrderDetails/styles.tsx +0 -1
  104. package/themes/original/src/components/OrderProgress/index.tsx +5 -4
  105. package/themes/original/src/components/OrderSummary/index.tsx +32 -11
  106. package/themes/original/src/components/OrderTypeSelector/index.tsx +120 -120
  107. package/themes/original/src/components/OrdersOption/index.tsx +325 -325
  108. package/themes/original/src/components/PaymentOptionWallet/index.tsx +1 -0
  109. package/themes/original/src/components/PaymentOptions/index.tsx +471 -459
  110. package/themes/original/src/components/PhoneInputNumber/index.tsx +92 -7
  111. package/themes/original/src/components/ProductItemAccordion/index.tsx +28 -37
  112. package/themes/original/src/components/ProductOptionSubOption/index.tsx +15 -14
  113. package/themes/original/src/components/ServiceForm/index.tsx +2 -2
  114. package/themes/original/src/components/SignupForm/index.tsx +40 -24
  115. package/themes/original/src/components/SingleOrderCard/index.tsx +8 -5
  116. package/themes/original/src/components/SingleProductCard/index.tsx +2 -1
  117. package/themes/original/src/components/SingleProductCard/styles.tsx +0 -3
  118. package/themes/original/src/components/StripeCardsList/index.tsx +7 -1
  119. package/themes/original/src/components/StripeElementsForm/index.tsx +2 -2
  120. package/themes/original/src/components/TaxInformation/index.tsx +3 -2
  121. package/themes/original/src/components/UpsellingProducts/UpsellingContent.tsx +7 -2
  122. package/themes/original/src/components/UserDetails/index.tsx +17 -16
  123. package/themes/original/src/components/UserFormDetails/index.tsx +109 -67
  124. package/themes/original/src/components/UserVerification/index.tsx +18 -5
  125. package/themes/original/src/components/VerifyPhone/index.tsx +1 -1
  126. package/themes/original/src/components/shared/OInput.tsx +97 -97
  127. package/themes/original/src/components/shared/OModal.tsx +7 -2
  128. package/themes/original/src/providers/AlertProvider.tsx +1 -1
  129. package/themes/original/src/types/index.tsx +700 -695
  130. package/themes/original/src/utils/index.tsx +50 -34
  131. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
  132. package/themes/original/src/components/HelpAccountAndPayment/index.tsx +0 -62
  133. package/themes/original/src/components/HelpAccountAndPayment/styles.tsx +0 -12
  134. package/themes/original/src/components/HelpGuide/index.tsx +0 -68
  135. package/themes/original/src/components/HelpGuide/styles.tsx +0 -12
  136. package/themes/original/src/components/HelpOrder/index.tsx +0 -71
  137. package/themes/original/src/components/HelpOrder/styles.tsx +0 -13
@@ -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,
@@ -72,6 +71,8 @@ const mapConfigs = {
72
71
  }
73
72
  };
74
73
 
74
+ const driverTipsTypes = [1, 2]
75
+
75
76
  const manageErrorsToShow = (array = []) => {
76
77
  let stringError = ''
77
78
  const list = Array.isArray(array) ? array : Object.values(array)
@@ -146,12 +147,11 @@ const CheckoutUI = (props: any) => {
146
147
 
147
148
  const [, { showToast }] = useToast();
148
149
  const [, t] = useLanguage();
149
- const [{ user, token }, { login }] = useSession();
150
+ const [{ user, token, loading: userLoading }, { login }] = useSession();
150
151
  const [ordering] = useApi()
151
152
  const [{ configs }] = useConfig();
152
153
  const [{ parsePrice, parseDate }] = useUtils();
153
154
  const [{ options, carts, loading }, { confirmCart }] = useOrder();
154
- const [validationFields] = useValidationFields();
155
155
  const [events] = useEvent()
156
156
  const [orientationState] = useDeviceOrientation();
157
157
  const [isReadMore, setIsReadMore] = useState(false)
@@ -177,13 +177,19 @@ const CheckoutUI = (props: any) => {
177
177
  const [showTitle, setShowTitle] = useState(false)
178
178
  const [cardList, setCardList] = useState<any>({ cards: [], loading: false, error: null })
179
179
  const [isGiftCardCart, setIsGiftCardCart] = useState(!cart?.business_id)
180
+ const [userHasCards, setUserHasCards] = useState(false)
180
181
  const containerRef = useRef<any>()
181
182
  const cardsMethods = ['credomatic']
182
- const stripePaymethods: any = ['stripe', 'stripe_direct', 'stripe_connect', 'stripe_redirect']
183
+ const stripePaymethods: any = ['stripe', 'stripe_connect', 'stripe_redirect']
184
+ const cardsPaymethods: any = ['stripe', 'stripe_connect']
185
+
183
186
  const notFields = ['coupon', 'driver_tip', 'mobile_phone', 'address', 'zipcode', 'address_notes', 'comments']
184
187
 
185
- const guestCheckoutDriveTip = checkoutFieldsState?.fields?.find(field => field.order_type_id === 1 && field?.validation_field?.code === 'driver_tip')
186
- const guestCheckoutComment = useMemo(() => checkoutFieldsState?.fields?.find(field => field.order_type_id === options?.type && field?.validation_field?.code === 'comments'), [checkoutFieldsState, options])
188
+ const checkoutFields = useMemo(() => checkoutFieldsState?.fields?.filter((field: any) => field.order_type_id === options?.type), [checkoutFieldsState, options])
189
+ const guestCheckoutDriveTip = useMemo(() => checkoutFields?.find((field: any) => driverTipsTypes.includes(field.order_type_id) && field?.validation_field?.code === 'driver_tip'), [JSON.stringify(checkoutFields), options])
190
+ const guestCheckoutComment = useMemo(() => checkoutFields?.find((field: any) => field.order_type_id === options?.type && field?.validation_field?.code === 'comments'), [JSON.stringify(checkoutFields), options])
191
+ const guestCheckoutCoupon = useMemo(() => checkoutFields?.find((field: any) => field.order_type_id === options?.type && field?.validation_field?.code === 'coupon'), [JSON.stringify(checkoutFields), options])
192
+ const guestCheckoutZipcode = useMemo(() => checkoutFields?.find((field: any) => field.order_type_id === options?.type && field?.validation_field?.code === 'zipcode'), [JSON.stringify(checkoutFields), options])
187
193
 
188
194
  const placeSpotTypes = [3, 4, 5]
189
195
  const placeSpotsEnabled = placeSpotTypes.includes(options?.type)
@@ -197,42 +203,42 @@ const CheckoutUI = (props: any) => {
197
203
  const hideBusinessDetails = theme?.checkout?.components?.business?.hidden
198
204
  const hideBusinessMap = theme?.checkout?.components?.business?.components?.map?.hidden
199
205
  const hideCustomerDetails = theme?.checkout?.components?.customer?.hidden
200
-
206
+ const isGuestCheckoutEnabled = configs?.guest_checkout_enabled?.value === '1'
201
207
  const creditPointPlan = loyaltyPlansState?.result?.find((loyal: any) => loyal.type === 'credit_point')
202
208
  const creditPointPlanOnBusiness = creditPointPlan?.businesses?.find((b: any) => b.business_id === cart?.business_id && b.accumulates)
203
209
  const methodsPay = ['google_pay', 'apple_pay']
204
210
 
211
+ const commentDelayTime = 1500
205
212
  const isPreOrder = configs?.preorder_status_enabled?.value === '1'
206
213
  const subtotalWithTaxes = cart?.taxes?.reduce((acc: any, item: any) => {
207
214
  if (item?.type === 1)
208
215
  return acc = acc + item?.summary?.tax
209
216
  return acc = acc
210
217
  }, cart?.subtotal)
211
-
212
- const validateCommentsCartField = (!user?.guest_id ? (validationFields?.fields?.checkout?.comments?.enabled && validationFields?.fields?.checkout?.comments?.required) : (guestCheckoutComment?.enabled && guestCheckoutComment?.required_with_guest)) && (cart?.comment === null || cart?.comment?.trim().length === 0)
213
- const validateDriverTipField = options.type === 1 && (!user?.guest_id ? (validationFields?.fields?.checkout?.driver_tip?.enabled && validationFields?.fields?.checkout?.driver_tip?.required) : (guestCheckoutDriveTip?.enabled && guestCheckoutDriveTip?.required_with_guest)) && (Number(cart?.driver_tip) <= 0)
214
-
215
- const validateZipcodeCard = validationFields?.fields?.card?.zipcode?.enabled &&
216
- validationFields?.fields?.card?.zipcode?.required &&
217
- paymethodSelected?.data?.card &&
218
- !paymethodSelected?.data?.card?.zipcode &&
219
- paymethodSelected?.gateway === 'stripe'
218
+ const allowDriverTipPickup = configs?.driver_tip_allowed_at_pickup?.value === '1' && options?.type === 2
219
+ const validateCommentsCartField = (guestCheckoutComment?.enabled && (user?.guest_id ? guestCheckoutComment?.required_with_guest : guestCheckoutComment?.required)) && (cart?.comment === null || cart?.comment?.trim().length === 0)
220
+ const validateDriverTipField = (options.type === 1 || allowDriverTipPickup) && (guestCheckoutDriveTip?.enabled && (user?.guest_id ? guestCheckoutDriveTip?.required_with_guest : guestCheckoutDriveTip?.required)) && (Number(cart?.driver_tip) <= 0)
221
+ const validateCouponField = (guestCheckoutCoupon?.enabled && (user?.guest_id ? guestCheckoutCoupon?.required_with_guest : guestCheckoutCoupon?.required)) && !cart?.offers?.some((offer: any) => offer?.type === 2)
222
+ const validateZipcodeCard = (guestCheckoutZipcode?.enabled && (user?.guest_id ? guestCheckoutZipcode?.required_with_guest : guestCheckoutZipcode?.required)) && paymethodSelected?.gateway === 'stripe' && paymethodSelected?.data?.card && !paymethodSelected?.data?.card?.zipcode
220
223
 
221
224
  const isDisabledButtonPlace = loading || !cart?.valid || (!paymethodSelected && cart?.balance > 0) ||
222
225
  placing || errorCash || subtotalWithTaxes < cart?.minimum ||
223
226
  (cardsMethods.includes(paymethodSelected?.gateway) && cardList?.cards?.length === 0) ||
224
- (options.type === 1 && !isGiftCardCart &&
225
- validationFields?.fields?.checkout?.driver_tip?.enabled &&
226
- validationFields?.fields?.checkout?.driver_tip?.required &&
227
- (Number(cart?.driver_tip) <= 0)) ||
228
227
  (validateCommentsCartField) ||
229
228
  (validateDriverTipField && !isGiftCardCart) ||
230
229
  (validateZipcodeCard) ||
231
- (methodsPay.includes(paymethodSelected?.gateway) && (!methodPaySupported.enabled || methodPaySupported.loading))
230
+ (methodsPay.includes(paymethodSelected?.gateway) && (!methodPaySupported.enabled || methodPaySupported.loading)) ||
231
+ validateCommentsCartField ||
232
+ validateDriverTipField ||
233
+ validateCouponField ||
234
+ validateZipcodeCard ||
235
+ (!userHasCards && cardsPaymethods.includes(paymethodSelected?.gateway)) ||
236
+ (!isGuestCheckoutEnabled && !!user?.guest_id)
232
237
 
233
238
  const driverTipsOptions = typeof configs?.driver_tip_options?.value === 'string'
234
239
  ? JSON.parse(configs?.driver_tip_options?.value) || []
235
240
  : configs?.driver_tip_options?.value || []
241
+ const driverTipsField = !cartState.loading && cart && cart?.business_id && (options.type === 1 || allowDriverTipPickup) && cart?.status !== 2 && (guestCheckoutDriveTip?.enabled) && driverTipsOptions.length > 0
236
242
 
237
243
  const configTypes = configs?.order_types_allowed?.value.split('|').map((value: any) => Number(value)) || []
238
244
 
@@ -249,11 +255,11 @@ const CheckoutUI = (props: any) => {
249
255
 
250
256
  const handleMomentClick = () => {
251
257
  if (isPreOrder) {
252
- navigation.navigate('MomentOption')
258
+ navigation.navigate('MomentOption', { business: businessDetails?.business })
253
259
  }
254
260
  }
255
261
 
256
- const vibrateApp = (impact?: string) => {
262
+ const vibrateApp = (impact?: HapticFeedbackTypes) => {
257
263
  const options = {
258
264
  enableVibrateFallback: true,
259
265
  ignoreAndroidSystemSettings: false
@@ -261,12 +267,11 @@ const CheckoutUI = (props: any) => {
261
267
  ReactNativeHapticFeedback.trigger(impact || "impactLight", options);
262
268
  }
263
269
 
264
- const handleSuccessSignup = (user: any) => {
265
- login({
270
+ const handleSuccessSignup = async (user: any) => {
271
+ await login({
266
272
  user,
267
273
  token: user?.session?.access_token
268
274
  })
269
- openModal?.isGuest && handlePlaceOrderAsGuest()
270
275
  setOpenModal({ ...openModal, signup: false, isGuest: false })
271
276
  }
272
277
 
@@ -274,6 +279,10 @@ const CheckoutUI = (props: any) => {
274
279
  if (user) setOpenModal({ ...openModal, login: false })
275
280
  }
276
281
 
282
+ const handleOpenGuestSignup = () => {
283
+ setOpenModal({ ...openModal, signup: true, isGuest: true })
284
+ }
285
+
277
286
  const handlePlaceOrder = (confirmPayment: any, forcePlace: boolean = false) => {
278
287
  if (stripePaymethods.includes(paymethodSelected?.gateway) && user?.guest_id) {
279
288
  setOpenModal({ ...openModal, signup: true, isGuest: true })
@@ -319,31 +328,32 @@ const CheckoutUI = (props: any) => {
319
328
 
320
329
  const checkValidationFields = () => {
321
330
  setUserErrors([])
322
- const errors = []
323
- const _requiredFields: any = []
324
-
325
- Object.values(validationFields?.fields?.checkout).map((field: any) => {
326
- if (field?.required && !notFields.includes(field.code) && field?.enabled) {
327
- if (!user[field?.code]) {
328
- _requiredFields.push(field?.code)
331
+ const errors: Array<string> = []
332
+ const userSelected = user
333
+ const _requiredFields: Array<string> = []
334
+ Object.values(checkoutFieldsState?.fields).map((field: any) => {
335
+ if (options?.type === field?.order_type_id &&
336
+ field?.enabled &&
337
+ field?.required &&
338
+ !notFields.includes(field?.validation_field?.code)
339
+ ) {
340
+ if (userSelected && !userSelected[field?.validation_field?.code]) {
341
+ _requiredFields.push(field?.validation_field?.code)
329
342
  }
330
343
  }
331
344
  })
332
-
345
+ const mobilePhoneField: any = Object.values(checkoutFieldsState?.fields)?.find((field: any) => field?.order_type_id === options?.type && field?.validation_field?.code === 'mobile_phone')
333
346
  if (
334
- !user?.cellphone &&
335
- ((validationFields?.fields?.checkout?.cellphone?.enabled &&
336
- validationFields?.fields?.checkout?.cellphone?.required) ||
347
+ userSelected &&
348
+ !userSelected?.cellphone &&
349
+ ((mobilePhoneField?.enabled &&
350
+ mobilePhoneField?.required) ||
337
351
  configs?.verification_phone_required?.value === '1')
338
352
  ) {
339
353
  _requiredFields.push('cellphone')
340
354
  }
341
355
  setRequiredFields(_requiredFields)
342
356
 
343
- if (phoneUpdate) {
344
- errors.push(t('NECESSARY_UPDATE_COUNTRY_PHONE_CODE', 'It is necessary to update your phone number'))
345
- }
346
-
347
357
  setUserErrors(errors)
348
358
  }
349
359
 
@@ -352,20 +362,29 @@ const CheckoutUI = (props: any) => {
352
362
  const _requiredFields = checkoutFieldsState?.fields
353
363
  .filter((field: any) => (field?.order_type_id === options?.type) && field?.enabled && field?.required_with_guest &&
354
364
  !notFields.includes(field?.validation_field?.code) &&
365
+ field?.validation_field?.code !== 'email' &&
355
366
  userSelected && !userSelected[field?.validation_field?.code])
356
367
  const requiredFieldsCode = _requiredFields.map((item: any) => item?.validation_field?.code)
357
368
  const guestCheckoutCellPhone = checkoutFieldsState?.fields?.find((field: any) => field.order_type_id === options?.type && field?.validation_field?.code === 'mobile_phone')
369
+ const guestCheckoutEmail = checkoutFieldsState?.fields?.find((field: any) => field.order_type_id === options?.type && field?.validation_field?.code === 'email')
358
370
  if (
359
371
  userSelected &&
360
- !userSelected?.cellphone &&
372
+ !userSelected?.guest_cellphone &&
361
373
  ((guestCheckoutCellPhone?.enabled &&
362
374
  guestCheckoutCellPhone?.required_with_guest) ||
363
375
  configs?.verification_phone_required?.value === '1')
364
376
  ) {
365
377
  requiredFieldsCode.push('cellphone')
366
378
  }
379
+ if (
380
+ userSelected &&
381
+ !userSelected?.guest_email &&
382
+ guestCheckoutEmail?.enabled &&
383
+ guestCheckoutEmail?.required_with_guest
384
+ ) {
385
+ requiredFieldsCode.push('email')
386
+ }
367
387
  setRequiredFields(requiredFieldsCode)
368
- setOrderTypeValidationFields(_requiredFields)
369
388
  }
370
389
 
371
390
  const togglePhoneUpdate = (val: boolean) => {
@@ -376,16 +395,20 @@ const CheckoutUI = (props: any) => {
376
395
  setShowTitle(contentOffset.y > 30)
377
396
  }
378
397
 
398
+ const handleRedirect = () => {
399
+ props.fromProductsList
400
+ ? navigation?.goBack()
401
+ : onNavigationRedirect('BottomTab', { screen: 'Cart' }, !props.fromMulti)
402
+ }
403
+
379
404
  useEffect(() => {
380
- if (validationFields && validationFields?.fields?.checkout && !user?.guest_id) {
405
+ if (checkoutFieldsState?.loading || userLoading) return
406
+ if (user?.guest_id) {
407
+ checkGuestValidationFields()
408
+ } else {
381
409
  checkValidationFields()
382
410
  }
383
- }, [validationFields, user])
384
-
385
- useEffect(() => {
386
- if (checkoutFieldsState?.loading || !user?.guest_id) return
387
- checkGuestValidationFields()
388
- }, [user, checkoutFieldsState])
411
+ }, [checkoutFieldsState, user, options?.type])
389
412
 
390
413
  useEffect(() => {
391
414
  if (errors) {
@@ -395,12 +418,14 @@ const CheckoutUI = (props: any) => {
395
418
  }, [errors])
396
419
 
397
420
  useEffect(() => {
398
- if (cart?.products?.length === 0) {
399
- if (cart?.business_id !== null) {
400
- onNavigationRedirect('Business', { store: cart?.business?.slug, header: null, logo: null, fromMulti: props.fromMulti })
401
- } else if (isGiftCardCart) {
402
- onNavigationRedirect('Wallets')
403
- }
421
+ if (cart?.products?.length === 0 || !userLoading) return
422
+ if (cart?.business_id !== null) {
423
+ onNavigationRedirect('Business', { store: cart?.business?.slug, header: null, logo: null, fromMulti: props.fromMulti })
424
+ return
425
+ }
426
+ if (isGiftCardCart) {
427
+ onNavigationRedirect('Wallets')
428
+ return
404
429
  }
405
430
  }, [cart?.products?.length])
406
431
 
@@ -462,15 +487,6 @@ const CheckoutUI = (props: any) => {
462
487
  }
463
488
  }, [cartState?.error, cartState?.cart, cartState?.loading, isFocused])
464
489
 
465
- useEffect(() => {
466
- const keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', () => {
467
- containerRef?.current?.scrollToEnd && containerRef.current.scrollToEnd({ animated: true })
468
- })
469
- return () => {
470
- keyboardDidShowListener.remove()
471
- }
472
- }, [])
473
-
474
490
  useEffect(() => {
475
491
  const onBackFunction = () => {
476
492
  if (webviewPaymethod?.gateway === 'paypal' && showGateway.open) {
@@ -491,7 +507,7 @@ const CheckoutUI = (props: any) => {
491
507
  <SafeAreaView style={{ backgroundColor: theme.colors.backgroundPage }}>
492
508
  <View style={styles.wrapperNavbar}>
493
509
  <TopHeader>
494
- <TopActions onPress={() => onNavigationRedirect('BottomTab', { screen: 'Cart' }, !props.fromMulti)}>
510
+ <TopActions onPress={() => handleRedirect()}>
495
511
  <IconAntDesign
496
512
  name='arrowleft'
497
513
  size={26}
@@ -517,7 +533,7 @@ const CheckoutUI = (props: any) => {
517
533
  hideArrowLeft
518
534
  title={t('CHECKOUT', 'Checkout')}
519
535
  titleAlign={'center'}
520
- onActionLeft={() => onNavigationRedirect('BottomTab', { screen: 'Cart' }, !props.fromMulti)}
536
+ onActionLeft={() => handleRedirect()}
521
537
  showCall={false}
522
538
  btnStyle={{ paddingLeft: 0, paddingTop: Platform.OS == 'ios' ? 0 : 2 }}
523
539
  titleWrapStyle={{ paddingHorizontal: 0 }}
@@ -662,14 +678,16 @@ const CheckoutUI = (props: any) => {
662
678
  style={{ borderRadius: 7.6, marginTop: 20 }}
663
679
  onClick={() => setOpenModal({ ...openModal, login: true })}
664
680
  />
665
- <OButton
666
- text={t('CONTINUE_AS_GUEST', 'Continue as guest')}
667
- textStyle={{ color: theme.colors.black }}
668
- bgColor={theme.colors.white}
669
- borderColor={theme.colors.black}
670
- style={{ borderRadius: 7.6, marginTop: 20 }}
671
- onClick={() => setAllowedGuest(true)}
672
- />
681
+ {isGuestCheckoutEnabled && (
682
+ <OButton
683
+ text={t('CONTINUE_AS_GUEST', 'Continue as guest')}
684
+ textStyle={{ color: theme.colors.black }}
685
+ bgColor={theme.colors.white}
686
+ borderColor={theme.colors.black}
687
+ style={{ borderRadius: 7.6, marginTop: 20 }}
688
+ onClick={() => setAllowedGuest(true)}
689
+ />
690
+ )}
673
691
  </View>
674
692
  ) : (
675
693
  <UserDetails
@@ -683,6 +701,9 @@ const CheckoutUI = (props: any) => {
683
701
  isCheckout
684
702
  phoneUpdate={phoneUpdate}
685
703
  togglePhoneUpdate={togglePhoneUpdate}
704
+ isOrderTypeValidationField
705
+ requiredFields={requiredFields}
706
+ checkoutFields={checkoutFields}
686
707
  />
687
708
  )
688
709
  )}
@@ -780,6 +801,7 @@ const CheckoutUI = (props: any) => {
780
801
  </Placeholder>
781
802
  ) : (
782
803
  <AddressDetails
804
+ cart={cart}
783
805
  navigation={navigation}
784
806
  location={options?.address?.location}
785
807
  businessLogo={businessDetails?.business?.logo}
@@ -795,14 +817,7 @@ const CheckoutUI = (props: any) => {
795
817
  </ChSection>
796
818
  )}
797
819
 
798
- {!cartState.loading &&
799
- cart &&
800
- cart?.valid &&
801
- options.type === 1 &&
802
- cart?.status !== 2 &&
803
- validationFields?.fields?.checkout?.driver_tip?.enabled &&
804
- driverTipsOptions && driverTipsOptions?.length > 0 &&
805
- cart?.business_id &&
820
+ {driverTipsField &&
806
821
  (
807
822
  <ChSection>
808
823
  <ChDriverTips>
@@ -862,6 +877,9 @@ const CheckoutUI = (props: any) => {
862
877
  openUserModal={setIsOpen}
863
878
  paymethodClicked={paymethodClicked}
864
879
  setPaymethodClicked={setPaymethodClicked}
880
+ setUserHasCards={setUserHasCards}
881
+ handleOpenGuestSignup={handleOpenGuestSignup}
882
+ guestDisabledError={(!isGuestCheckoutEnabled && !!user?.guest_id)}
865
883
  />
866
884
  </ChPaymethods>
867
885
  </ChSection>
@@ -940,6 +958,7 @@ const CheckoutUI = (props: any) => {
940
958
  cart={cart}
941
959
  isCartPending={cart?.status === 2}
942
960
  onNavigationRedirect={onNavigationRedirect}
961
+ commentDelayTime={commentDelayTime}
943
962
  placeSpotTypes={placeSpotTypes}
944
963
  businessConfigs={businessConfigs}
945
964
  maxDate={maxDate}
@@ -947,6 +966,8 @@ const CheckoutUI = (props: any) => {
947
966
  creditPointPlanOnBusiness?.accumulation_rate ??
948
967
  (!!creditPointPlanOnBusiness && creditPointPlan?.accumulation_rate) ?? 0
949
968
  }
969
+ hideCommentsByValidationCheckout={!guestCheckoutComment?.enabled}
970
+ hideCouponByValidationCheckout={!guestCheckoutCoupon?.enabled}
950
971
  />
951
972
  </>
952
973
  )}
@@ -993,17 +1014,6 @@ const CheckoutUI = (props: any) => {
993
1014
  {t('INVALID_CART_MOMENT', 'Selected schedule time is invalid, please select a schedule into the business schedule interval.')}
994
1015
  </OText>
995
1016
  )}
996
- {options.type === 1 && !isGiftCardCart &&
997
- validationFields?.fields?.checkout?.driver_tip?.enabled &&
998
- validationFields?.fields?.checkout?.driver_tip?.required &&
999
- (Number(cart?.driver_tip) <= 0) && (
1000
- <OText
1001
- color={theme.colors.error}
1002
- size={12}
1003
- >
1004
- {t('WARNING_INVALID_DRIVER_TIP', 'Driver Tip is required.')}
1005
- </OText>
1006
- )}
1007
1017
  {validateDriverTipField && !isGiftCardCart &&
1008
1018
  (
1009
1019
  <OText
@@ -1030,6 +1040,23 @@ const CheckoutUI = (props: any) => {
1030
1040
  {t('WARNING_CARD_ZIPCODE_REQUIRED', 'Your card selected has not zipcode')}
1031
1041
  </OText>
1032
1042
  )}
1043
+ {validateCouponField &&
1044
+ (
1045
+ <OText
1046
+ color={theme.colors.error}
1047
+ size={12}
1048
+ >
1049
+ {t('WARNING_INVALID_COUPON_FIELD', 'Coupon is required.')}
1050
+ </OText>
1051
+ )}
1052
+ {(!isGuestCheckoutEnabled && !!user?.guest_id) && (
1053
+ <OText
1054
+ color={theme.colors.error}
1055
+ size={12}
1056
+ >
1057
+ {t('LOGIN_SIGN_UP_COMPLETE_ORDER', 'Login/Sign up to complete your order.')}
1058
+ </OText>
1059
+ )}
1033
1060
  </ChErrors>
1034
1061
  </View>
1035
1062
  )}
@@ -1047,24 +1074,25 @@ const CheckoutUI = (props: any) => {
1047
1074
  <OModal
1048
1075
  open={isOpen}
1049
1076
  onClose={() => setIsOpen(false)}
1077
+ showToastInsideModal
1050
1078
  >
1051
1079
  <View style={styles.detailWrapper}>
1052
1080
  <UserDetails
1053
1081
  isUserDetailsEdit
1054
1082
  cartStatus={cart?.status}
1055
1083
  businessId={cart?.business_id}
1056
- useValidationFields
1057
1084
  useDefualtSessionManager
1058
1085
  useSessionUser
1059
1086
  isCheckout
1060
1087
  isEdit
1061
1088
  phoneUpdate={phoneUpdate}
1062
1089
  togglePhoneUpdate={togglePhoneUpdate}
1090
+ isOrderTypeValidationField
1063
1091
  requiredFields={requiredFields}
1064
- orderTypeValidationFields={orderTypeValidationFields}
1092
+ checkoutFields={checkoutFields}
1093
+ isCheckoutPlace
1065
1094
  hideUpdateButton
1066
1095
  handlePlaceOrderAsGuest={handlePlaceOrderAsGuest}
1067
- isGuest={!!user?.guest_id}
1068
1096
  onClose={() => {
1069
1097
  setIsOpen(false)
1070
1098
  if (paymethodClicked) {
@@ -62,7 +62,7 @@ const FloatingButtonUI = (props: FloatingButtonParams) => {
62
62
  return (
63
63
  <Container
64
64
  style={{
65
- paddingBottom: Platform.OS === 'ios' ? 20 : bottom + 16
65
+ paddingBottom: Platform.OS === 'ios' ? 20 : (typeof Platform.Version === 'number' && Platform.Version >= 35) ? 10 : bottom + 16
66
66
  }}>
67
67
 
68
68
  <View style={styles.infoCont}>
@@ -34,7 +34,8 @@ export const GPSButton = (props: any) => {
34
34
  }
35
35
  let data : any
36
36
  const details = {
37
- geometry: { location: { lat: pos.latitude, lng: pos.longitude } }
37
+ geometry: { location: { lat: pos.latitude, lng: pos.longitude } },
38
+ address_components: results[0]?.address_components
38
39
  }
39
40
  // if (isSetInputs) {
40
41
  data = {
@@ -82,11 +82,12 @@ export const GoogleMap = (props: GoogleMapsParams) => {
82
82
  place_id: results[0]?.place_id,
83
83
  }
84
84
  const details = {
85
- geometry: { location: { lat: pos.latitude, lng: pos.longitude } }
85
+ geometry: { location: { lat: pos.latitude, lng: pos.longitude } },
86
+ address_components: results[0]?.address_components,
86
87
  }
87
88
  handleChangeAddressMap && handleChangeAddressMap(address, details)
88
89
  setSaveLocation && setSaveLocation(false)
89
- if (!isMovingRegion) {
90
+ if (isMovingRegion) {
90
91
  handleToggleMap && handleToggleMap()
91
92
  }
92
93
  } else {
@@ -0,0 +1,76 @@
1
+ import React, { useState, useEffect } from 'react'
2
+ import PropTypes from 'prop-types'
3
+ import { useApi } from 'ordering-components/native'
4
+
5
+ /**
6
+ * Component to manage login behavior without UI component
7
+ */
8
+ export const CmsContent = (props: any) => {
9
+ const { UIComponent } = props
10
+
11
+ /**
12
+ * Array to save the body of the page
13
+ */
14
+ const [ordering] = useApi()
15
+ const [cmsState, setCmsState] = useState({ items: [], pages: [], loading: true, error: null })
16
+
17
+ /**
18
+ * Method used to get the page by slug
19
+ */
20
+ const getPages = async () => {
21
+ setCmsState({ ...cmsState, loading: true })
22
+ try {
23
+ const propsToFetch = ['name', 'enabled']
24
+ let pages: any = []
25
+ const { content: { error, result } } = await ordering.pages().select(propsToFetch).get()
26
+ if (!error) {
27
+ const promises = result.map((item: any) => getPage(item.id));
28
+ pages = await Promise.all(promises)
29
+ }
30
+ setCmsState({
31
+ ...cmsState,
32
+ loading: false,
33
+ error: error ? typeof result === 'string' ? result : result[0] : null,
34
+ items: error ? [] : result.filter((i: any) => i.enabled).map((item: any) => ({ id: item.id, name: item.name })),
35
+ pages
36
+ })
37
+ } catch (err: any) {
38
+ setCmsState({
39
+ ...cmsState,
40
+ loading: false,
41
+ error: err?.message ?? err
42
+ })
43
+ }
44
+ }
45
+
46
+ const getPage = async (id: number) => {
47
+ try {
48
+ const { content: { error, result } } = await ordering.pages(id).get()
49
+ return error ? null : { id, body: result?.body }
50
+ } catch {
51
+ return null
52
+ }
53
+ }
54
+
55
+ useEffect(() => {
56
+ getPages()
57
+ }, [])
58
+
59
+ return (
60
+ <>
61
+ {UIComponent && (
62
+ <UIComponent
63
+ {...props}
64
+ cmsState={cmsState}
65
+ />
66
+ )}
67
+ </>
68
+ )
69
+ }
70
+
71
+ CmsContent.propTypes = {
72
+ /**
73
+ * UI Component, this must be containt all graphic elements and use parent props
74
+ */
75
+ UIComponent: PropTypes.elementType
76
+ }