ordering-ui-react-native 0.21.97 → 0.21.98-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 (161) hide show
  1. package/package.json +6 -7
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/BusinessesListing/index.tsx +1 -1
  4. package/src/components/StripeMethodForm/index.tsx +6 -4
  5. package/src/components/VerifyPhone/styles.tsx +1 -2
  6. package/src/context/OfflineActions/index.tsx +236 -0
  7. package/src/types/index.tsx +3 -1
  8. package/themes/business/index.tsx +2 -0
  9. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +9 -6
  10. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +1 -0
  11. package/themes/business/src/components/BusinessController/index.tsx +8 -3
  12. package/themes/business/src/components/BusinessProductList/index.tsx +2 -1
  13. package/themes/business/src/components/Chat/index.tsx +15 -3
  14. package/themes/business/src/components/DriverMap/index.tsx +49 -27
  15. package/themes/business/src/components/FloatingButton/index.tsx +3 -2
  16. package/themes/business/src/components/GoogleMap/index.tsx +15 -8
  17. package/themes/business/src/components/LanguageSelector/index.tsx +2 -3
  18. package/themes/business/src/components/LanguageSelector/lang_country.json +515 -70
  19. package/themes/business/src/components/LogoutButton/index.tsx +1 -1
  20. package/themes/business/src/components/MapView/index.tsx +36 -17
  21. package/themes/business/src/components/NewOrderNotification/index.tsx +40 -27
  22. package/themes/business/src/components/OrderDetails/Business.tsx +74 -9
  23. package/themes/business/src/components/OrderDetails/Delivery.tsx +138 -55
  24. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +125 -43
  25. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +62 -24
  26. package/themes/business/src/components/OrderDetails/styles.tsx +39 -3
  27. package/themes/business/src/components/OrderDetails/usePrinterCommands.tsx +221 -0
  28. package/themes/business/src/components/OrderDetailsLogistic/index.tsx +3 -2
  29. package/themes/business/src/components/OrderSummary/index.tsx +210 -65
  30. package/themes/business/src/components/OrdersListManager/index.tsx +13 -1
  31. package/themes/business/src/components/OrdersOption/index.tsx +217 -156
  32. package/themes/business/src/components/PhoneInputNumber/index.tsx +8 -5
  33. package/themes/business/src/components/PreviousMessages/index.tsx +26 -3
  34. package/themes/business/src/components/PreviousOrders/OrderItem.tsx +39 -16
  35. package/themes/business/src/components/PreviousOrders/index.tsx +76 -66
  36. package/themes/business/src/components/PrinterEdition/MessageAlert.tsx +33 -0
  37. package/themes/business/src/components/PrinterEdition/index.tsx +431 -0
  38. package/themes/business/src/components/PrinterEdition/printerList.tsx +23 -0
  39. package/themes/business/src/components/PrinterEdition/styles.tsx +61 -0
  40. package/themes/business/src/components/PrinterSettings/index.tsx +267 -0
  41. package/themes/business/src/components/PrinterSettings/styles.tsx +30 -0
  42. package/themes/business/src/components/ReviewCustomer/index.tsx +2 -0
  43. package/themes/business/src/components/StoresList/index.tsx +2 -2
  44. package/themes/business/src/components/UserFormDetails/index.tsx +111 -107
  45. package/themes/business/src/components/UserProfileForm/index.tsx +43 -25
  46. package/themes/business/src/components/WebsocketStatus/index.tsx +2 -2
  47. package/themes/business/src/components/shared/OTextarea.tsx +8 -9
  48. package/themes/business/src/hooks/useLocation.tsx +2 -2
  49. package/themes/business/src/layouts/SafeAreaContainer.tsx +35 -19
  50. package/themes/business/src/types/index.tsx +15 -5
  51. package/themes/business/src/utils/index.tsx +25 -1
  52. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  53. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  54. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  55. package/themes/kiosk/src/components/Checkout/index.tsx +6 -0
  56. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  57. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  58. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
  59. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  60. package/themes/original/index.tsx +11 -0
  61. package/themes/original/src/components/AddressForm/index.tsx +32 -17
  62. package/themes/original/src/components/AddressList/index.tsx +8 -7
  63. package/themes/original/src/components/AnalyticsSegment/index.tsx +6 -6
  64. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  65. package/themes/original/src/components/BusinessBasicInformation/index.tsx +5 -8
  66. package/themes/original/src/components/BusinessController/index.tsx +5 -5
  67. package/themes/original/src/components/BusinessItemAccordion/index.tsx +13 -5
  68. package/themes/original/src/components/BusinessListingSearch/BusinessSearchFooter.tsx +2 -3
  69. package/themes/original/src/components/BusinessListingSearch/BusinessSearchHeader.tsx +1 -3
  70. package/themes/original/src/components/BusinessListingSearch/index.tsx +1 -2
  71. package/themes/original/src/components/BusinessPreorder/index.tsx +20 -15
  72. package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/index.tsx +73 -70
  73. package/themes/original/src/components/BusinessProductsList/index.tsx +6 -7
  74. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  75. package/themes/original/src/components/BusinessProductsListing/index.tsx +18 -6
  76. package/themes/original/src/components/BusinessTypeFilter/index.tsx +9 -8
  77. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +2 -1
  78. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +1 -1
  79. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +1 -1
  80. package/themes/original/src/components/BusinessesListing/index.tsx +0 -1
  81. package/themes/original/src/components/Cart/index.tsx +38 -14
  82. package/themes/original/src/components/CartContent/index.tsx +2 -4
  83. package/themes/original/src/components/Checkout/index.tsx +102 -58
  84. package/themes/original/src/components/CitiesControl/index.tsx +0 -3
  85. package/themes/original/src/components/CouponControl/index.tsx +1 -3
  86. package/themes/original/src/components/DriverTips/index.tsx +1 -3
  87. package/themes/original/src/components/Favorite/index.tsx +1 -5
  88. package/themes/original/src/components/FavoriteList/index.tsx +0 -1
  89. package/themes/original/src/components/ForgotPasswordForm/index.tsx +5 -7
  90. package/themes/original/src/components/GiftCard/GiftCardUI/index.tsx +15 -17
  91. package/themes/original/src/components/GiftCard/PurchaseGiftCard/index.tsx +3 -7
  92. package/themes/original/src/components/GiftCard/RedeemGiftCard/index.tsx +24 -32
  93. package/themes/original/src/components/GiftCard/SendGiftCard/index.tsx +7 -9
  94. package/themes/original/src/components/GiftCard/VerticalGiftCardOrdersLayout/index.tsx +11 -12
  95. package/themes/original/src/components/GoogleMap/index.tsx +39 -18
  96. package/themes/original/src/components/Help/index.tsx +2 -0
  97. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +1 -1
  98. package/themes/original/src/components/Home/index.tsx +3 -11
  99. package/themes/original/src/components/LoginForm/Otp/index.tsx +0 -3
  100. package/themes/original/src/components/LoginForm/index.tsx +4 -7
  101. package/themes/original/src/components/MessageListing/index.tsx +2 -1
  102. package/themes/original/src/components/Messages/index.tsx +29 -17
  103. package/themes/original/src/components/MomentOption/index.tsx +13 -2
  104. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +7 -3
  105. package/themes/original/src/components/MultiCheckout/index.tsx +55 -27
  106. package/themes/original/src/components/MultiOrdersDetails/index.tsx +1 -0
  107. package/themes/original/src/components/MyOrders/index.tsx +2 -2
  108. package/themes/original/src/components/NavBar/index.tsx +7 -4
  109. package/themes/original/src/components/NetworkError/index.tsx +0 -5
  110. package/themes/original/src/components/NotFoundSource/index.tsx +0 -3
  111. package/themes/original/src/components/OrderDetails/OrderEta.tsx +4 -3
  112. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +13 -10
  113. package/themes/original/src/components/OrderDetails/index.tsx +42 -19
  114. package/themes/original/src/components/OrderDetails/styles.tsx +0 -1
  115. package/themes/original/src/components/OrderProgress/index.tsx +14 -7
  116. package/themes/original/src/components/OrderSummary/index.tsx +29 -10
  117. package/themes/original/src/components/OrderTypeSelector/index.tsx +7 -6
  118. package/themes/original/src/components/OrdersOption/index.tsx +3 -6
  119. package/themes/original/src/components/PaymentOptionStripe/index.tsx +0 -5
  120. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  121. package/themes/original/src/components/PaymentOptions/index.tsx +14 -9
  122. package/themes/original/src/components/PlaceSpot/index.tsx +1 -3
  123. package/themes/original/src/components/PreviousOrders/index.tsx +1 -2
  124. package/themes/original/src/components/ProductForm/ActionButton.tsx +17 -20
  125. package/themes/original/src/components/ProductForm/index.tsx +107 -102
  126. package/themes/original/src/components/ProductItemAccordion/index.tsx +51 -44
  127. package/themes/original/src/components/ProductItemAccordion/styles.tsx +3 -4
  128. package/themes/original/src/components/ProductOptionSubOption/index.tsx +16 -8
  129. package/themes/original/src/components/ProfessionalProfile/index.tsx +4 -5
  130. package/themes/original/src/components/Promotions/index.tsx +6 -9
  131. package/themes/original/src/components/ReviewDriver/index.tsx +1 -1
  132. package/themes/original/src/components/ReviewOrder/index.tsx +2 -2
  133. package/themes/original/src/components/ReviewProducts/index.tsx +1 -1
  134. package/themes/original/src/components/ReviewTrigger/index.tsx +2 -2
  135. package/themes/original/src/components/ServiceForm/index.tsx +52 -54
  136. package/themes/original/src/components/Sessions/index.tsx +3 -3
  137. package/themes/original/src/components/SignupForm/index.tsx +86 -78
  138. package/themes/original/src/components/SingleOrderCard/index.tsx +6 -4
  139. package/themes/original/src/components/SingleProductCard/index.tsx +3 -4
  140. package/themes/original/src/components/SingleProductCard/styles.tsx +0 -3
  141. package/themes/original/src/components/StripeCardForm/index.tsx +0 -3
  142. package/themes/original/src/components/StripeCardsList/index.tsx +10 -3
  143. package/themes/original/src/components/StripeElementsForm/index.tsx +76 -60
  144. package/themes/original/src/components/StripeElementsForm/naked.tsx +48 -1
  145. package/themes/original/src/components/StripeRedirectForm/index.tsx +0 -3
  146. package/themes/original/src/components/TaxInformation/index.tsx +3 -2
  147. package/themes/original/src/components/UpsellingProducts/UpsellingContent.tsx +10 -7
  148. package/themes/original/src/components/UpsellingProducts/UpsellingLayout.tsx +8 -3
  149. package/themes/original/src/components/UserDetails/index.tsx +3 -2
  150. package/themes/original/src/components/UserFormDetails/index.tsx +154 -130
  151. package/themes/original/src/components/UserProfile/index.tsx +9 -1
  152. package/themes/original/src/components/UserVerification/index.tsx +2 -2
  153. package/themes/original/src/components/Wallets/index.tsx +6 -3
  154. package/themes/original/src/components/WebsocketStatus/index.tsx +1 -4
  155. package/themes/original/src/components/shared/OAlert.tsx +2 -1
  156. package/themes/original/src/components/shared/OButton.tsx +5 -4
  157. package/themes/original/src/components/shared/OInput.tsx +4 -8
  158. package/themes/original/src/components/shared/OModal.tsx +7 -2
  159. package/themes/original/src/types/index.tsx +5 -1
  160. package/themes/original/src/utils/index.tsx +30 -1
  161. 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,
@@ -102,7 +101,9 @@ const CheckoutUI = (props: any) => {
102
101
  merchantId,
103
102
  setPlaceSpotNumber,
104
103
  maxDate,
105
- urlscheme
104
+ androidAppId,
105
+ urlscheme,
106
+ checkoutFieldsState
106
107
  } = props
107
108
 
108
109
  const theme = useTheme();
@@ -144,12 +145,11 @@ const CheckoutUI = (props: any) => {
144
145
 
145
146
  const [, { showToast }] = useToast();
146
147
  const [, t] = useLanguage();
147
- const [{ user, token }, { login }] = useSession();
148
+ const [{ user, token, loading: userLoading }, { login }] = useSession();
148
149
  const [ordering] = useApi()
149
150
  const [{ configs }] = useConfig();
150
151
  const [{ parsePrice, parseDate }] = useUtils();
151
152
  const [{ options, carts, loading }, { confirmCart }] = useOrder();
152
- const [validationFields] = useValidationFields();
153
153
  const [events] = useEvent()
154
154
  const [orientationState] = useDeviceOrientation();
155
155
  const [isReadMore, setIsReadMore] = useState(false)
@@ -166,6 +166,7 @@ const CheckoutUI = (props: any) => {
166
166
  const [webviewPaymethod, setWebviewPaymethod] = useState<any>(null)
167
167
  const [isOpen, setIsOpen] = useState(false)
168
168
  const [requiredFields, setRequiredFields] = useState<any>([])
169
+ const [orderTypeValidationFields, setOrderTypeValidationFields] = useState<any>([])
169
170
  const [openModal, setOpenModal] = useState({ login: false, signup: false, isGuest: false })
170
171
  const [allowedGuest, setAllowedGuest] = useState(false)
171
172
  const [placeByMethodPay, setPlaceByMethodPay] = useState(false)
@@ -177,6 +178,14 @@ const CheckoutUI = (props: any) => {
177
178
  const containerRef = useRef<any>()
178
179
  const cardsMethods = ['credomatic']
179
180
  const stripePaymethods: any = ['stripe', 'stripe_direct', 'stripe_connect', 'stripe_redirect']
181
+ const notFields = ['coupon', 'driver_tip', 'mobile_phone', 'address', 'zipcode', 'address_notes', 'comments']
182
+
183
+ const checkoutFields = useMemo(() => checkoutFieldsState?.fields?.filter((field : any) => field.order_type_id === options?.type), [checkoutFieldsState, options])
184
+ const guestCheckoutDriveTip = useMemo(() => checkoutFields?.find((field : any) => field.order_type_id === 1 && field?.validation_field?.code === 'driver_tip'), [JSON.stringify(checkoutFields), options])
185
+ const guestCheckoutComment = useMemo(() => checkoutFields?.find((field : any) => field.order_type_id === options?.type && field?.validation_field?.code === 'comments'), [JSON.stringify(checkoutFields), options])
186
+ const guestCheckoutCoupon = useMemo(() => checkoutFields?.find((field : any) => field.order_type_id === options?.type && field?.validation_field?.code === 'coupon'), [JSON.stringify(checkoutFields), options])
187
+ const guestCheckoutZipcode = useMemo(() => checkoutFields?.find((field : any) => field.order_type_id === options?.type && field?.validation_field?.code === 'zipcode'), [JSON.stringify(checkoutFields), options])
188
+
180
189
  const placeSpotTypes = [3, 4, 5]
181
190
  const placeSpotsEnabled = placeSpotTypes.includes(options?.type)
182
191
  const businessConfigs = businessDetails?.business?.configs ?? []
@@ -201,27 +210,28 @@ const CheckoutUI = (props: any) => {
201
210
  return acc = acc
202
211
  }, cart?.subtotal)
203
212
 
204
- const validateCommentsCartField = validationFields?.fields?.checkout?.comments?.enabled && validationFields?.fields?.checkout?.comments?.required && (cart?.comment === null || cart?.comment?.trim().length === 0)
205
- const validateZipcodeCard = validationFields?.fields?.card?.zipcode?.enabled &&
206
- validationFields?.fields?.card?.zipcode?.required &&
207
- paymethodSelected?.data?.card &&
208
- !paymethodSelected?.data?.card?.zipcode &&
209
- paymethodSelected?.gateway === 'stripe'
213
+ const validateCommentsCartField = (guestCheckoutComment?.enabled && (user?.guest_id ? guestCheckoutComment?.required_with_guest : guestCheckoutComment?.required)) && (cart?.comment === null || cart?.comment?.trim().length === 0)
214
+ const validateDriverTipField = options.type === 1 && (guestCheckoutDriveTip?.enabled && (user?.guest_id ? guestCheckoutDriveTip?.required_with_guest : guestCheckoutDriveTip?.required)) && (Number(cart?.driver_tip) <= 0)
215
+ const validateCouponField = (guestCheckoutCoupon?.enabled && (user?.guest_id ? guestCheckoutCoupon?.required_with_guest : guestCheckoutCoupon?.required)) && !cart?.offers?.some((offer : any) => offer?.type === 2)
216
+ const validateZipcodeCard = (guestCheckoutZipcode?.enabled && (user?.guest_id ? guestCheckoutZipcode?.required_with_guest : guestCheckoutZipcode?.required)) && paymethodSelected?.gateway === 'stripe' && paymethodSelected?.data?.card && !paymethodSelected?.data?.card?.zipcode
210
217
 
211
218
  const isDisabledButtonPlace = loading || !cart?.valid || (!paymethodSelected && cart?.balance > 0) ||
212
219
  placing || errorCash || subtotalWithTaxes < cart?.minimum ||
213
220
  (cardsMethods.includes(paymethodSelected?.gateway) && cardList?.cards?.length === 0) ||
214
- (options.type === 1 && !isGiftCardCart &&
215
- validationFields?.fields?.checkout?.driver_tip?.enabled &&
216
- validationFields?.fields?.checkout?.driver_tip?.required &&
217
- (Number(cart?.driver_tip) <= 0)) ||
218
221
  (validateCommentsCartField) ||
219
- (validateZipcodeCard)
220
- || (methodsPay.includes(paymethodSelected?.gateway) && (!methodPaySupported.enabled || methodPaySupported.loading))
222
+ (validateDriverTipField && !isGiftCardCart) ||
223
+ (validateZipcodeCard) ||
224
+ (methodsPay.includes(paymethodSelected?.gateway) && (!methodPaySupported.enabled || methodPaySupported.loading)) ||
225
+ validateCommentsCartField ||
226
+ validateDriverTipField ||
227
+ validateCouponField ||
228
+ validateZipcodeCard
229
+
221
230
 
222
231
  const driverTipsOptions = typeof configs?.driver_tip_options?.value === 'string'
223
232
  ? JSON.parse(configs?.driver_tip_options?.value) || []
224
233
  : configs?.driver_tip_options?.value || []
234
+ const driverTipsField = !cartState.loading && cart && cart?.business_id && options.type === 1 && cart?.status !== 2 && (guestCheckoutDriveTip?.enabled) && driverTipsOptions.length > 0
225
235
 
226
236
  const configTypes = configs?.order_types_allowed?.value.split('|').map((value: any) => Number(value)) || []
227
237
 
@@ -242,7 +252,7 @@ const CheckoutUI = (props: any) => {
242
252
  }
243
253
  }
244
254
 
245
- const vibrateApp = (impact?: string) => {
255
+ const vibrateApp = (impact?: HapticFeedbackTypes) => {
246
256
  const options = {
247
257
  enableVibrateFallback: true,
248
258
  ignoreAndroidSystemSettings: false
@@ -269,7 +279,7 @@ const CheckoutUI = (props: any) => {
269
279
  return
270
280
  }
271
281
 
272
- if (!userErrors.length && (!requiredFields?.length || allowedGuest) || forcePlace) {
282
+ if (!userErrors.length && (!requiredFields?.length) || forcePlace) {
273
283
  vibrateApp()
274
284
  handlerClickPlaceOrder && handlerClickPlaceOrder(null, { isNative: true }, confirmPayment, NativeStripeSdk?.dismissPlatformPay)
275
285
  return
@@ -308,35 +318,55 @@ const CheckoutUI = (props: any) => {
308
318
 
309
319
  const checkValidationFields = () => {
310
320
  setUserErrors([])
311
- const errors = []
312
- const notFields = ['coupon', 'driver_tip', 'mobile_phone', 'address', 'zipcode', 'address_notes', 'comments']
313
- const _requiredFields: any = []
314
-
315
- Object.values(validationFields?.fields?.checkout).map((field: any) => {
316
- if (field?.required && !notFields.includes(field.code) && field?.enabled) {
317
- if (!user[field?.code]) {
318
- _requiredFields.push(field?.code)
321
+ const errors: Array<string> = []
322
+ const userSelected = user
323
+ const _requiredFields: Array<string> = []
324
+ Object.values(checkoutFieldsState?.fields).map((field: any) => {
325
+ if (options?.type === field?.order_type_id &&
326
+ field?.enabled &&
327
+ field?.required &&
328
+ !notFields.includes(field?.validation_field?.code)
329
+ ) {
330
+ if (userSelected && !userSelected[field?.validation_field?.code]) {
331
+ _requiredFields.push(field?.validation_field?.code)
319
332
  }
320
333
  }
321
334
  })
322
-
335
+ const mobilePhoneField: any = Object.values(checkoutFieldsState?.fields)?.find((field: any) => field?.order_type_id === options?.type && field?.validation_field?.code === 'mobile_phone')
323
336
  if (
324
- !user?.cellphone &&
325
- ((validationFields?.fields?.checkout?.cellphone?.enabled &&
326
- validationFields?.fields?.checkout?.cellphone?.required) ||
337
+ userSelected &&
338
+ !userSelected?.cellphone &&
339
+ ((mobilePhoneField?.enabled &&
340
+ mobilePhoneField?.required) ||
327
341
  configs?.verification_phone_required?.value === '1')
328
342
  ) {
329
343
  _requiredFields.push('cellphone')
330
344
  }
331
345
  setRequiredFields(_requiredFields)
332
346
 
333
- if (phoneUpdate) {
334
- errors.push(t('NECESSARY_UPDATE_COUNTRY_PHONE_CODE', 'It is necessary to update your phone number'))
335
- }
336
-
337
347
  setUserErrors(errors)
338
348
  }
339
349
 
350
+ const checkGuestValidationFields = () => {
351
+ const userSelected = user
352
+ const _requiredFields = checkoutFieldsState?.fields
353
+ .filter((field) => (field?.order_type_id === options?.type) && field?.enabled && field?.required_with_guest &&
354
+ !notFields.includes(field?.validation_field?.code) &&
355
+ userSelected && !userSelected[field?.validation_field?.code])
356
+ const requiredFieldsCode = _requiredFields.map((item) => item?.validation_field?.code)
357
+ const guestCheckoutCellPhone = checkoutFieldsState?.fields?.find((field) => field.order_type_id === options?.type && field?.validation_field?.code === 'mobile_phone')
358
+ if (
359
+ userSelected &&
360
+ !userSelected?.cellphone &&
361
+ ((guestCheckoutCellPhone?.enabled &&
362
+ guestCheckoutCellPhone?.required_with_guest) ||
363
+ configs?.verification_phone_required?.value === '1')
364
+ ) {
365
+ requiredFieldsCode.push('cellphone')
366
+ }
367
+ setRequiredFields(requiredFieldsCode)
368
+ }
369
+
340
370
  const togglePhoneUpdate = (val: boolean) => {
341
371
  setPhoneUpdate(val)
342
372
  }
@@ -345,11 +375,20 @@ const CheckoutUI = (props: any) => {
345
375
  setShowTitle(contentOffset.y > 30)
346
376
  }
347
377
 
378
+ const handleRedirect = () => {
379
+ props.fromProductsList
380
+ ? navigation?.goBack()
381
+ : onNavigationRedirect('BottomTab', { screen: 'Cart' }, !props.fromMulti)
382
+ }
383
+
348
384
  useEffect(() => {
349
- if (validationFields && validationFields?.fields?.checkout) {
385
+ if (checkoutFieldsState?.loading || userLoading) return
386
+ if (user?.guest_id) {
387
+ checkGuestValidationFields()
388
+ } else {
350
389
  checkValidationFields()
351
390
  }
352
- }, [validationFields, user])
391
+ }, [checkoutFieldsState, user, options?.type])
353
392
 
354
393
  useEffect(() => {
355
394
  if (errors) {
@@ -455,7 +494,7 @@ const CheckoutUI = (props: any) => {
455
494
  <SafeAreaView style={{ backgroundColor: theme.colors.backgroundPage }}>
456
495
  <View style={styles.wrapperNavbar}>
457
496
  <TopHeader>
458
- <TopActions onPress={() => onNavigationRedirect('BottomTab', { screen: 'Cart' }, !props.fromMulti)}>
497
+ <TopActions onPress={() => handleRedirect()}>
459
498
  <IconAntDesign
460
499
  name='arrowleft'
461
500
  size={26}
@@ -481,7 +520,7 @@ const CheckoutUI = (props: any) => {
481
520
  hideArrowLeft
482
521
  title={t('CHECKOUT', 'Checkout')}
483
522
  titleAlign={'center'}
484
- onActionLeft={() => onNavigationRedirect('BottomTab', { screen: 'Cart' }, !props.fromMulti)}
523
+ onActionLeft={() => handleRedirect()}
485
524
  showCall={false}
486
525
  btnStyle={{ paddingLeft: 0, paddingTop: Platform.OS == 'ios' ? 0 : 2 }}
487
526
  titleWrapStyle={{ paddingHorizontal: 0 }}
@@ -618,15 +657,11 @@ const CheckoutUI = (props: any) => {
618
657
  <HeaderTitle text={t('CUSTOMER_DETAILS', 'Customer details')} />
619
658
  <OButton
620
659
  text={t('SIGN_UP', 'Sign up')}
621
- textStyle={{ color: theme.colors.white }}
622
660
  style={{ borderRadius: 7.6, marginTop: 20 }}
623
661
  onClick={() => setOpenModal({ ...openModal, signup: true })}
624
662
  />
625
663
  <OButton
626
664
  text={t('LOGIN', 'Login')}
627
- textStyle={{ color: theme.colors.primary }}
628
- bgColor={theme.colors.white}
629
- borderColor={theme.colors.primary}
630
665
  style={{ borderRadius: 7.6, marginTop: 20 }}
631
666
  onClick={() => setOpenModal({ ...openModal, login: true })}
632
667
  />
@@ -651,6 +686,9 @@ const CheckoutUI = (props: any) => {
651
686
  isCheckout
652
687
  phoneUpdate={phoneUpdate}
653
688
  togglePhoneUpdate={togglePhoneUpdate}
689
+ isOrderTypeValidationField
690
+ requiredFields={requiredFields}
691
+ checkoutFields={checkoutFields}
654
692
  />
655
693
  )
656
694
  )}
@@ -748,6 +786,7 @@ const CheckoutUI = (props: any) => {
748
786
  </Placeholder>
749
787
  ) : (
750
788
  <AddressDetails
789
+ cart={cart}
751
790
  navigation={navigation}
752
791
  location={options?.address?.location}
753
792
  businessLogo={businessDetails?.business?.logo}
@@ -763,14 +802,7 @@ const CheckoutUI = (props: any) => {
763
802
  </ChSection>
764
803
  )}
765
804
 
766
- {!cartState.loading &&
767
- cart &&
768
- cart?.valid &&
769
- options.type === 1 &&
770
- cart?.status !== 2 &&
771
- validationFields?.fields?.checkout?.driver_tip?.enabled &&
772
- driverTipsOptions && driverTipsOptions?.length > 0 &&
773
- !isGiftCardCart &&
805
+ {driverTipsField &&
774
806
  (
775
807
  <ChSection>
776
808
  <ChDriverTips>
@@ -819,6 +851,7 @@ const CheckoutUI = (props: any) => {
819
851
  handlePlaceOrder={handlePlaceOrder}
820
852
  merchantId={merchantId}
821
853
  urlscheme={urlscheme}
854
+ androidAppId={androidAppId}
822
855
  setMethodPaySupported={setMethodPaySupported}
823
856
  methodPaySupported={methodPaySupported}
824
857
  placeByMethodPay={placeByMethodPay}
@@ -914,6 +947,8 @@ const CheckoutUI = (props: any) => {
914
947
  creditPointPlanOnBusiness?.accumulation_rate ??
915
948
  (!!creditPointPlanOnBusiness && creditPointPlan?.accumulation_rate) ?? 0
916
949
  }
950
+ hideCommentsByValidationCheckout={!guestCheckoutComment?.enabled}
951
+ hideCouponByValidationCheckout={!guestCheckoutCoupon?.enabled}
917
952
  />
918
953
  </>
919
954
  )}
@@ -960,10 +995,8 @@ const CheckoutUI = (props: any) => {
960
995
  {t('INVALID_CART_MOMENT', 'Selected schedule time is invalid, please select a schedule into the business schedule interval.')}
961
996
  </OText>
962
997
  )}
963
- {options.type === 1 && !isGiftCardCart &&
964
- validationFields?.fields?.checkout?.driver_tip?.enabled &&
965
- validationFields?.fields?.checkout?.driver_tip?.required &&
966
- (Number(cart?.driver_tip) <= 0) && (
998
+ {validateDriverTipField && !isGiftCardCart &&
999
+ (
967
1000
  <OText
968
1001
  color={theme.colors.error}
969
1002
  size={12}
@@ -971,7 +1004,6 @@ const CheckoutUI = (props: any) => {
971
1004
  {t('WARNING_INVALID_DRIVER_TIP', 'Driver Tip is required.')}
972
1005
  </OText>
973
1006
  )}
974
-
975
1007
  {validateCommentsCartField && (
976
1008
  <OText
977
1009
  color={theme.colors.error}
@@ -989,6 +1021,15 @@ const CheckoutUI = (props: any) => {
989
1021
  {t('WARNING_CARD_ZIPCODE_REQUIRED', 'Your card selected has not zipcode')}
990
1022
  </OText>
991
1023
  )}
1024
+ {validateCouponField &&
1025
+ (
1026
+ <OText
1027
+ color={theme.colors.error}
1028
+ size={12}
1029
+ >
1030
+ {t('WARNING_INVALID_COUPON_FIELD', 'Coupon is required.')}
1031
+ </OText>
1032
+ )}
992
1033
  </ChErrors>
993
1034
  </View>
994
1035
  )}
@@ -1006,20 +1047,23 @@ const CheckoutUI = (props: any) => {
1006
1047
  <OModal
1007
1048
  open={isOpen}
1008
1049
  onClose={() => setIsOpen(false)}
1050
+ showToastInsideModal
1009
1051
  >
1010
1052
  <View style={styles.detailWrapper}>
1011
1053
  <UserDetails
1012
1054
  isUserDetailsEdit
1013
1055
  cartStatus={cart?.status}
1014
1056
  businessId={cart?.business_id}
1015
- useValidationFields
1016
1057
  useDefualtSessionManager
1017
1058
  useSessionUser
1018
1059
  isCheckout
1019
1060
  isEdit
1020
1061
  phoneUpdate={phoneUpdate}
1021
1062
  togglePhoneUpdate={togglePhoneUpdate}
1063
+ isOrderTypeValidationField
1022
1064
  requiredFields={requiredFields}
1065
+ checkoutFields={checkoutFields}
1066
+ isCheckoutPlace
1023
1067
  hideUpdateButton
1024
1068
  handlePlaceOrderAsGuest={handlePlaceOrderAsGuest}
1025
1069
  onClose={() => {
@@ -69,10 +69,7 @@ export const CitiesControl = (props: any) => {
69
69
  </View>
70
70
  <OButton
71
71
  text={t('CONTINUE', 'Continue')}
72
- bgColor={theme.colors.primary}
73
- borderColor={theme.colors.primary}
74
72
  style={styles.btnStyle}
75
- textStyle={{ color: 'white' }}
76
73
  onClick={() => handleClick()}
77
74
  />
78
75
  </Container>
@@ -102,9 +102,7 @@ const CouponControlUI = (props: any) => {
102
102
  />
103
103
  <OButton
104
104
  onClick={() => onButtonApplyClick()}
105
- bgColor={theme.colors.primary}
106
- borderColor={theme.colors.primary}
107
- textStyle={{ color: 'white', fontSize: 12 }}
105
+ textStyle={{ fontSize: 12 }}
108
106
  imgRightSrc={null}
109
107
  text={t('APPLY', 'Apply')}
110
108
  isDisabled={!couponInput}
@@ -125,9 +125,7 @@ const DriverTipsUI = (props: any) => {
125
125
  />
126
126
  <OButton
127
127
  text={t('APPLY_TIP', 'Apply Tip')}
128
- bgColor={theme.colors.primary}
129
- borderColor={theme.colors.primary}
130
- textStyle={{ color: 'white', fontSize: 14 }}
128
+ textStyle={{ fontSize: 14 }}
131
129
  imgRightSrc={null}
132
130
  style={{ borderRadius: 5, height: 44 }}
133
131
  isDisabled={parseFloat(value || '0') < 0 || parseFloat(value || '0') === driverTip || value === ''}
@@ -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>
@@ -270,7 +270,6 @@ const FavoriteListUI = (props: FavoriteParams) => {
270
270
  onClick={() => getFavoriteList(pagination?.currentPage + 1)}
271
271
  text={t('LOAD_MORE_ITEMS', 'Load more items')}
272
272
  imgRightSrc={null}
273
- textStyle={{ color: theme.colors.white }}
274
273
  style={{ borderRadius: 7.6, shadowOpacity: 0, marginTop: 20 }}
275
274
  />
276
275
  </WrappButton>
@@ -64,7 +64,7 @@ const ForgotPasswordUI = (props: any) => {
64
64
  handleReCaptcha(null)
65
65
  if (reCaptchaValue) return
66
66
 
67
- if (!recaptchaConfig?.siteKey) {
67
+ if (!recaptchaConfig?.siteKey) {
68
68
  showToast(ToastType.Error, t('NO_RECAPTCHA_SITE_KEY', 'The config doesn\'t have recaptcha site key'));
69
69
  return
70
70
  }
@@ -73,7 +73,7 @@ const ForgotPasswordUI = (props: any) => {
73
73
  return
74
74
  }
75
75
  recaptchaRef.current.open()
76
- }
76
+ }
77
77
 
78
78
  const onRecaptchaVerify = (token: any) => {
79
79
  setRecaptchaVerified(true)
@@ -92,8 +92,8 @@ const ForgotPasswordUI = (props: any) => {
92
92
  formState.result?.result && showToast(
93
93
  ToastType.Error,
94
94
  typeof formState.result?.result === 'string'
95
- ? formState.result?.result
96
- : formState.result?.result[0]
95
+ ? formState.result?.result
96
+ : formState.result?.result[0]
97
97
  )
98
98
  return
99
99
  }
@@ -208,9 +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
- textStyle={{ color: 'white' }}
212
- bgColor={emailSent && !formState.result?.error ? theme.colors.disabled : theme.colors.primary}
213
- borderColor={emailSent && !formState.result?.error ? theme.colors.disabled : theme.colors.primary}
211
+ isDisabled={formState.loading || emailSent && !formState.result?.error}
214
212
  isLoading={formState.loading}
215
213
  imgRightSrc={null}
216
214
  onClick={emailSent && !formState.result?.error ? () => { } : handleSubmit(onSubmit)}
@@ -12,7 +12,7 @@ import {
12
12
  Container
13
13
  } from './styles'
14
14
 
15
- export const GiftCardUI = React.memo((props: any) => {
15
+ export const GiftCardUI = React.memo((props: any) => {
16
16
  const {
17
17
  navigation
18
18
  } = props
@@ -57,9 +57,7 @@ export const GiftCardUI = React.memo((props: any) => {
57
57
  <OButton
58
58
  onClick={() => setOpenModal('purchase')}
59
59
  text={t('PURCHASE', 'Purchase')}
60
- bgColor={theme.colors.primary}
61
- borderColor={theme.colors.primary}
62
- textStyle={{ color: 'white', fontSize: 13 }}
60
+ textStyle={{ fontSize: 13 }}
63
61
  imgRightSrc={null}
64
62
  style={{ ...style.btnStyle, marginRight: 14 }}
65
63
  />
@@ -76,26 +74,26 @@ export const GiftCardUI = React.memo((props: any) => {
76
74
  </View>
77
75
 
78
76
  <OModal
79
- open={openModal === 'purchase'}
80
- onClose={() => setOpenModal(null)}
81
- entireModal
77
+ open={openModal === 'purchase'}
78
+ onClose={() => setOpenModal(null)}
79
+ entireModal
82
80
  customClose
83
- >
84
- <PurchaseGiftCard
81
+ >
82
+ <PurchaseGiftCard
85
83
  handleCustomGoToCheckout={handleCustomGoToCheckout}
86
84
  onClose={() => setOpenModal(null)}
87
85
  />
88
- </OModal>
86
+ </OModal>
89
87
  <OModal
90
- open={openModal === 'redeem'}
91
- onClose={() => setOpenModal(null)}
92
- entireModal
88
+ open={openModal === 'redeem'}
89
+ onClose={() => setOpenModal(null)}
90
+ entireModal
93
91
  customClose
94
- >
95
- <RedeemGiftCard
92
+ >
93
+ <RedeemGiftCard
96
94
  onClose={() => setOpenModal(null)}
97
95
  />
98
- </OModal>
96
+ </OModal>
99
97
  </Container>
100
98
  )
101
- })
99
+ })
@@ -58,12 +58,10 @@ const PurchaseGiftCardUI = (props: any) => {
58
58
  borderWidth: 0,
59
59
  width: 26,
60
60
  height: 26,
61
- backgroundColor: '#FFF',
62
- borderColor: '#FFF',
63
- shadowColor: '#FFF',
64
61
  paddingLeft: 0,
65
62
  paddingRight: 0,
66
63
  }}
64
+ useArrow
67
65
  onClick={onClose}
68
66
  icon={AntDesignIcon}
69
67
  iconProps={{
@@ -113,9 +111,7 @@ const PurchaseGiftCardUI = (props: any) => {
113
111
  <OButton
114
112
  onClick={() => handleAccept()}
115
113
  text={t('ACCEPT', 'Accept')}
116
- bgColor={theme.colors.primary}
117
- borderColor={theme.colors.primary}
118
- textStyle={{ color: 'white', fontSize: 13 }}
114
+ textStyle={{ fontSize: 13 }}
119
115
  imgRightSrc={null}
120
116
  style={style.btnStyle}
121
117
  isDisabled={!selectedProduct}
@@ -130,4 +126,4 @@ export const PurchaseGiftCard = (props: any) => {
130
126
  UIComponent: PurchaseGiftCardUI
131
127
  }
132
128
  return <PurchaseGiftCardController {...purchaseGiftCardProps} />
133
- }
129
+ }