ordering-ui-react-native 0.15.27 → 0.15.29-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 (168) hide show
  1. package/package.json +4 -2
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/BusinessController/index.tsx +8 -2
  4. package/src/components/BusinessTypeFilter/index.tsx +4 -1
  5. package/src/components/BusinessesListing/index.tsx +1 -1
  6. package/src/components/Checkout/index.tsx +23 -3
  7. package/src/components/DriverTips/index.tsx +11 -6
  8. package/src/components/LanguageSelector/index.tsx +7 -2
  9. package/src/components/OrderDetails/index.tsx +2 -2
  10. package/src/components/PaymentOptions/index.tsx +9 -16
  11. package/src/components/PaymentOptionsWebView/index.tsx +123 -124
  12. package/src/components/SingleProductCard/index.tsx +16 -4
  13. package/src/components/StripeElementsForm/index.tsx +27 -48
  14. package/src/components/UpsellingProducts/index.tsx +1 -1
  15. package/src/components/UserProfileForm/index.tsx +63 -6
  16. package/src/components/UserProfileForm/styles.tsx +8 -0
  17. package/src/components/VerifyPhone/styles.tsx +1 -2
  18. package/src/components/shared/OModal.tsx +1 -1
  19. package/src/config.json +0 -2
  20. package/src/hooks/useCountdownTimer.tsx +26 -0
  21. package/src/navigators/HomeNavigator.tsx +6 -0
  22. package/src/pages/BusinessProductsList.tsx +1 -0
  23. package/src/pages/BusinessesListing.tsx +1 -1
  24. package/src/pages/Checkout.tsx +1 -1
  25. package/src/pages/Sessions.tsx +22 -0
  26. package/src/types/index.tsx +5 -11
  27. package/src/utils/index.tsx +68 -1
  28. package/themes/business/index.tsx +2 -0
  29. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +103 -15
  30. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +6 -0
  31. package/themes/business/src/components/Chat/index.tsx +38 -86
  32. package/themes/business/src/components/DriverMap/index.tsx +6 -5
  33. package/themes/business/src/components/Home/index.tsx +128 -55
  34. package/themes/business/src/components/Home/styles.tsx +8 -1
  35. package/themes/business/src/components/LoginForm/index.tsx +89 -2
  36. package/themes/business/src/components/LoginForm/styles.tsx +6 -0
  37. package/themes/business/src/components/LogoutButton/index.tsx +1 -1
  38. package/themes/business/src/components/NewOrderNotification/index.tsx +79 -105
  39. package/themes/business/src/components/OrderDetails/Business.tsx +2 -1
  40. package/themes/business/src/components/OrderDetails/Delivery.tsx +32 -15
  41. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +151 -89
  42. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +91 -17
  43. package/themes/business/src/components/OrderDetails/styles.tsx +7 -0
  44. package/themes/business/src/components/OrdersListManager/index.tsx +874 -0
  45. package/themes/business/src/components/OrdersListManager/styles.tsx +123 -0
  46. package/themes/business/src/components/OrdersListManager/utils.tsx +216 -0
  47. package/themes/business/src/components/OrdersOption/index.tsx +58 -51
  48. package/themes/business/src/components/PreviousOrders/index.tsx +75 -22
  49. package/themes/business/src/components/shared/OModal.tsx +1 -1
  50. package/themes/business/src/types/index.tsx +5 -1
  51. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  52. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  53. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  54. package/themes/kiosk/src/components/Cart/index.tsx +98 -24
  55. package/themes/kiosk/src/components/Cart/styles.tsx +6 -0
  56. package/themes/kiosk/src/components/CartBottomSheet/index.tsx +1 -1
  57. package/themes/kiosk/src/components/CartBottomSheet/styles.tsx +1 -1
  58. package/themes/kiosk/src/components/CartContent/index.tsx +13 -3
  59. package/themes/kiosk/src/components/CartItem/index.tsx +20 -8
  60. package/themes/kiosk/src/components/CustomerName/index.tsx +89 -88
  61. package/themes/kiosk/src/components/Intro/index.tsx +13 -13
  62. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  63. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  64. package/themes/kiosk/src/components/OrderDetails/index.tsx +136 -41
  65. package/themes/kiosk/src/components/OrderDetails/styles.tsx +5 -0
  66. package/themes/kiosk/src/components/OrderSummary/index.tsx +1 -1
  67. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +10 -12
  68. package/themes/kiosk/src/components/ProductForm/index.tsx +174 -125
  69. package/themes/kiosk/src/components/ProductForm/styles.tsx +1 -1
  70. package/themes/kiosk/src/components/ProductOption/index.tsx +1 -0
  71. package/themes/kiosk/src/components/ProductOption/styles.tsx +1 -0
  72. package/themes/kiosk/src/components/UpsellingProducts/index.tsx +48 -34
  73. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  74. package/themes/kiosk/src/types/index.d.ts +2 -0
  75. package/themes/original/index.tsx +178 -1
  76. package/themes/original/src/components/AddressForm/index.tsx +15 -10
  77. package/themes/original/src/components/AddressList/index.tsx +56 -18
  78. package/themes/original/src/components/AppleLogin/index.tsx +117 -78
  79. package/themes/original/src/components/BusinessBasicInformation/index.tsx +96 -45
  80. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +28 -1
  81. package/themes/original/src/components/BusinessController/index.tsx +52 -22
  82. package/themes/original/src/components/BusinessController/styles.tsx +22 -0
  83. package/themes/original/src/components/BusinessFeaturedController/index.tsx +20 -1
  84. package/themes/original/src/components/BusinessFeaturedController/styles.tsx +23 -0
  85. package/themes/original/src/components/BusinessListingSearch/index.tsx +121 -7
  86. package/themes/original/src/components/BusinessListingSearch/styles.tsx +14 -1
  87. package/themes/original/src/components/BusinessMenuList/index.tsx +11 -4
  88. package/themes/original/src/components/BusinessPreorder/index.tsx +142 -122
  89. package/themes/original/src/components/BusinessProductsCategories/index.tsx +9 -7
  90. package/themes/original/src/components/BusinessProductsList/CategoryDescription/index.tsx +44 -0
  91. package/themes/original/src/components/BusinessProductsList/index.tsx +132 -35
  92. package/themes/original/src/components/BusinessProductsList/styles.tsx +29 -2
  93. package/themes/original/src/components/BusinessProductsListing/index.tsx +118 -37
  94. package/themes/original/src/components/BusinessProductsListing/styles.tsx +22 -0
  95. package/themes/original/src/components/BusinessReviews/index.tsx +4 -25
  96. package/themes/original/src/components/BusinessTypeFilter/index.tsx +1 -2
  97. package/themes/original/src/components/BusinessesListing/index.tsx +74 -70
  98. package/themes/original/src/components/Cart/index.tsx +21 -17
  99. package/themes/original/src/components/CartContent/index.tsx +2 -2
  100. package/themes/original/src/components/Checkout/index.tsx +58 -45
  101. package/themes/original/src/components/DriverTips/index.tsx +17 -12
  102. package/themes/original/src/components/ForgotPasswordForm/index.tsx +84 -4
  103. package/themes/original/src/components/GPSButton/index.tsx +15 -8
  104. package/themes/original/src/components/GoogleMap/index.tsx +1 -0
  105. package/themes/original/src/components/Help/index.tsx +21 -4
  106. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +97 -89
  107. package/themes/original/src/components/Home/index.tsx +1 -1
  108. package/themes/original/src/components/LastOrders/index.tsx +12 -1
  109. package/themes/original/src/components/LoginForm/Otp/index.tsx +90 -0
  110. package/themes/original/src/components/LoginForm/Otp/styles.tsx +7 -0
  111. package/themes/original/src/components/LoginForm/index.tsx +389 -156
  112. package/themes/original/src/components/LoginForm/styles.tsx +7 -4
  113. package/themes/original/src/components/LogoutButton/index.tsx +7 -1
  114. package/themes/original/src/components/MessageListing/index.tsx +10 -1
  115. package/themes/original/src/components/Messages/index.tsx +34 -25
  116. package/themes/original/src/components/Messages/styles.tsx +1 -3
  117. package/themes/original/src/components/MomentOption/index.tsx +10 -1
  118. package/themes/original/src/components/MomentOption/styles.tsx +1 -1
  119. package/themes/original/src/components/OrderDetails/index.tsx +56 -33
  120. package/themes/original/src/components/OrderDetails/styles.tsx +1 -2
  121. package/themes/original/src/components/OrderProgress/index.tsx +4 -4
  122. package/themes/original/src/components/OrderProgress/styles.tsx +1 -0
  123. package/themes/original/src/components/OrderSummary/index.tsx +3 -3
  124. package/themes/original/src/components/OrderTypeSelector/index.tsx +4 -2
  125. package/themes/original/src/components/OrdersOption/index.tsx +55 -58
  126. package/themes/original/src/components/OrdersOption/styles.tsx +0 -6
  127. package/themes/original/src/components/PaymentOptionCash/index.tsx +2 -2
  128. package/themes/original/src/components/PaymentOptionWallet/index.tsx +22 -24
  129. package/themes/original/src/components/PaymentOptionWallet/styles.tsx +1 -1
  130. package/themes/original/src/components/PaymentOptions/index.tsx +9 -19
  131. package/themes/original/src/components/PhoneInputNumber/index.tsx +1 -1
  132. package/themes/original/src/components/PreviousOrders/index.tsx +16 -14
  133. package/themes/original/src/components/ProductForm/index.tsx +76 -61
  134. package/themes/original/src/components/ProductForm/styles.tsx +2 -2
  135. package/themes/original/src/components/ProductItemAccordion/index.tsx +2 -2
  136. package/themes/original/src/components/ProductOptionSubOption/index.tsx +18 -12
  137. package/themes/original/src/components/Promotions/index.tsx +250 -0
  138. package/themes/original/src/components/Promotions/styles.tsx +60 -0
  139. package/themes/original/src/components/ReviewOrder/index.tsx +10 -9
  140. package/themes/original/src/components/ReviewProducts/index.tsx +1 -1
  141. package/themes/original/src/components/SearchBar/index.tsx +4 -1
  142. package/themes/original/src/components/Sessions/index.tsx +160 -0
  143. package/themes/original/src/components/Sessions/styles.tsx +15 -0
  144. package/themes/original/src/components/SingleProductCard/index.tsx +47 -21
  145. package/themes/original/src/components/SingleProductCard/styles.tsx +28 -1
  146. package/themes/original/src/components/StripeElementsForm/index.tsx +55 -72
  147. package/themes/original/src/components/TaxInformation/index.tsx +10 -4
  148. package/themes/original/src/components/UpsellingProducts/index.tsx +86 -74
  149. package/themes/original/src/components/UserDetails/index.tsx +4 -95
  150. package/themes/original/src/components/UserFormDetails/index.tsx +34 -24
  151. package/themes/original/src/components/UserProfile/index.tsx +62 -14
  152. package/themes/original/src/components/UserProfileForm/index.tsx +20 -18
  153. package/themes/original/src/components/UserVerification/index.tsx +178 -192
  154. package/themes/original/src/components/VerifyPhone/index.tsx +10 -7
  155. package/themes/original/src/components/VerifyPhone/styles.tsx +2 -1
  156. package/themes/original/src/components/Wallets/index.tsx +76 -9
  157. package/themes/original/src/components/Wallets/styles.tsx +21 -0
  158. package/themes/original/src/components/shared/HeaderTitle.tsx +21 -0
  159. package/themes/original/src/components/shared/OModal.tsx +1 -1
  160. package/themes/original/src/components/shared/index.tsx +2 -0
  161. package/themes/original/src/config/constants.tsx +6 -6
  162. package/themes/original/src/types/index.tsx +68 -6
  163. package/themes/original/src/utils/index.tsx +28 -2
  164. package/themes/single-business/src/components/AddressList/index.tsx +1 -1
  165. package/themes/single-business/src/components/OrderTypeSelector/index.tsx +6 -6
  166. package/themes/single-business/src/components/UserProfile/index.tsx +1 -1
  167. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
  168. package/src/components/StripeMethodForm/index.tsx +0 -168
@@ -1,6 +1,7 @@
1
1
  import React, { useCallback, useEffect, useRef, useState } from 'react';
2
2
  import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
3
3
  import Geolocation from '@react-native-community/geolocation'
4
+ import { getTrackingStatus, requestTrackingPermission } from 'react-native-tracking-transparency'
4
5
  import {
5
6
  View,
6
7
  StyleSheet,
@@ -47,7 +48,7 @@ import { getTypesText, convertToRadian } from '../../utils';
47
48
  import { OrderProgress } from '../OrderProgress';
48
49
  import { useFocusEffect, useIsFocused } from '@react-navigation/native';
49
50
 
50
- const PIXELS_TO_SCROLL = 1000;
51
+ const PIXELS_TO_SCROLL = 2000;
51
52
 
52
53
  const BusinessesListingUI = (props: BusinessesListingParams) => {
53
54
  const {
@@ -59,9 +60,9 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
59
60
  handleBusinessClick,
60
61
  paginationProps,
61
62
  handleChangeSearch,
62
- businessId
63
+ businessId,
64
+ isGuestUser
63
65
  } = props;
64
-
65
66
  const theme = useTheme();
66
67
  const isFocused = useIsFocused();
67
68
  const appState = useRef(AppState.currentState)
@@ -117,10 +118,10 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
117
118
  const [featuredBusiness, setFeaturedBusinesses] = useState(Array);
118
119
  const [isFarAway, setIsFarAway] = useState(false)
119
120
  const [businessTypes, setBusinessTypes] = useState(null)
120
-
121
+ const [orderTypeValue, setOrderTypeValue] = useState(orderState?.options.value)
121
122
  const isPreorderEnabled = (configs?.preorder_status_enabled?.value === '1' || configs?.preorder_status_enabled?.value === 'true') &&
122
123
  Number(configs?.max_days_preorder?.value) > 0
123
-
124
+ const isPreOrderSetting = configs?.preorder_status_enabled?.value === '1'
124
125
  const timerId = useRef<any>(false)
125
126
  // const panResponder = useRef(
126
127
  // PanResponder.create({
@@ -166,8 +167,15 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
166
167
  return R * c
167
168
  }
168
169
 
170
+ const resetInactivityTimeout = () => {
171
+ clearTimeout(timerId.current)
172
+ timerId.current = setInterval(() => {
173
+ getBusinesses(true)
174
+ }, 120000)
175
+ }
176
+
169
177
  useEffect(() => {
170
- if (businessesList.businesses.length > 0) {
178
+ if (!businessesList?.loading) {
171
179
  const fb = businessesList.businesses.filter((b) => b.featured === true && b?.open);
172
180
  const ary = [];
173
181
  while (fb.length > 0) {
@@ -175,16 +183,6 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
175
183
  }
176
184
  setFeaturedBusinesses(ary);
177
185
  }
178
- }, [businessesList.businesses]);
179
-
180
- const resetInactivityTimeout = () => {
181
- clearTimeout(timerId.current)
182
- timerId.current = setInterval(() => {
183
- getBusinesses(true)
184
- }, 300000)
185
- }
186
-
187
- useEffect(() => {
188
186
  resetInactivityTimeout()
189
187
  }, [businessesList.loading])
190
188
 
@@ -194,40 +192,37 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
194
192
  }
195
193
  }
196
194
 
195
+ const checkUserLocation = async () => {
196
+ let trackingStatus = await getTrackingStatus()
197
+ if (trackingStatus === 'not-determined') {
198
+ trackingStatus = await requestTrackingPermission()
199
+ }
200
+ if (trackingStatus === 'authorized' || trackingStatus === 'unavailable') {
201
+ Geolocation.getCurrentPosition((pos) => {
202
+ const crd = pos.coords
203
+ const distance = getDistance(crd.latitude, crd.longitude, orderState?.options?.address?.location?.lat, orderState?.options?.address?.location?.lng)
204
+ if (distance > 20) setIsFarAway(true)
205
+ else setIsFarAway(false)
206
+ }, (err) => {
207
+ console.log(`ERROR(${err.code}): ${err.message}`)
208
+ }, {
209
+ enableHighAccuracy: true, timeout: 15000, maximumAge: 10000
210
+ })
211
+ }
212
+ }
213
+
197
214
  useEffect(() => {
198
- Geolocation.getCurrentPosition((pos) => {
199
- const crd = pos.coords
200
- const distance = getDistance(crd.latitude, crd.longitude, orderState?.options?.address?.location?.lat, orderState?.options?.address?.location?.lng)
201
- if (distance > 20) setIsFarAway(true)
202
- else setIsFarAway(false)
203
- }, (err) => {
204
- console.log(`ERROR(${err.code}): ${err.message}`)
205
- }, {
206
- enableHighAccuracy: true, timeout: 15000, maximumAge: 10000
207
- })
215
+ checkUserLocation()
208
216
  }, [orderState?.options?.address?.location])
209
217
 
210
218
  useEffect(() => {
211
- const onFocusApp = (nextAppState: any) => {
212
- if (
213
- appState.current.match(/inactive|background/) &&
214
- nextAppState === "active"
215
- ) {
216
- getBusinesses(true);
217
- }
218
- appState.current = nextAppState;
219
- setAppStateVisible(appState.current);
219
+ if(!orderState?.loading){
220
+ setOrderTypeValue(orderState?.options?.type)
220
221
  }
221
-
222
- AppState.addEventListener("change", onFocusApp);
223
- return () => {
224
- AppState.removeEventListener('change', onFocusApp);
225
- };
226
- }, [])
222
+ }, [orderState?.options?.type])
227
223
 
228
224
  useFocusEffect(
229
225
  useCallback(() => {
230
- getBusinesses(true)
231
226
  resetInactivityTimeout()
232
227
  return () => clearTimeout(timerId.current)
233
228
  }, [navigation])
@@ -259,6 +254,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
259
254
  : navigation.navigate('AddressForm', {
260
255
  address: orderState.options?.address,
261
256
  isFromBusinesses: true,
257
+ isGuestUser: isGuestUser
262
258
  })
263
259
  }>
264
260
  <OIcon
@@ -280,33 +276,35 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
280
276
  )}
281
277
  <OrderControlContainer>
282
278
  <View style={styles.wrapperOrderOptions}>
283
- <WrapMomentOption onPress={() => navigation.navigate('OrderTypes', { configTypes: configTypes })}>
284
- <OText size={12} numberOfLines={1} ellipsizeMode={'tail'} color={theme.colors.textSecondary}>{t(getTypesText(orderState?.options?.type || 1), 'Delivery')}</OText>
279
+ <WrapMomentOption onPress={() => navigation.navigate('OrderTypes', { configTypes: configTypes, setOrderTypeValue })}>
280
+ <OText size={12} numberOfLines={1} ellipsizeMode={'tail'} color={theme.colors.textSecondary}>{t(getTypesText(orderTypeValue || orderState?.options?.type || 1), 'Delivery')}</OText>
285
281
  <OIcon
286
282
  src={theme.images.general.arrow_down}
287
283
  width={10}
288
284
  style={{ marginStart: 8 }}
289
285
  />
290
286
  </WrapMomentOption>
291
- <WrapMomentOption
292
- onPress={() => handleMomentClick()}>
293
- <OText
294
- size={12}
295
- numberOfLines={1}
296
- ellipsizeMode="tail"
297
- color={theme.colors.textSecondary}>
298
- {orderState.options?.momentß
299
- ? parseDate(orderState.options?.moment, { outputFormat: configs?.dates_moment_format?.value })
300
- : t('ASAP_ABBREVIATION', 'ASAP')}
301
- </OText>
302
- {isPreorderEnabled && (
303
- <OIcon
304
- src={theme.images.general.arrow_down}
305
- width={10}
306
- style={{ marginStart: 8 }}
307
- />
308
- )}
309
- </WrapMomentOption>
287
+ {isPreOrderSetting && (
288
+ <WrapMomentOption
289
+ onPress={() => handleMomentClick()}>
290
+ <OText
291
+ size={12}
292
+ numberOfLines={1}
293
+ ellipsizeMode="tail"
294
+ color={theme.colors.textSecondary}>
295
+ {orderState.options?.moment
296
+ ? parseDate(orderState.options?.moment, { outputFormat: configs?.dates_moment_format?.value })
297
+ : t('ASAP_ABBREVIATION', 'ASAP')}
298
+ </OText>
299
+ {isPreorderEnabled && (
300
+ <OIcon
301
+ src={theme.images.general.arrow_down}
302
+ width={10}
303
+ style={{ marginStart: 8 }}
304
+ />
305
+ )}
306
+ </WrapMomentOption>
307
+ )}
310
308
 
311
309
  {!businessId && (
312
310
  <SearchBar
@@ -318,9 +316,9 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
318
316
  onCancel={() => handleChangeSearch('')}
319
317
  placeholder={t('SEARCH', 'Search')}
320
318
  height={26}
321
- isDisabled={configs?.advanced_business_search_enabled?.value === '1' || !businessTypes}
319
+ isDisabled={!businessTypes}
322
320
  inputStyle={{ ...styles.searchInput, ...Platform.OS === 'ios' ? {} : { paddingBottom: 4 } }}
323
- onPress={() => { configs?.advanced_business_search_enabled?.value === '1' && navigation.navigate('BusinessSearch', { businessTypes }) }}
321
+ onSubmitEditing={() => { configs?.advanced_business_search_enabled?.value === '1' && navigation.navigate('BusinessSearch', { businessTypes, defaultTerm: searchValue }) }}
324
322
  />
325
323
  )}
326
324
 
@@ -338,7 +336,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
338
336
  {
339
337
  !businessId && !props.franchiseId && featuredBusiness && featuredBusiness.length > 0 && (
340
338
  <FeaturedWrapper>
341
- <OText size={16} style={{ marginLeft: 40 }} weight={Platform.OS === 'ios' ? '600' : 'bold'}>{t('FEATURED_BUSINESS', 'Featured business')}</OText>
339
+ <OText size={16} style={{ marginLeft: 40 }} weight={Platform.OS === 'ios' ? '600' : 'bold'}>{t('BUSINESS_FEATURE', 'Featured business')}</OText>
342
340
  <ScrollView
343
341
  showsHorizontalScrollIndicator={false}
344
342
  nestedScrollEnabled
@@ -346,7 +344,6 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
346
344
  {featuredBusiness.map((bAry: any, idx) => (
347
345
  <View key={'f-listing_' + idx}>
348
346
  <BusinessFeaturedController
349
- key={bAry[0].id}
350
347
  business={bAry[0]}
351
348
  isBusinessOpen={bAry[0]?.open}
352
349
  handleCustomClick={handleBusinessClick}
@@ -354,7 +351,6 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
354
351
  />
355
352
  {bAry.length > 1 && (
356
353
  <BusinessFeaturedController
357
- key={bAry[1].id}
358
354
  business={bAry[1]}
359
355
  isBusinessOpen={bAry[1]?.open}
360
356
  handleCustomClick={handleBusinessClick}
@@ -393,14 +389,22 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
393
389
  />
394
390
  )}
395
391
  {businessesList.businesses?.map(
396
- (business: any) => (
392
+ (business: any, i : number) => (
397
393
  <BusinessController
398
- key={business.id}
394
+ key={`${business.id}_` + i}
399
395
  business={business}
400
396
  isBusinessOpen={business.open}
401
397
  handleCustomClick={handleBusinessClick}
402
398
  orderType={orderState?.options?.type}
403
399
  navigation={navigation}
400
+ businessHeader={business?.header}
401
+ businessFeatured={business?.featured}
402
+ businessLogo={business?.logo}
403
+ businessReviews={business?.reviews}
404
+ businessDeliveryPrice={business?.delivery_price}
405
+ businessDeliveryTime={business?.delivery_time}
406
+ businessPickupTime={business?.pickup_time}
407
+ businessDistance={business?.distance}
404
408
  />
405
409
  )
406
410
  )}
@@ -106,7 +106,7 @@ const CartUI = (props: any) => {
106
106
  }
107
107
 
108
108
  const getIncludedTaxes = () => {
109
- if (cart?.taxes === null) {
109
+ if (cart?.taxes === null || !cart?.taxes) {
110
110
  return cart.business.tax_type === 1 ? cart?.tax : 0
111
111
  } else {
112
112
  return cart?.taxes.reduce((taxIncluded: number, tax: any) => {
@@ -162,13 +162,13 @@ const CartUI = (props: any) => {
162
162
  handleClearProducts={handleClearProducts}
163
163
  handleCartOpen={handleCartOpen}
164
164
  onNavigationRedirect={props.onNavigationRedirect}
165
- handleChangeStore={props.isFranchiseApp ? () => setOpenChangeStore(true) : null}
165
+ handleChangeStore={() => setOpenChangeStore(true)}
166
166
  handleClickCheckout={() => setOpenUpselling(true)}
167
167
  checkoutButtonDisabled={(openUpselling && !canOpenUpselling) || cart?.subtotal < cart?.minimum || !cart?.valid_address}
168
168
  >
169
- {cart?.products?.length > 0 && cart?.products.map((product: any) => (
169
+ {cart?.products?.length > 0 && cart?.products.map((product: any, i: number) => (
170
170
  <ProductItemAccordion
171
- key={product.code}
171
+ key={`${product.code}_${i}`}
172
172
  isCartPending={isCartPending}
173
173
  isCartProduct
174
174
  product={product}
@@ -202,8 +202,8 @@ const CartUI = (props: any) => {
202
202
  </OSTable>
203
203
  )}
204
204
  {
205
- cart?.offers?.length > 0 && cart?.offers?.filter((offer: any) => offer?.target === 1)?.map((offer: any) => (
206
- <OSTable key={offer.id}>
205
+ cart?.offers?.length > 0 && cart?.offers?.filter((offer: any) => offer?.target === 1)?.map((offer: any, i: number) => (
206
+ <OSTable key={`${offer.id}_${i}`}>
207
207
  <OSRow>
208
208
  <OText size={12} lineHeight={18}>{offer.name}</OText>
209
209
  {offer.rate_type === 1 && (
@@ -234,8 +234,8 @@ const CartUI = (props: any) => {
234
234
  </OSTable>
235
235
  )}
236
236
  {
237
- cart.taxes?.length > 0 && cart.taxes.filter((tax: any) => tax.type === 2 && tax?.rate !== 0).map((tax: any) => (
238
- <OSTable key={tax.id}>
237
+ cart.taxes?.length > 0 && cart.taxes.filter((tax: any) => tax.type === 2 && tax?.rate !== 0).map((tax: any, i: number) => (
238
+ <OSTable key={`${tax.id}_${i}`}>
239
239
  <OSRow>
240
240
  <OText size={12} lineHeight={18} numberOfLines={1} >
241
241
  {tax.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
@@ -250,12 +250,12 @@ const CartUI = (props: any) => {
250
250
  ))
251
251
  }
252
252
  {
253
- cart?.fees?.length > 0 && cart?.fees?.filter((fee: any) => !(fee.fixed === 0 && fee.percentage === 0)).map((fee: any) => (
254
- <OSTable key={fee?.id}>
253
+ cart?.fees?.length > 0 && cart?.fees?.filter((fee: any) => !(fee.fixed === 0 && fee.percentage === 0)).map((fee: any, i: number) => (
254
+ <OSTable key={`${fee.id}_${i}`}>
255
255
  <OSRow>
256
256
  <OText size={12} lineHeight={18} numberOfLines={1}>
257
257
  {fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
258
- ({fee?.fixed > 0 && `${parsePrice(fee?.fixed)} + `}{fee.percentage}%){' '}
258
+ ({fee?.fixed > 0 && `${parsePrice(fee?.fixed)}${fee.percentage > 0 ? ' + ' : ''}`}{fee.percentage > 0 && `${fee.percentage}%`}){' '}
259
259
  </OText>
260
260
  <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee, type: 'fee' })} >
261
261
  <AntIcon name='infocirlceo' size={16} color={theme.colors.primary} />
@@ -293,8 +293,8 @@ const CartUI = (props: any) => {
293
293
  </OSTable>
294
294
  )}
295
295
  {
296
- cart?.offers?.length > 0 && cart?.offers?.filter((offer: any) => offer?.target === 2)?.map((offer: any) => (
297
- <OSTable key={offer.id}>
296
+ cart?.offers?.length > 0 && cart?.offers?.filter((offer: any) => offer?.target === 2)?.map((offer: any, i: number) => (
297
+ <OSTable key={`${offer.id}_${i}`}>
298
298
  <OSRow>
299
299
  <OText size={12} lineHeight={18}>{offer.name}</OText>
300
300
  {offer.rate_type === 1 && (
@@ -409,7 +409,7 @@ const CartUI = (props: any) => {
409
409
  )}
410
410
  </OSBill>
411
411
  )}
412
- {cart?.valid_products && (
412
+ {cart?.valid_products ? (
413
413
  <CheckoutAction>
414
414
  <OButton
415
415
  text={(cart?.subtotal >= cart?.minimum || !cart?.minimum) && cart?.valid_address ? (
@@ -428,11 +428,17 @@ const CartUI = (props: any) => {
428
428
  style={{ width: '100%', flexDirection: 'row', justifyContent: 'center', borderRadius: 7.6, shadowOpacity: 0 }}
429
429
  />
430
430
  </CheckoutAction>
431
+ ) : (
432
+ <View style={{ alignItems: 'center', width: '100%' }}>
433
+ <OText size={12} color={theme.colors.red} style={{ textAlign: 'center', marginTop: 5 }}>
434
+ {t('WARNING_INVALID_PRODUCTS_CHECKOUT', 'To continue with your checkout, please remove from your cart the products that are not available.')}
435
+ </OText>
436
+ </View>
431
437
  )}
432
438
  </BusinessItemAccordion>
433
439
 
434
440
  <OModal
435
- open={openChangeStore && props.isFranchiseApp}
441
+ open={openChangeStore}
436
442
  entireModal
437
443
  customClose
438
444
  onClose={() => setOpenChangeStore(false)}
@@ -446,8 +452,6 @@ const CartUI = (props: any) => {
446
452
  open={openTaxModal.open}
447
453
  onClose={() => setOpenTaxModal({ open: false, data: null, type: '' })}
448
454
  entireModal
449
- title={`${openTaxModal.data?.name ||
450
- t('INHERIT_FROM_BUSINESS', 'Inherit from business')} ${openTaxModal.data?.rate_type !== 2 ? `(${typeof openTaxModal.data?.rate === 'number' ? `${openTaxModal.data?.rate}%` : `${parsePrice(openTaxModal.data?.fixed ?? 0)} + ${openTaxModal.data?.percentage}%`})` : ''} `}
451
455
  >
452
456
  <TaxInformation
453
457
  type={openTaxModal.type}
@@ -22,9 +22,9 @@ export const CartContent = (props: any) => {
22
22
  <CCContainer>
23
23
  {isOrderStateCarts && carts?.length > 0 && (
24
24
  <>
25
- <OText size={24} lineHeight={36} weight={'600'} style={{ marginBottom: 20 }}>
25
+ {/* <OText size={24} lineHeight={36} weight={'600'} style={{ marginBottom: 20 }}>
26
26
  {carts.length > 1 ? t('MY_CARTS', 'My Carts') : t('CART', 'Cart')}
27
- </OText>
27
+ </OText> */}
28
28
  {carts.map((cart: any, i: number) => (
29
29
  <CCList key={i} style={{ overflow: 'visible' }}>
30
30
  {cart.products.length > 0 && (
@@ -112,7 +112,10 @@ const CheckoutUI = (props: any) => {
112
112
  right: Platform.OS === 'ios' ? 5 : (I18nManager.isRTL ? 30 : 0),
113
113
  position: 'absolute',
114
114
  fontSize: 20
115
- }
115
+ },
116
+ wrapperNavbar: Platform.OS === 'ios'
117
+ ? { paddingVertical: 0, paddingHorizontal: 40 }
118
+ : { paddingVertical: 20, paddingHorizontal: 40 }
116
119
  })
117
120
 
118
121
  const [, { showToast }] = useToast();
@@ -132,11 +135,20 @@ const CheckoutUI = (props: any) => {
132
135
  const [isDeliveryOptionModalVisible, setIsDeliveryOptionModalVisible] = useState(false)
133
136
  const [showGateway, setShowGateway] = useState<any>({ closedByUsed: false, open: false });
134
137
  const [webviewPaymethod, setWebviewPaymethod] = useState<any>(null)
135
-
138
+
136
139
  const placeSpotTypes = [3, 4]
137
- const isWalletEnabled = configs?.wallet_enabled?.value === '1' && (configs?.wallet_cash_enabled?.value === '1' || configs?.wallet_credit_point_enabled?.value === '1')
140
+ const businessConfigs = businessDetails?.business?.configs ?? []
141
+ const isWalletCashEnabled = businessConfigs.find((config: any) => config.key === 'wallet_cash_enabled')?.value === '1'
142
+ const isWalletCreditPointsEnabled = businessConfigs.find((config: any) => config.key === 'wallet_credit_point_enabled')?.value === '1'
143
+ const isWalletEnabled = configs?.cash_wallet?.value && configs?.wallet_enabled?.value === '1' && (isWalletCashEnabled || isWalletCreditPointsEnabled)
144
+
138
145
  const isPreOrder = configs?.preorder_status_enabled?.value === '1'
139
- const isDisabledButtonPlace = loading || !cart?.valid || (!paymethodSelected && cart?.balance > 0) || placing || errorCash || cart?.subtotal < cart?.minimum || (placeSpotTypes.includes(options?.type) && !cart?.place)
146
+ const isDisabledButtonPlace = loading || !cart?.valid || (!paymethodSelected && cart?.balance > 0) || placing || errorCash ||
147
+ cart?.subtotal < cart?.minimum || (placeSpotTypes.includes(options?.type) && !cart?.place) ||
148
+ (options.type === 1 &&
149
+ validationFields?.fields?.checkout?.driver_tip?.enabled &&
150
+ validationFields?.fields?.checkout?.driver_tip?.required &&
151
+ (Number(cart?.driver_tip) <= 0))
140
152
 
141
153
  const driverTipsOptions = typeof configs?.driver_tip_options?.value === 'string'
142
154
  ? JSON.parse(configs?.driver_tip_options?.value) || []
@@ -238,7 +250,7 @@ const CheckoutUI = (props: any) => {
238
250
 
239
251
  useEffect(() => {
240
252
  if (cart?.products?.length === 0) {
241
- navigation?.canGoBack() && navigation.goBack();
253
+ onNavigationRedirect('Business', { store: cart?.business?.slug, header: null, logo: null })
242
254
  }
243
255
  }, [cart?.products])
244
256
 
@@ -249,13 +261,18 @@ const CheckoutUI = (props: any) => {
249
261
  return (
250
262
  <>
251
263
  <Container noPadding>
252
- <NavBar
253
- isVertical
254
- onActionLeft={() => navigation?.canGoBack() && navigation.goBack()}
255
- title={t('CHECKOUT', 'Checkout')}
256
- style={styles.pagePadding}
257
- titleStyle={{ marginLeft: 0, marginRight: 0 }}
258
- />
264
+ <View style={styles.wrapperNavbar}>
265
+ <NavBar
266
+ title={t('CHECKOUT', 'Checkout')}
267
+ titleAlign={'center'}
268
+ onActionLeft={() => navigation?.canGoBack() && navigation.goBack()}
269
+ showCall={false}
270
+ btnStyle={{ paddingLeft: 0 }}
271
+ style={{ marginTop: Platform.OS === 'ios' ? 0 : 30 }}
272
+ titleWrapStyle={{ paddingHorizontal: 0 }}
273
+ titleStyle={{ marginRight: 0, marginLeft: 0 }}
274
+ />
275
+ </View>
259
276
  <ChContainer style={styles.pagePadding}>
260
277
  <ChSection style={{ paddingTop: 0 }}>
261
278
  <ChHeader>
@@ -546,17 +563,17 @@ const CheckoutUI = (props: any) => {
546
563
  onNavigationRedirect={onNavigationRedirect}
547
564
  paySelected={paymethodSelected}
548
565
  handlePaymentMethodClickCustom={handlePaymentMethodClick}
549
- handlePlaceOrder={handlePlaceOrder}
550
566
  />
551
567
  </ChPaymethods>
552
568
  </ChSection>
553
569
  )}
554
570
 
555
- {!cartState.loading && cart && isWalletEnabled && (
571
+ {!cartState.loading && cart && isWalletEnabled && businessDetails?.business?.configs && (
556
572
  <WalletPaymentOptionContainer>
557
573
  <PaymentOptionWallet
558
574
  cart={cart}
559
575
  businessId={cart?.business_id}
576
+ businessConfigs={businessDetails?.business?.configs}
560
577
  />
561
578
  </WalletPaymentOptionContainer>
562
579
  )}
@@ -594,21 +611,19 @@ const CheckoutUI = (props: any) => {
594
611
  </OText>
595
612
  </TouchableOpacity>
596
613
  </CartHeader>
597
- {props.isFranchiseApp && (
598
- <TouchableOpacity
599
- onPress={() => setOpenChangeStore(true)}
600
- style={{ alignSelf: 'flex-start' }}
614
+ <TouchableOpacity
615
+ onPress={() => setOpenChangeStore(true)}
616
+ style={{ alignSelf: 'flex-start' }}
617
+ >
618
+ <OText
619
+ size={12}
620
+ lineHeight={18}
621
+ color={theme.colors.textSecondary}
622
+ style={{ textDecorationLine: 'underline' }}
601
623
  >
602
- <OText
603
- size={12}
604
- lineHeight={18}
605
- color={theme.colors.textSecondary}
606
- style={{ textDecorationLine: 'underline' }}
607
- >
608
- {t('CHANGE_STORE', 'Change store')}
609
- </OText>
610
- </TouchableOpacity>
611
- )}
624
+ {t('CHANGE_STORE', 'Change store')}
625
+ </OText>
626
+ </TouchableOpacity>
612
627
  <OrderSummary
613
628
  cart={cart}
614
629
  isCartPending={cart?.status === 2}
@@ -622,7 +637,7 @@ const CheckoutUI = (props: any) => {
622
637
 
623
638
  {!cartState.loading && cart && (
624
639
  <View>
625
- <ChErrors style={{ marginBottom: 0 }}>
640
+ <ChErrors style={{ marginBottom: 10 }}>
626
641
  {!cart?.valid_address && cart?.status !== 2 && (
627
642
  <OText
628
643
  color={theme.colors.error}
@@ -646,7 +661,7 @@ const CheckoutUI = (props: any) => {
646
661
  color={theme.colors.error}
647
662
  size={12}
648
663
  >
649
- {t('WARNING_INVALID_PRODUCTS', 'Some products are invalid, please check them.')}
664
+ {t('WARNING_INVALID_PRODUCTS_CHECKOUT', 'To continue with your checkout, please remove from your cart the products that are not available.')}
650
665
  </OText>
651
666
  )}
652
667
  {placeSpotTypes.includes(options?.type) && !cart?.place && (
@@ -657,11 +672,22 @@ const CheckoutUI = (props: any) => {
657
672
  {t('WARNING_PLACE_SPOT', 'Please, select your spot to place order.')}
658
673
  </OText>
659
674
  )}
675
+ {options.type === 1 &&
676
+ validationFields?.fields?.checkout?.driver_tip?.enabled &&
677
+ validationFields?.fields?.checkout?.driver_tip?.required &&
678
+ (Number(cart?.driver_tip) <= 0) && (
679
+ <OText
680
+ color={theme.colors.error}
681
+ size={12}
682
+ >
683
+ {t('WARNING_INVALID_DRIVER_TIP', 'Driver Tip is required.')}
684
+ </OText>
685
+ )}
660
686
  </ChErrors>
661
687
  </View>
662
688
  )}
663
689
  <OModal
664
- open={openChangeStore && props.isFranchiseApp}
690
+ open={openChangeStore}
665
691
  entireModal
666
692
  customClose
667
693
  onClose={() => setOpenChangeStore(false)}
@@ -705,19 +731,6 @@ const CheckoutUI = (props: any) => {
705
731
  setShowGateway={setShowGateway}
706
732
  />
707
733
  )}
708
- {webviewPaymethod?.gateway === 'square' && showGateway.open && (
709
- <PaymentOptionsWebView
710
- onNavigationRedirect={onNavigationRedirect}
711
- uri={`https://test-square-f50f7.web.app`}
712
- user={user}
713
- token={token}
714
- cart={cart}
715
- currency={currency}
716
- webviewPaymethod={webviewPaymethod}
717
- setShowGateway={setShowGateway}
718
- locationId={'L1NGAY5M6KJRX'}
719
- />
720
- )}
721
734
  </>
722
735
  )
723
736
  }
@@ -870,7 +883,7 @@ export const Checkout = (props: any) => {
870
883
  ...props,
871
884
  UIComponent: CheckoutUI,
872
885
  cartState,
873
- [props.isFranchiseApp ? 'uuid' : 'businessId']: props.isFranchiseApp ? cartUuid : cartState.cart?.business_id
886
+ uuid: cartUuid
874
887
  }
875
888
 
876
889
  return (
@@ -48,22 +48,28 @@ const DriverTipsUI = (props: any) => {
48
48
  }
49
49
  })
50
50
 
51
- const [value, setvalue] = useState(0);
51
+ const [value, setvalue] = useState('');
52
52
 
53
53
  const placeholderCurrency = (configs?.currency_position?.value || 'left') === 'left'
54
54
  ? `${configs?.format_number_currency?.value}0`
55
55
  : `0${configs?.format_number_currency?.value}`
56
56
 
57
57
  const handleChangeDriverTip = (val: any) => {
58
- let tip = parseFloat(val)
59
- tip = isNaN(tip) ? 0 : tip
60
- setvalue(tip)
58
+ const tip = Number(val)
59
+ if ((isNaN(tip) || tip < 0)) {
60
+ setvalue(value)
61
+ return
62
+ }
63
+ setvalue(val)
61
64
  }
62
-
65
+
63
66
  return (
64
67
  <DTContainer>
68
+ <DTLabel>
69
+ {t('CUSTOM_DRIVER_TIP_MESSAGE', '100% of these tips go directly to your driver')}
70
+ </DTLabel>
65
71
  <DTWrapperTips>
66
- {driverTipsOptions.map((option: any, i: number) => (
72
+ {!isDriverTipUseCustom && driverTipsOptions.map((option: any, i: number) => (
67
73
  <TouchableOpacity
68
74
  key={i}
69
75
  onPress={() => handlerChangeOption(option)}
@@ -79,7 +85,7 @@ const DriverTipsUI = (props: any) => {
79
85
  </TouchableOpacity>
80
86
  ))}
81
87
  </DTWrapperTips>
82
- {!driverTipsOptions.includes(driverTip) && driverTip > 0 && (
88
+ {(!isDriverTipUseCustom && !driverTipsOptions.includes(driverTip) && driverTip > 0) && (
83
89
  <OText
84
90
  color={theme.colors.error}
85
91
  size={16}
@@ -90,13 +96,12 @@ const DriverTipsUI = (props: any) => {
90
96
  )}
91
97
  {isDriverTipUseCustom && (
92
98
  <DTForm>
93
- <DTLabel>
94
- {t('CUSTOM_DRIVER_TIP_MESSAGE', '100% of these tips go directly to your driver')}
95
- </DTLabel>
96
99
  <DTWrapperInput>
97
100
  <OInput
98
101
  placeholder={placeholderCurrency}
99
102
  style={style.inputStyle}
103
+ value={value}
104
+ type={'numeric'}
100
105
  onChange={handleChangeDriverTip}
101
106
  autoCapitalize='none'
102
107
  autoCorrect={false}
@@ -108,10 +113,10 @@ const DriverTipsUI = (props: any) => {
108
113
  textStyle={{ color: 'white', fontSize: 14 }}
109
114
  imgRightSrc={null}
110
115
  style={{ borderRadius: 5, height: 44 }}
111
- isDisabled={!(value > 0 && value !== driverTip) || !value}
116
+ isDisabled={parseFloat(value || '0') < 0 || parseFloat(value || '0') === driverTip || value === ''}
112
117
  onClick={() => {
113
118
  handlerChangeOption(value)
114
- setvalue(0)
119
+ setvalue('')
115
120
  }}
116
121
  />
117
122
  </DTWrapperInput>