ordering-ui-react-native 0.22.21 → 0.22.22-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 (164) 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/Checkout/index.tsx +40 -39
  5. package/src/components/StripeMethodForm/index.tsx +4 -2
  6. package/src/components/VerifyPhone/styles.tsx +1 -2
  7. package/src/context/OfflineActions/index.tsx +236 -0
  8. package/src/types/index.tsx +2 -1
  9. package/themes/business/index.tsx +2 -0
  10. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +9 -6
  11. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +1 -0
  12. package/themes/business/src/components/BusinessController/index.tsx +8 -3
  13. package/themes/business/src/components/BusinessProductList/index.tsx +3 -2
  14. package/themes/business/src/components/Chat/index.tsx +15 -3
  15. package/themes/business/src/components/DriverMap/index.tsx +49 -26
  16. package/themes/business/src/components/FloatingButton/index.tsx +3 -2
  17. package/themes/business/src/components/GoogleMap/index.tsx +15 -8
  18. package/themes/business/src/components/LanguageSelector/index.tsx +2 -3
  19. package/themes/business/src/components/LanguageSelector/lang_country.json +515 -70
  20. package/themes/business/src/components/LogoutButton/index.tsx +1 -1
  21. package/themes/business/src/components/MapView/index.tsx +36 -17
  22. package/themes/business/src/components/NewOrderNotification/index.tsx +38 -19
  23. package/themes/business/src/components/OrderDetails/Business.tsx +47 -27
  24. package/themes/business/src/components/OrderDetails/Delivery.tsx +134 -53
  25. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +128 -41
  26. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +45 -18
  27. package/themes/business/src/components/OrderDetails/styles.tsx +39 -3
  28. package/themes/business/src/components/OrderDetails/usePrinterCommands.tsx +17 -16
  29. package/themes/business/src/components/OrderDetailsLogistic/index.tsx +3 -2
  30. package/themes/business/src/components/OrderSummary/index.tsx +6 -4
  31. package/themes/business/src/components/OrdersListManager/index.tsx +13 -1
  32. package/themes/business/src/components/OrdersOption/index.tsx +217 -156
  33. package/themes/business/src/components/PhoneInputNumber/index.tsx +8 -5
  34. package/themes/business/src/components/PreviousMessages/index.tsx +26 -3
  35. package/themes/business/src/components/PreviousOrders/OrderItem.tsx +39 -16
  36. package/themes/business/src/components/PreviousOrders/index.tsx +74 -66
  37. package/themes/business/src/components/PrinterEdition/MessageAlert.tsx +33 -0
  38. package/themes/business/src/components/PrinterEdition/index.tsx +431 -0
  39. package/themes/business/src/components/PrinterEdition/printerList.tsx +23 -0
  40. package/themes/business/src/components/PrinterEdition/styles.tsx +61 -0
  41. package/themes/business/src/components/PrinterSettings/index.tsx +162 -174
  42. package/themes/business/src/components/PrinterSettings/styles.tsx +14 -1
  43. package/themes/business/src/components/ProductItemAccordion/index.tsx +3 -2
  44. package/themes/business/src/components/ReviewCustomer/index.tsx +2 -0
  45. package/themes/business/src/components/StoresList/index.tsx +2 -2
  46. package/themes/business/src/components/UserProfileForm/index.tsx +55 -22
  47. package/themes/business/src/components/UserProfileForm/styles.tsx +7 -0
  48. package/themes/business/src/components/WebsocketStatus/index.tsx +2 -2
  49. package/themes/business/src/components/shared/OTextarea.tsx +8 -9
  50. package/themes/business/src/config/currency.tsx +1010 -0
  51. package/themes/business/src/hooks/useLocation.tsx +16 -12
  52. package/themes/business/src/layouts/SafeAreaContainer.tsx +35 -19
  53. package/themes/business/src/types/index.tsx +16 -4
  54. package/themes/business/src/utils/index.tsx +33 -3
  55. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  56. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  57. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  58. package/themes/kiosk/src/components/Checkout/index.tsx +6 -0
  59. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  60. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  61. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
  62. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  63. package/themes/original/index.tsx +11 -0
  64. package/themes/original/src/components/AddressForm/index.tsx +32 -17
  65. package/themes/original/src/components/AddressList/index.tsx +8 -7
  66. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  67. package/themes/original/src/components/BusinessBasicInformation/index.tsx +5 -8
  68. package/themes/original/src/components/BusinessItemAccordion/index.tsx +13 -5
  69. package/themes/original/src/components/BusinessListingSearch/BusinessSearchFooter.tsx +103 -92
  70. package/themes/original/src/components/BusinessListingSearch/BusinessSearchHeader.tsx +8 -6
  71. package/themes/original/src/components/BusinessListingSearch/index.tsx +1 -2
  72. package/themes/original/src/components/BusinessPreorder/index.tsx +46 -28
  73. package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/index.tsx +73 -70
  74. package/themes/original/src/components/BusinessProductsList/index.tsx +6 -7
  75. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  76. package/themes/original/src/components/BusinessProductsListing/index.tsx +10 -6
  77. package/themes/original/src/components/BusinessTypeFilter/index.tsx +9 -8
  78. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +2 -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 +46 -14
  82. package/themes/original/src/components/CartContent/index.tsx +2 -4
  83. package/themes/original/src/components/Checkout/index.tsx +127 -77
  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 +12 -9
  101. package/themes/original/src/components/MessageListing/index.tsx +2 -1
  102. package/themes/original/src/components/Messages/index.tsx +27 -19
  103. package/themes/original/src/components/MomentOption/TimeListItem.tsx +56 -0
  104. package/themes/original/src/components/MomentOption/index.tsx +80 -51
  105. package/themes/original/src/components/MomentSelector/index.tsx +5 -2
  106. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +7 -3
  107. package/themes/original/src/components/MultiCheckout/index.tsx +55 -27
  108. package/themes/original/src/components/MultiOrdersDetails/index.tsx +1 -0
  109. package/themes/original/src/components/MyOrders/index.tsx +2 -2
  110. package/themes/original/src/components/NavBar/index.tsx +7 -4
  111. package/themes/original/src/components/NetworkError/index.tsx +0 -5
  112. package/themes/original/src/components/NotFoundSource/index.tsx +0 -3
  113. package/themes/original/src/components/OrderDetails/OrderEta.tsx +4 -3
  114. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +16 -11
  115. package/themes/original/src/components/OrderDetails/index.tsx +44 -21
  116. package/themes/original/src/components/OrderDetails/styles.tsx +0 -1
  117. package/themes/original/src/components/OrderProgress/index.tsx +4 -3
  118. package/themes/original/src/components/OrderSummary/index.tsx +29 -10
  119. package/themes/original/src/components/OrderTypeSelector/index.tsx +7 -6
  120. package/themes/original/src/components/OrdersOption/index.tsx +3 -6
  121. package/themes/original/src/components/PaymentOptionStripe/index.tsx +0 -5
  122. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  123. package/themes/original/src/components/PaymentOptions/index.tsx +4 -3
  124. package/themes/original/src/components/PhoneInputNumber/index.tsx +92 -7
  125. package/themes/original/src/components/PlaceSpot/index.tsx +1 -3
  126. package/themes/original/src/components/PreviousOrders/index.tsx +1 -2
  127. package/themes/original/src/components/ProductForm/ActionButton.tsx +17 -20
  128. package/themes/original/src/components/ProductForm/index.tsx +107 -102
  129. package/themes/original/src/components/ProductItemAccordion/index.tsx +50 -43
  130. package/themes/original/src/components/ProductItemAccordion/styles.tsx +0 -3
  131. package/themes/original/src/components/ProductOptionSubOption/index.tsx +16 -8
  132. package/themes/original/src/components/ProfessionalProfile/index.tsx +4 -5
  133. package/themes/original/src/components/Promotions/index.tsx +6 -9
  134. package/themes/original/src/components/ReviewDriver/index.tsx +1 -1
  135. package/themes/original/src/components/ReviewOrder/index.tsx +2 -2
  136. package/themes/original/src/components/ReviewProducts/index.tsx +1 -1
  137. package/themes/original/src/components/ReviewTrigger/index.tsx +2 -2
  138. package/themes/original/src/components/ServiceForm/index.tsx +52 -54
  139. package/themes/original/src/components/Sessions/index.tsx +3 -3
  140. package/themes/original/src/components/SignupForm/index.tsx +102 -88
  141. package/themes/original/src/components/SingleOrderCard/index.tsx +6 -4
  142. package/themes/original/src/components/SingleProductCard/index.tsx +5 -5
  143. package/themes/original/src/components/SingleProductCard/styles.tsx +0 -3
  144. package/themes/original/src/components/StripeCardForm/index.tsx +0 -3
  145. package/themes/original/src/components/StripeCardsList/index.tsx +16 -3
  146. package/themes/original/src/components/StripeElementsForm/index.tsx +76 -62
  147. package/themes/original/src/components/StripeElementsForm/naked.tsx +48 -1
  148. package/themes/original/src/components/StripeRedirectForm/index.tsx +0 -3
  149. package/themes/original/src/components/TaxInformation/index.tsx +3 -2
  150. package/themes/original/src/components/UpsellingProducts/UpsellingContent.tsx +10 -7
  151. package/themes/original/src/components/UpsellingProducts/UpsellingLayout.tsx +8 -3
  152. package/themes/original/src/components/UserDetails/index.tsx +17 -16
  153. package/themes/original/src/components/UserFormDetails/index.tsx +164 -135
  154. package/themes/original/src/components/UserProfile/index.tsx +9 -1
  155. package/themes/original/src/components/UserVerification/index.tsx +15 -4
  156. package/themes/original/src/components/Wallets/index.tsx +6 -3
  157. package/themes/original/src/components/WebsocketStatus/index.tsx +1 -4
  158. package/themes/original/src/components/shared/OAlert.tsx +2 -1
  159. package/themes/original/src/components/shared/OButton.tsx +5 -4
  160. package/themes/original/src/components/shared/OInput.tsx +4 -8
  161. package/themes/original/src/components/shared/OModal.tsx +7 -2
  162. package/themes/original/src/types/index.tsx +10 -3
  163. package/themes/original/src/utils/index.tsx +30 -1
  164. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
@@ -1,5 +1,5 @@
1
1
  import React, { useCallback, useEffect, useState } from 'react';
2
- import { View } from 'react-native';
2
+ import { Vibration, View } from 'react-native';
3
3
  import { useLanguage, useConfig, useUtils, useOrder } from 'ordering-components/native';
4
4
  import { useTheme } from 'styled-components/native';
5
5
  import { CCContainer, CCNotCarts, CCList, CheckoutAction, ChCartsTotal } from './styles';
@@ -39,6 +39,7 @@ export const CartContent = (props: any) => {
39
39
  ?.filter((cart: any) => cart?.status !== 1 && cart?.valid && cart?.products?.length)
40
40
  ?.reduce((total: any, cart: any) => { return total + (cart?.delivery_price_with_discount) }, 0)
41
41
  const handleCheckoutRedirect = () => {
42
+ Vibration.vibrate(100)
42
43
  if (cartsAvailable.length === 1) {
43
44
  onNavigationRedirect('CheckoutNavigator', {
44
45
  screen: 'CheckoutPage',
@@ -173,11 +174,8 @@ export const CartContent = (props: any) => {
173
174
  <CheckoutAction style={{ marginTop: 0 }}>
174
175
  <OButton
175
176
  text={t('CHECKOUT', 'Checkout')}
176
- bgColor={!cartsAvailable.length ? theme.colors.secundary : theme.colors.primary}
177
177
  isDisabled={!cartsAvailable.length}
178
- borderColor={theme.colors.primary}
179
178
  imgRightSrc={null}
180
- textStyle={{ color: 'white', textAlign: 'center', flex: 1 }}
181
179
  onClick={() => handleCheckoutRedirect()}
182
180
  style={{ width: '100%', flexDirection: 'row', justifyContent: 'center', borderRadius: 7.6, shadowOpacity: 0 }}
183
181
  />
@@ -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,
@@ -103,7 +102,8 @@ const CheckoutUI = (props: any) => {
103
102
  setPlaceSpotNumber,
104
103
  maxDate,
105
104
  androidAppId,
106
- urlscheme
105
+ urlscheme,
106
+ checkoutFieldsState
107
107
  } = props
108
108
 
109
109
  const theme = useTheme();
@@ -145,12 +145,11 @@ const CheckoutUI = (props: any) => {
145
145
 
146
146
  const [, { showToast }] = useToast();
147
147
  const [, t] = useLanguage();
148
- const [{ user, token }, { login }] = useSession();
148
+ const [{ user, token, loading: userLoading }, { login }] = useSession();
149
149
  const [ordering] = useApi()
150
150
  const [{ configs }] = useConfig();
151
151
  const [{ parsePrice, parseDate }] = useUtils();
152
152
  const [{ options, carts, loading }, { confirmCart }] = useOrder();
153
- const [validationFields] = useValidationFields();
154
153
  const [events] = useEvent()
155
154
  const [orientationState] = useDeviceOrientation();
156
155
  const [isReadMore, setIsReadMore] = useState(false)
@@ -167,6 +166,7 @@ const CheckoutUI = (props: any) => {
167
166
  const [webviewPaymethod, setWebviewPaymethod] = useState<any>(null)
168
167
  const [isOpen, setIsOpen] = useState(false)
169
168
  const [requiredFields, setRequiredFields] = useState<any>([])
169
+ const [orderTypeValidationFields, setOrderTypeValidationFields] = useState<any>([])
170
170
  const [openModal, setOpenModal] = useState({ login: false, signup: false, isGuest: false })
171
171
  const [allowedGuest, setAllowedGuest] = useState(false)
172
172
  const [placeByMethodPay, setPlaceByMethodPay] = useState(false)
@@ -175,9 +175,20 @@ const CheckoutUI = (props: any) => {
175
175
  const [showTitle, setShowTitle] = useState(false)
176
176
  const [cardList, setCardList] = useState<any>({ cards: [], loading: false, error: null })
177
177
  const [isGiftCardCart, setIsGiftCardCart] = useState(!cart?.business_id)
178
+ const [userHasCards, setUserHasCards] = useState(false)
178
179
  const containerRef = useRef<any>()
179
180
  const cardsMethods = ['credomatic']
180
- const stripePaymethods: any = ['stripe', 'stripe_direct', 'stripe_connect', 'stripe_redirect']
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
+
181
192
  const placeSpotTypes = [3, 4, 5]
182
193
  const placeSpotsEnabled = placeSpotTypes.includes(options?.type)
183
194
  const businessConfigs = businessDetails?.business?.configs ?? []
@@ -195,6 +206,7 @@ const CheckoutUI = (props: any) => {
195
206
  const creditPointPlanOnBusiness = creditPointPlan?.businesses?.find((b: any) => b.business_id === cart?.business_id && b.accumulates)
196
207
  const methodsPay = ['google_pay', 'apple_pay']
197
208
 
209
+ const commentDelayTime = 1500
198
210
  const isPreOrder = configs?.preorder_status_enabled?.value === '1'
199
211
  const subtotalWithTaxes = cart?.taxes?.reduce((acc: any, item: any) => {
200
212
  if (item?.type === 1)
@@ -202,27 +214,28 @@ const CheckoutUI = (props: any) => {
202
214
  return acc = acc
203
215
  }, cart?.subtotal)
204
216
 
205
- const validateCommentsCartField = validationFields?.fields?.checkout?.comments?.enabled && validationFields?.fields?.checkout?.comments?.required && (cart?.comment === null || cart?.comment?.trim().length === 0)
206
- const validateZipcodeCard = validationFields?.fields?.card?.zipcode?.enabled &&
207
- validationFields?.fields?.card?.zipcode?.required &&
208
- paymethodSelected?.data?.card &&
209
- !paymethodSelected?.data?.card?.zipcode &&
210
- 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
211
221
 
212
222
  const isDisabledButtonPlace = loading || !cart?.valid || (!paymethodSelected && cart?.balance > 0) ||
213
223
  placing || errorCash || subtotalWithTaxes < cart?.minimum ||
214
224
  (cardsMethods.includes(paymethodSelected?.gateway) && cardList?.cards?.length === 0) ||
215
- (options.type === 1 && !isGiftCardCart &&
216
- validationFields?.fields?.checkout?.driver_tip?.enabled &&
217
- validationFields?.fields?.checkout?.driver_tip?.required &&
218
- (Number(cart?.driver_tip) <= 0)) ||
219
225
  (validateCommentsCartField) ||
220
- (validateZipcodeCard)
221
- || (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))
222
234
 
223
235
  const driverTipsOptions = typeof configs?.driver_tip_options?.value === 'string'
224
236
  ? JSON.parse(configs?.driver_tip_options?.value) || []
225
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
226
239
 
227
240
  const configTypes = configs?.order_types_allowed?.value.split('|').map((value: any) => Number(value)) || []
228
241
 
@@ -243,7 +256,7 @@ const CheckoutUI = (props: any) => {
243
256
  }
244
257
  }
245
258
 
246
- const vibrateApp = (impact?: string) => {
259
+ const vibrateApp = (impact?: HapticFeedbackTypes) => {
247
260
  const options = {
248
261
  enableVibrateFallback: true,
249
262
  ignoreAndroidSystemSettings: false
@@ -251,12 +264,11 @@ const CheckoutUI = (props: any) => {
251
264
  ReactNativeHapticFeedback.trigger(impact || "impactLight", options);
252
265
  }
253
266
 
254
- const handleSuccessSignup = (user: any) => {
255
- login({
267
+ const handleSuccessSignup = async (user: any) => {
268
+ await login({
256
269
  user,
257
270
  token: user?.session?.access_token
258
271
  })
259
- openModal?.isGuest && handlePlaceOrderAsGuest()
260
272
  setOpenModal({ ...openModal, signup: false, isGuest: false })
261
273
  }
262
274
 
@@ -270,7 +282,7 @@ const CheckoutUI = (props: any) => {
270
282
  return
271
283
  }
272
284
 
273
- if (!userErrors.length && (!requiredFields?.length || allowedGuest) || forcePlace) {
285
+ if (!userErrors.length && (!requiredFields?.length) || forcePlace) {
274
286
  vibrateApp()
275
287
  handlerClickPlaceOrder && handlerClickPlaceOrder(null, { isNative: true }, confirmPayment, NativeStripeSdk?.dismissPlatformPay)
276
288
  return
@@ -309,35 +321,65 @@ const CheckoutUI = (props: any) => {
309
321
 
310
322
  const checkValidationFields = () => {
311
323
  setUserErrors([])
312
- const errors = []
313
- const notFields = ['coupon', 'driver_tip', 'mobile_phone', 'address', 'zipcode', 'address_notes', 'comments']
314
- const _requiredFields: any = []
315
-
316
- Object.values(validationFields?.fields?.checkout).map((field: any) => {
317
- if (field?.required && !notFields.includes(field.code) && field?.enabled) {
318
- if (!user[field?.code]) {
319
- _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)
320
335
  }
321
336
  }
322
337
  })
323
-
338
+ const mobilePhoneField: any = Object.values(checkoutFieldsState?.fields)?.find((field: any) => field?.order_type_id === options?.type && field?.validation_field?.code === 'mobile_phone')
324
339
  if (
325
- !user?.cellphone &&
326
- ((validationFields?.fields?.checkout?.cellphone?.enabled &&
327
- validationFields?.fields?.checkout?.cellphone?.required) ||
340
+ userSelected &&
341
+ !userSelected?.cellphone &&
342
+ ((mobilePhoneField?.enabled &&
343
+ mobilePhoneField?.required) ||
328
344
  configs?.verification_phone_required?.value === '1')
329
345
  ) {
330
346
  _requiredFields.push('cellphone')
331
347
  }
332
348
  setRequiredFields(_requiredFields)
333
349
 
334
- if (phoneUpdate) {
335
- errors.push(t('NECESSARY_UPDATE_COUNTRY_PHONE_CODE', 'It is necessary to update your phone number'))
336
- }
337
-
338
350
  setUserErrors(errors)
339
351
  }
340
352
 
353
+ const checkGuestValidationFields = () => {
354
+ const userSelected = user
355
+ const _requiredFields = checkoutFieldsState?.fields
356
+ .filter((field: any) => (field?.order_type_id === options?.type) && field?.enabled && field?.required_with_guest &&
357
+ !notFields.includes(field?.validation_field?.code) &&
358
+ field?.validation_field?.code !== 'email' &&
359
+ userSelected && !userSelected[field?.validation_field?.code])
360
+ const requiredFieldsCode = _requiredFields.map((item: any) => item?.validation_field?.code)
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')
363
+ if (
364
+ userSelected &&
365
+ !userSelected?.guest_cellphone &&
366
+ ((guestCheckoutCellPhone?.enabled &&
367
+ guestCheckoutCellPhone?.required_with_guest) ||
368
+ configs?.verification_phone_required?.value === '1')
369
+ ) {
370
+ requiredFieldsCode.push('cellphone')
371
+ }
372
+ if (
373
+ userSelected &&
374
+ !userSelected?.guest_email &&
375
+ guestCheckoutEmail?.enabled &&
376
+ guestCheckoutEmail?.required_with_guest
377
+ ) {
378
+ requiredFieldsCode.push('email')
379
+ }
380
+ setRequiredFields(requiredFieldsCode)
381
+ }
382
+
341
383
  const togglePhoneUpdate = (val: boolean) => {
342
384
  setPhoneUpdate(val)
343
385
  }
@@ -346,11 +388,20 @@ const CheckoutUI = (props: any) => {
346
388
  setShowTitle(contentOffset.y > 30)
347
389
  }
348
390
 
391
+ const handleRedirect = () => {
392
+ props.fromProductsList
393
+ ? navigation?.goBack()
394
+ : onNavigationRedirect('BottomTab', { screen: 'Cart' }, !props.fromMulti)
395
+ }
396
+
349
397
  useEffect(() => {
350
- if (validationFields && validationFields?.fields?.checkout) {
398
+ if (checkoutFieldsState?.loading || userLoading) return
399
+ if (user?.guest_id) {
400
+ checkGuestValidationFields()
401
+ } else {
351
402
  checkValidationFields()
352
403
  }
353
- }, [validationFields, user])
404
+ }, [checkoutFieldsState, user, options?.type])
354
405
 
355
406
  useEffect(() => {
356
407
  if (errors) {
@@ -360,12 +411,14 @@ const CheckoutUI = (props: any) => {
360
411
  }, [errors])
361
412
 
362
413
  useEffect(() => {
363
- if (cart?.products?.length === 0) {
364
- if (cart?.business_id !== null) {
365
- onNavigationRedirect('Business', { store: cart?.business?.slug, header: null, logo: null, fromMulti: props.fromMulti })
366
- } else if (isGiftCardCart) {
367
- onNavigationRedirect('Wallets')
368
- }
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
369
422
  }
370
423
  }, [cart?.products?.length])
371
424
 
@@ -427,15 +480,6 @@ const CheckoutUI = (props: any) => {
427
480
  }
428
481
  }, [cartState?.error, cartState?.cart, cartState?.loading, isFocused])
429
482
 
430
- useEffect(() => {
431
- const keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', () => {
432
- containerRef?.current?.scrollToEnd && containerRef.current.scrollToEnd({ animated: true })
433
- })
434
- return () => {
435
- keyboardDidShowListener.remove()
436
- }
437
- }, [])
438
-
439
483
  useEffect(() => {
440
484
  const onBackFunction = () => {
441
485
  if (webviewPaymethod?.gateway === 'paypal' && showGateway.open) {
@@ -456,7 +500,7 @@ const CheckoutUI = (props: any) => {
456
500
  <SafeAreaView style={{ backgroundColor: theme.colors.backgroundPage }}>
457
501
  <View style={styles.wrapperNavbar}>
458
502
  <TopHeader>
459
- <TopActions onPress={() => onNavigationRedirect('BottomTab', { screen: 'Cart' }, !props.fromMulti)}>
503
+ <TopActions onPress={() => handleRedirect()}>
460
504
  <IconAntDesign
461
505
  name='arrowleft'
462
506
  size={26}
@@ -482,7 +526,7 @@ const CheckoutUI = (props: any) => {
482
526
  hideArrowLeft
483
527
  title={t('CHECKOUT', 'Checkout')}
484
528
  titleAlign={'center'}
485
- onActionLeft={() => onNavigationRedirect('BottomTab', { screen: 'Cart' }, !props.fromMulti)}
529
+ onActionLeft={() => handleRedirect()}
486
530
  showCall={false}
487
531
  btnStyle={{ paddingLeft: 0, paddingTop: Platform.OS == 'ios' ? 0 : 2 }}
488
532
  titleWrapStyle={{ paddingHorizontal: 0 }}
@@ -619,15 +663,11 @@ const CheckoutUI = (props: any) => {
619
663
  <HeaderTitle text={t('CUSTOMER_DETAILS', 'Customer details')} />
620
664
  <OButton
621
665
  text={t('SIGN_UP', 'Sign up')}
622
- textStyle={{ color: theme.colors.white }}
623
666
  style={{ borderRadius: 7.6, marginTop: 20 }}
624
667
  onClick={() => setOpenModal({ ...openModal, signup: true })}
625
668
  />
626
669
  <OButton
627
670
  text={t('LOGIN', 'Login')}
628
- textStyle={{ color: theme.colors.primary }}
629
- bgColor={theme.colors.white}
630
- borderColor={theme.colors.primary}
631
671
  style={{ borderRadius: 7.6, marginTop: 20 }}
632
672
  onClick={() => setOpenModal({ ...openModal, login: true })}
633
673
  />
@@ -652,6 +692,9 @@ const CheckoutUI = (props: any) => {
652
692
  isCheckout
653
693
  phoneUpdate={phoneUpdate}
654
694
  togglePhoneUpdate={togglePhoneUpdate}
695
+ isOrderTypeValidationField
696
+ requiredFields={requiredFields}
697
+ checkoutFields={checkoutFields}
655
698
  />
656
699
  )
657
700
  )}
@@ -749,6 +792,7 @@ const CheckoutUI = (props: any) => {
749
792
  </Placeholder>
750
793
  ) : (
751
794
  <AddressDetails
795
+ cart={cart}
752
796
  navigation={navigation}
753
797
  location={options?.address?.location}
754
798
  businessLogo={businessDetails?.business?.logo}
@@ -764,14 +808,7 @@ const CheckoutUI = (props: any) => {
764
808
  </ChSection>
765
809
  )}
766
810
 
767
- {!cartState.loading &&
768
- cart &&
769
- cart?.valid &&
770
- options.type === 1 &&
771
- cart?.status !== 2 &&
772
- validationFields?.fields?.checkout?.driver_tip?.enabled &&
773
- driverTipsOptions && driverTipsOptions?.length > 0 &&
774
- cart?.business_id &&
811
+ {driverTipsField &&
775
812
  (
776
813
  <ChSection>
777
814
  <ChDriverTips>
@@ -831,6 +868,7 @@ const CheckoutUI = (props: any) => {
831
868
  openUserModal={setIsOpen}
832
869
  paymethodClicked={paymethodClicked}
833
870
  setPaymethodClicked={setPaymethodClicked}
871
+ setUserHasCards={setUserHasCards}
834
872
  />
835
873
  </ChPaymethods>
836
874
  </ChSection>
@@ -909,6 +947,7 @@ const CheckoutUI = (props: any) => {
909
947
  cart={cart}
910
948
  isCartPending={cart?.status === 2}
911
949
  onNavigationRedirect={onNavigationRedirect}
950
+ commentDelayTime={commentDelayTime}
912
951
  placeSpotTypes={placeSpotTypes}
913
952
  businessConfigs={businessConfigs}
914
953
  maxDate={maxDate}
@@ -916,6 +955,8 @@ const CheckoutUI = (props: any) => {
916
955
  creditPointPlanOnBusiness?.accumulation_rate ??
917
956
  (!!creditPointPlanOnBusiness && creditPointPlan?.accumulation_rate) ?? 0
918
957
  }
958
+ hideCommentsByValidationCheckout={!guestCheckoutComment?.enabled}
959
+ hideCouponByValidationCheckout={!guestCheckoutCoupon?.enabled}
919
960
  />
920
961
  </>
921
962
  )}
@@ -962,10 +1003,8 @@ const CheckoutUI = (props: any) => {
962
1003
  {t('INVALID_CART_MOMENT', 'Selected schedule time is invalid, please select a schedule into the business schedule interval.')}
963
1004
  </OText>
964
1005
  )}
965
- {options.type === 1 && !isGiftCardCart &&
966
- validationFields?.fields?.checkout?.driver_tip?.enabled &&
967
- validationFields?.fields?.checkout?.driver_tip?.required &&
968
- (Number(cart?.driver_tip) <= 0) && (
1006
+ {validateDriverTipField && !isGiftCardCart &&
1007
+ (
969
1008
  <OText
970
1009
  color={theme.colors.error}
971
1010
  size={12}
@@ -973,7 +1012,6 @@ const CheckoutUI = (props: any) => {
973
1012
  {t('WARNING_INVALID_DRIVER_TIP', 'Driver Tip is required.')}
974
1013
  </OText>
975
1014
  )}
976
-
977
1015
  {validateCommentsCartField && (
978
1016
  <OText
979
1017
  color={theme.colors.error}
@@ -991,6 +1029,15 @@ const CheckoutUI = (props: any) => {
991
1029
  {t('WARNING_CARD_ZIPCODE_REQUIRED', 'Your card selected has not zipcode')}
992
1030
  </OText>
993
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
+ )}
994
1041
  </ChErrors>
995
1042
  </View>
996
1043
  )}
@@ -1008,20 +1055,23 @@ const CheckoutUI = (props: any) => {
1008
1055
  <OModal
1009
1056
  open={isOpen}
1010
1057
  onClose={() => setIsOpen(false)}
1058
+ showToastInsideModal
1011
1059
  >
1012
1060
  <View style={styles.detailWrapper}>
1013
1061
  <UserDetails
1014
1062
  isUserDetailsEdit
1015
1063
  cartStatus={cart?.status}
1016
1064
  businessId={cart?.business_id}
1017
- useValidationFields
1018
1065
  useDefualtSessionManager
1019
1066
  useSessionUser
1020
1067
  isCheckout
1021
1068
  isEdit
1022
1069
  phoneUpdate={phoneUpdate}
1023
1070
  togglePhoneUpdate={togglePhoneUpdate}
1071
+ isOrderTypeValidationField
1024
1072
  requiredFields={requiredFields}
1073
+ checkoutFields={checkoutFields}
1074
+ isCheckoutPlace
1025
1075
  hideUpdateButton
1026
1076
  handlePlaceOrderAsGuest={handlePlaceOrderAsGuest}
1027
1077
  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
+ })