ordering-ui-react-native 0.17.49 → 0.17.50-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 (219) hide show
  1. package/package.json +8 -7
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/BusinessesListing/index.tsx +1 -1
  4. package/src/components/OrderCreating/index.tsx +1 -21
  5. package/src/components/PaymentOptionsWebView/index.tsx +29 -8
  6. package/src/components/PhoneInputNumber/index.tsx +6 -2
  7. package/src/components/StripeMethodForm/index.tsx +136 -102
  8. package/src/components/VerifyPhone/styles.tsx +1 -2
  9. package/src/components/shared/OToast.tsx +4 -4
  10. package/src/types/index.tsx +5 -0
  11. package/src/utils/index.tsx +7 -1
  12. package/themes/business/index.tsx +2 -0
  13. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +265 -240
  14. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +6 -4
  15. package/themes/business/src/components/BusinessController/index.tsx +0 -1
  16. package/themes/business/src/components/Chat/index.tsx +125 -113
  17. package/themes/business/src/components/DriverMap/index.tsx +17 -6
  18. package/themes/business/src/components/DriverSchedule/index.tsx +29 -2
  19. package/themes/business/src/components/GoogleMap/index.tsx +58 -57
  20. package/themes/business/src/components/LoginForm/Otp/index.tsx +120 -0
  21. package/themes/business/src/components/LoginForm/Otp/styles.tsx +7 -0
  22. package/themes/business/src/components/LoginForm/index.tsx +238 -80
  23. package/themes/business/src/components/LoginForm/styles.tsx +10 -0
  24. package/themes/business/src/components/MapView/index.tsx +10 -10
  25. package/themes/business/src/components/NewOrderNotification/index.tsx +35 -21
  26. package/themes/business/src/components/OrderDetails/Delivery.tsx +30 -4
  27. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +93 -50
  28. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +59 -62
  29. package/themes/business/src/components/OrderDetailsLogistic/index.tsx +195 -0
  30. package/themes/business/src/components/OrderDetailsLogistic/styles.tsx +5 -0
  31. package/themes/business/src/components/OrderMessage/index.tsx +18 -17
  32. package/themes/business/src/components/OrderSummary/index.tsx +113 -121
  33. package/themes/business/src/components/OrdersOption/index.tsx +32 -75
  34. package/themes/business/src/components/PreviousOrders/OrderItem.tsx +250 -0
  35. package/themes/business/src/components/PreviousOrders/OrdersGroupedItem.tsx +115 -0
  36. package/themes/business/src/components/PreviousOrders/index.tsx +445 -243
  37. package/themes/business/src/components/PreviousOrders/styles.tsx +31 -3
  38. package/themes/business/src/components/ProductItemAccordion/index.tsx +27 -3
  39. package/themes/business/src/components/ReviewCustomer/index.tsx +29 -14
  40. package/themes/business/src/components/StoresList/index.tsx +2 -2
  41. package/themes/business/src/components/UserProfileForm/index.tsx +11 -13
  42. package/themes/business/src/components/shared/OLink.tsx +33 -13
  43. package/themes/business/src/components/shared/OModal.tsx +16 -9
  44. package/themes/business/src/components/shared/OText.tsx +8 -2
  45. package/themes/business/src/types/index.tsx +32 -2
  46. package/themes/business/src/utils/index.tsx +44 -1
  47. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  48. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  49. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  50. package/themes/kiosk/src/components/BusinessesListing/index.tsx +2 -1
  51. package/themes/kiosk/src/components/Checkout/index.tsx +6 -0
  52. package/themes/kiosk/src/components/LoginForm/Otp/index.tsx +92 -0
  53. package/themes/kiosk/src/components/LoginForm/Otp/styles.tsx +7 -0
  54. package/themes/kiosk/src/components/LoginForm/index.tsx +480 -156
  55. package/themes/kiosk/src/components/LoginForm/styles.tsx +14 -1
  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/PhoneInputNumber/index.tsx +3 -2
  60. package/themes/kiosk/src/components/PhoneInputNumber/styles.tsx +1 -3
  61. package/themes/kiosk/src/components/ProductForm/index.tsx +1 -14
  62. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  63. package/themes/kiosk/src/components/shared/OModal.tsx +14 -11
  64. package/themes/kiosk/src/layouts/Container.tsx +7 -1
  65. package/themes/kiosk/src/types/index.d.ts +13 -0
  66. package/themes/kiosk/src/utils/index.tsx +15 -0
  67. package/themes/original/index.tsx +6 -0
  68. package/themes/original/src/components/AddressDetails/index.tsx +29 -11
  69. package/themes/original/src/components/AddressForm/index.tsx +79 -44
  70. package/themes/original/src/components/AddressList/index.tsx +27 -22
  71. package/themes/original/src/components/AddressList/styles.tsx +4 -2
  72. package/themes/original/src/components/AnalyticsSegment/index.tsx +193 -10
  73. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  74. package/themes/original/src/components/AppleLogin/styles.tsx +3 -1
  75. package/themes/original/src/components/BusinessBasicInformation/index.tsx +160 -91
  76. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +9 -7
  77. package/themes/original/src/components/BusinessController/index.tsx +146 -68
  78. package/themes/original/src/components/BusinessController/styles.tsx +22 -2
  79. package/themes/original/src/components/BusinessFeaturedController/index.tsx +21 -54
  80. package/themes/original/src/components/BusinessFeaturedController/styles.tsx +8 -0
  81. package/themes/original/src/components/BusinessInformation/index.tsx +10 -31
  82. package/themes/original/src/components/BusinessItemAccordion/index.tsx +23 -22
  83. package/themes/original/src/components/BusinessListingSearch/index.tsx +352 -326
  84. package/themes/original/src/components/BusinessPreorder/index.tsx +97 -16
  85. package/themes/original/src/components/BusinessProductsList/index.tsx +23 -14
  86. package/themes/original/src/components/BusinessProductsList/styles.tsx +8 -3
  87. package/themes/original/src/components/BusinessProductsListing/UpsellingRedirect.tsx +1 -1
  88. package/themes/original/src/components/BusinessProductsListing/index.tsx +669 -513
  89. package/themes/original/src/components/BusinessProductsListing/styles.tsx +2 -2
  90. package/themes/original/src/components/BusinessReviews/index.tsx +3 -1
  91. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +1 -1
  92. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +98 -79
  93. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +1 -11
  94. package/themes/original/src/components/BusinessesListing/index.tsx +0 -1
  95. package/themes/original/src/components/Cart/index.tsx +100 -67
  96. package/themes/original/src/components/CartContent/index.tsx +115 -19
  97. package/themes/original/src/components/CartContent/styles.tsx +17 -7
  98. package/themes/original/src/components/Checkout/index.tsx +366 -173
  99. package/themes/original/src/components/Checkout/styles.tsx +4 -2
  100. package/themes/original/src/components/CitiesControl/index.tsx +89 -0
  101. package/themes/original/src/components/CitiesControl/styles.tsx +17 -0
  102. package/themes/original/src/components/CouponControl/index.tsx +10 -3
  103. package/themes/original/src/components/DriverTips/index.tsx +52 -34
  104. package/themes/original/src/components/FacebookLogin/styles.tsx +3 -1
  105. package/themes/original/src/components/Favorite/index.tsx +8 -9
  106. package/themes/original/src/components/Favorite/styles.tsx +1 -1
  107. package/themes/original/src/components/FavoriteList/index.tsx +51 -80
  108. package/themes/original/src/components/FloatingButton/index.tsx +1 -2
  109. package/themes/original/src/components/FloatingButton/styles.tsx +1 -1
  110. package/themes/original/src/components/GPSButton/index.tsx +6 -4
  111. package/themes/original/src/components/GPSButton/styles.ts +3 -3
  112. package/themes/original/src/components/GiftCard/GiftCardUI/index.tsx +96 -0
  113. package/themes/original/src/components/GiftCard/GiftCardUI/styles.tsx +5 -0
  114. package/themes/original/src/components/GiftCard/PurchaseGiftCard/index.tsx +100 -0
  115. package/themes/original/src/components/GiftCard/PurchaseGiftCard/styles.tsx +8 -0
  116. package/themes/original/src/components/GiftCard/RedeemGiftCard/index.tsx +191 -0
  117. package/themes/original/src/components/GiftCard/RedeemGiftCard/styles.tsx +8 -0
  118. package/themes/original/src/components/GiftCard/SendGiftCard/index.tsx +165 -0
  119. package/themes/original/src/components/GiftCard/SendGiftCard/styles.tsx +9 -0
  120. package/themes/original/src/components/GoogleLogin/styles.tsx +1 -1
  121. package/themes/original/src/components/GoogleMap/index.tsx +15 -4
  122. package/themes/original/src/components/Help/index.tsx +8 -8
  123. package/themes/original/src/components/HelpAccountAndPayment/index.tsx +10 -31
  124. package/themes/original/src/components/HelpAccountAndPayment/styles.tsx +5 -3
  125. package/themes/original/src/components/HelpGuide/index.tsx +6 -6
  126. package/themes/original/src/components/HelpGuide/styles.tsx +6 -0
  127. package/themes/original/src/components/HelpOrder/index.tsx +6 -15
  128. package/themes/original/src/components/HelpOrder/styles.tsx +8 -1
  129. package/themes/original/src/components/Home/index.tsx +13 -4
  130. package/themes/original/src/components/LastOrder/index.tsx +1 -34
  131. package/themes/original/src/components/LoginForm/Otp/index.tsx +55 -13
  132. package/themes/original/src/components/LoginForm/Otp/styles.tsx +0 -1
  133. package/themes/original/src/components/LoginForm/index.tsx +64 -26
  134. package/themes/original/src/components/LottieAnimation/index.tsx +89 -55
  135. package/themes/original/src/components/MessageListing/index.tsx +16 -42
  136. package/themes/original/src/components/Messages/index.tsx +32 -10
  137. package/themes/original/src/components/MomentOption/index.tsx +195 -88
  138. package/themes/original/src/components/MultiCart/index.tsx +50 -0
  139. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +151 -49
  140. package/themes/original/src/components/MultiCheckout/index.tsx +308 -88
  141. package/themes/original/src/components/MultiCheckout/styles.tsx +3 -1
  142. package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +37 -224
  143. package/themes/original/src/components/MultiOrdersDetails/index.tsx +68 -21
  144. package/themes/original/src/components/MultiOrdersDetails/styles.tsx +1 -1
  145. package/themes/original/src/components/MyOrders/index.tsx +77 -52
  146. package/themes/original/src/components/NavBar/index.tsx +18 -18
  147. package/themes/original/src/components/NotFoundSource/index.tsx +14 -10
  148. package/themes/original/src/components/Notifications/index.tsx +46 -50
  149. package/themes/original/src/components/Notifications/styles.tsx +6 -3
  150. package/themes/original/src/components/OrderDetails/OrderEta.tsx +76 -0
  151. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +15 -3
  152. package/themes/original/src/components/OrderDetails/index.tsx +190 -358
  153. package/themes/original/src/components/OrderDetails/styles.tsx +0 -1
  154. package/themes/original/src/components/OrderItAgain/index.tsx +3 -1
  155. package/themes/original/src/components/OrderProgress/index.tsx +93 -114
  156. package/themes/original/src/components/OrderProgress/styles.tsx +5 -0
  157. package/themes/original/src/components/OrderSummary/index.tsx +85 -57
  158. package/themes/original/src/components/OrderTypeSelector/index.tsx +1 -1
  159. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +24 -19
  160. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +14 -14
  161. package/themes/original/src/components/OrdersOption/index.tsx +76 -66
  162. package/themes/original/src/components/OrdersOption/styles.tsx +1 -1
  163. package/themes/original/src/components/PageBanner/index.tsx +171 -0
  164. package/themes/original/src/components/PageBanner/styles.tsx +11 -0
  165. package/themes/original/src/components/PaymentOptionCard/index.tsx +180 -0
  166. package/themes/original/src/components/PaymentOptionStripe/styles.tsx +1 -1
  167. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  168. package/themes/original/src/components/PaymentOptions/index.tsx +64 -7
  169. package/themes/original/src/components/PhoneInputNumber/index.tsx +3 -3
  170. package/themes/original/src/components/PlaceSpot/index.tsx +12 -6
  171. package/themes/original/src/components/ProductForm/index.tsx +114 -36
  172. package/themes/original/src/components/ProductForm/styles.tsx +5 -7
  173. package/themes/original/src/components/ProductItemAccordion/index.tsx +17 -14
  174. package/themes/original/src/components/ProductOptionSubOption/index.tsx +24 -14
  175. package/themes/original/src/components/ProductOptionSubOption/styles.tsx +3 -4
  176. package/themes/original/src/components/ProfessionalFilter/SingleProfessionalCard/index.tsx +108 -0
  177. package/themes/original/src/components/ProfessionalFilter/index.tsx +20 -50
  178. package/themes/original/src/components/ProfessionalProfile/index.tsx +36 -7
  179. package/themes/original/src/components/Promotions/index.tsx +234 -220
  180. package/themes/original/src/components/Promotions/styles.tsx +10 -3
  181. package/themes/original/src/components/ReviewDriver/index.tsx +3 -3
  182. package/themes/original/src/components/ReviewOrder/index.tsx +26 -9
  183. package/themes/original/src/components/ReviewOrder/styles.tsx +7 -0
  184. package/themes/original/src/components/ReviewProducts/index.tsx +23 -11
  185. package/themes/original/src/components/ReviewTrigger/index.tsx +27 -9
  186. package/themes/original/src/components/ReviewTrigger/styles.tsx +8 -1
  187. package/themes/original/src/components/ScheduleAccordion/index.tsx +68 -0
  188. package/themes/original/src/components/ScheduleAccordion/styles.tsx +14 -0
  189. package/themes/original/src/components/ServiceForm/index.tsx +66 -17
  190. package/themes/original/src/components/Sessions/index.tsx +11 -8
  191. package/themes/original/src/components/Sessions/styles.tsx +5 -0
  192. package/themes/original/src/components/SignupForm/index.tsx +43 -20
  193. package/themes/original/src/components/SingleOrderCard/index.tsx +130 -52
  194. package/themes/original/src/components/SingleOrderCard/styles.tsx +11 -2
  195. package/themes/original/src/components/SingleProductCard/index.tsx +72 -34
  196. package/themes/original/src/components/SingleProductCard/styles.tsx +22 -4
  197. package/themes/original/src/components/SingleProductReview/styles.tsx +1 -1
  198. package/themes/original/src/components/StripeCardsList/index.tsx +13 -3
  199. package/themes/original/src/components/StripeElementsForm/index.tsx +67 -34
  200. package/themes/original/src/components/UpsellingProducts/index.tsx +238 -224
  201. package/themes/original/src/components/UpsellingProducts/styles.tsx +12 -1
  202. package/themes/original/src/components/UserDetails/index.tsx +8 -4
  203. package/themes/original/src/components/UserFormDetails/index.tsx +76 -7
  204. package/themes/original/src/components/UserFormDetails/styles.tsx +1 -1
  205. package/themes/original/src/components/UserProfile/index.tsx +12 -29
  206. package/themes/original/src/components/UserProfileForm/index.tsx +27 -29
  207. package/themes/original/src/components/UserProfileForm/styles.tsx +7 -0
  208. package/themes/original/src/components/WalletTransactionItem/index.tsx +2 -2
  209. package/themes/original/src/components/WalletTransactions/index.tsx +3 -3
  210. package/themes/original/src/components/Wallets/index.tsx +67 -24
  211. package/themes/original/src/components/Wallets/styles.tsx +3 -4
  212. package/themes/original/src/components/shared/HeaderTitle.tsx +8 -3
  213. package/themes/original/src/components/shared/OButton.tsx +6 -2
  214. package/themes/original/src/components/shared/OInput.tsx +16 -2
  215. package/themes/original/src/components/shared/OModal.tsx +3 -3
  216. package/themes/original/src/layouts/Container.tsx +1 -1
  217. package/themes/original/src/types/index.tsx +40 -11
  218. package/themes/original/src/utils/index.tsx +375 -58
  219. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
@@ -1,17 +1,18 @@
1
1
  import React, { useCallback, useEffect, useRef, useState } from 'react'
2
- import { View, TouchableOpacity, StyleSheet, SafeAreaView, Dimensions, Platform, KeyboardAvoidingViewBase, KeyboardAvoidingView } from 'react-native'
2
+ import { View, TouchableOpacity, StyleSheet, SafeAreaView, Dimensions, Platform, KeyboardAvoidingViewBase, KeyboardAvoidingView, Keyboard, KeyboardEvent, BackHandler } from 'react-native'
3
3
  import { IOScrollView } from 'react-native-intersection-observer'
4
4
  import { useSafeAreaInsets } from 'react-native-safe-area-context'
5
5
  import { useTheme } from 'styled-components/native';
6
6
  import {
7
- BusinessAndProductList,
8
- useLanguage,
9
- useOrder,
10
- useSession,
11
- useUtils,
12
- ToastType,
13
- useToast,
14
- useConfig
7
+ BusinessAndProductList,
8
+ useLanguage,
9
+ useOrder,
10
+ useSession,
11
+ useUtils,
12
+ ToastType,
13
+ useToast,
14
+ useConfig,
15
+ useEvent
15
16
  } from 'ordering-components/native'
16
17
  import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
17
18
  import { OButton, OIcon, OModal, OText } from '../shared'
@@ -24,17 +25,18 @@ import { BusinessProductsListingParams } from '../../types'
24
25
  import { _retrieveStoreData, _removeStoreData } from '../../providers/StoreUtil';
25
26
  import IconAntDesign from 'react-native-vector-icons/AntDesign';
26
27
  import { useIsFocused } from '@react-navigation/native';
28
+ import AntDesignIcon from 'react-native-vector-icons/AntDesign'
29
+ import ReactNativeHapticFeedback from "react-native-haptic-feedback";
27
30
 
28
31
  import {
29
- TopHeader,
30
- WrapSearchBar,
31
- WrapContent,
32
- FiltProductsContainer,
33
- ContainerSafeAreaView,
34
- BackgroundGray,
35
- ProfessionalFilterWrapper,
36
- NearBusiness,
37
- TopActions
32
+ TopHeader,
33
+ WrapSearchBar,
34
+ WrapContent,
35
+ FiltProductsContainer,
36
+ BackgroundGray,
37
+ ProfessionalFilterWrapper,
38
+ NearBusiness,
39
+ TopActions
38
40
  } from './styles'
39
41
  import { FloatingButton } from '../FloatingButton'
40
42
  import { UpsellingRedirect } from './UpsellingRedirect'
@@ -42,521 +44,675 @@ import Animated from 'react-native-reanimated'
42
44
  import { ProfessionalFilter } from '../ProfessionalFilter';
43
45
  import { ServiceForm } from '../ServiceForm';
44
46
  import { BusinessesListing } from '../BusinessesListing/Layout/Original'
47
+ import { PageBanner } from '../PageBanner'
48
+ import { vibrateApp } from '../../utils';
45
49
 
46
50
  const PIXELS_TO_SCROLL = 2000
47
51
 
48
52
  const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
49
- const {
50
- navigation,
51
- errors,
52
- businessState,
53
- categoryState,
54
- handleChangeSearch,
55
- categorySelected,
56
- searchValue,
57
- handleChangeCategory,
58
- handleSearchRedirect,
59
- featuredProducts,
60
- errorQuantityProducts,
61
- header,
62
- logo,
63
- alertState,
64
- setAlertState,
65
- multiRemoveProducts,
66
- getNextProducts,
67
- handleUpdateProducts,
68
- professionalSelected,
69
- handleChangeProfessionalSelected,
70
- onBusinessClick
71
- } = props
72
-
73
- const insets = useSafeAreaInsets()
74
- const theme = useTheme();
75
- const [, t] = useLanguage()
76
- const [{ auth }] = useSession()
77
- const [orderState, { clearCart }] = useOrder()
78
- const [{ parsePrice }] = useUtils()
79
- const [, { showToast }] = useToast()
80
- const [{ configs }] = useConfig()
81
- const isFocused = useIsFocused();
82
- const isPreOrder = configs?.preorder_status_enabled?.value === '1'
83
-
84
- const isChewLayout = theme?.business_view?.components?.header?.components?.layout?.type === 'chew'
85
- const showLogo = !theme?.business_view?.components?.header?.components?.business?.components?.logo?.hidden
86
- const hideBusinessNearCity = theme?.business_view?.components?.near_business?.hidden ?? true
87
-
88
- const styles = StyleSheet.create({
89
- mainContainer: {
90
- flex: 1
91
- },
92
- BackIcon: {
93
- paddingRight: 20,
94
- },
95
- headerItem: {
96
- flexDirection: 'row',
97
- alignItems: 'center',
98
- marginVertical: 2,
99
- marginHorizontal: 20,
100
- },
101
- btnBackArrow: {
102
- borderWidth: 0,
103
- backgroundColor: theme.colors.clear,
104
- shadowColor: theme.colors.clear,
105
- padding: 40,
106
- },
107
- searchIcon: {
108
- borderWidth: 0,
109
- padding: 15,
110
- justifyContent: 'center',
111
- shadowColor: theme.colors.clear,
112
- },
113
- businessSkeleton: {
114
- borderRadius: 8,
115
- marginRight: 20,
116
- width: 56,
117
- height: 56
118
- },
119
- })
120
-
121
- const { business, loading, error } = businessState
122
- const [openBusinessInformation, setOpenBusinessInformation] = useState(false)
123
- const [isOpenSearchBar, setIsOpenSearchBar] = useState(false)
124
- const [openUpselling, setOpenUpselling] = useState(false)
125
- const [canOpenUpselling, setCanOpenUpselling] = useState(false)
126
- const scrollViewRef = useRef<any>(null)
127
- const [categoriesLayout, setCategoriesLayout] = useState<any>({})
128
- const [productListLayout, setProductListLayout] = useState<any>(null)
129
- const [isCategoryClicked, setCategoryClicked] = useState(false)
130
- const [subcategoriesSelected, setSubcategoriesSelected] = useState([])
131
- const [openService, setOpenService] = useState(false)
132
- const [currentProduct, setCurrentProduct] = useState(null)
53
+ const {
54
+ navigation,
55
+ errors,
56
+ businessState,
57
+ categoryState,
58
+ handleChangeSearch,
59
+ categorySelected,
60
+ searchValue,
61
+ handleChangeCategory,
62
+ handleSearchRedirect,
63
+ featuredProducts,
64
+ errorQuantityProducts,
65
+ header,
66
+ logo,
67
+ alertState,
68
+ setAlertState,
69
+ multiRemoveProducts,
70
+ getNextProducts,
71
+ handleUpdateProducts,
72
+ professionalSelected,
73
+ handleUpdateProfessionals,
74
+ handleChangeProfessionalSelected,
75
+ onBusinessClick,
76
+ businessSingleId
77
+ } = props
78
+
79
+ const insets = useSafeAreaInsets()
80
+ const theme = useTheme();
81
+ const [, t] = useLanguage()
82
+ const [{ auth }] = useSession()
83
+ const [orderState, { addProduct, updateProduct }] = useOrder()
84
+ const [{ parsePrice }] = useUtils()
85
+ const [, { showToast }] = useToast()
86
+ const [{ configs }] = useConfig()
87
+ const [events] = useEvent()
88
+ const isFocused = useIsFocused();
89
+ const isPreOrder = configs?.preorder_status_enabled?.value === '1'
90
+
91
+ const isChewLayout = theme?.header?.components?.layout?.type === 'chew'
92
+ const showLogo = !theme?.business_view?.components?.header?.components?.business?.components?.logo?.hidden
93
+ const hideBusinessNearCity = theme?.business_view?.components?.near_business?.hidden ?? true
94
+ const backgroundColor = theme?.business_view?.components?.style?.backgroundColor
95
+ const styles = StyleSheet.create({
96
+ mainContainer: {
97
+ flex: 1
98
+ },
99
+ BackIcon: {
100
+ paddingRight: 20,
101
+ },
102
+ headerItem: {
103
+ flexDirection: 'row',
104
+ alignItems: 'center',
105
+ marginVertical: 2,
106
+ marginHorizontal: 20,
107
+ },
108
+ btnBackArrow: {
109
+ borderWidth: 0,
110
+ backgroundColor: theme.colors.clear,
111
+ shadowColor: theme.colors.clear,
112
+ padding: 40,
113
+ },
114
+ searchIcon: {
115
+ borderWidth: 0,
116
+ padding: 15,
117
+ justifyContent: 'center',
118
+ shadowColor: theme.colors.clear,
119
+ },
120
+ businessSkeleton: {
121
+ borderRadius: 8,
122
+ marginRight: 20,
123
+ width: 56,
124
+ height: 56
125
+ },
126
+ })
127
+
128
+ const { business, loading, error } = businessState
129
+ const [openBusinessInformation, setOpenBusinessInformation] = useState(false)
130
+ const [isOpenSearchBar, setIsOpenSearchBar] = useState(false)
131
+ const [openUpselling, setOpenUpselling] = useState(false)
132
+ const [canOpenUpselling, setCanOpenUpselling] = useState(false)
133
+ const scrollViewRef = useRef<any>(null)
134
+ const [categoriesLayout, setCategoriesLayout] = useState<any>({})
135
+ const [productListLayout, setProductListLayout] = useState<any>(null)
136
+ const [isCategoryClicked, setCategoryClicked] = useState(false)
137
+ const [subcategoriesSelected, setSubcategoriesSelected] = useState([])
138
+ const [openService, setOpenService] = useState(false)
139
+ const [currentProduct, setCurrentProduct] = useState(null)
133
140
  const [searchBarHeight, setSearchBarHeight] = useState(60)
141
+ const [keyboardHeight, setKeyboardHeight] = useState(0);
142
+ const [viewedCategory, setViewedCategory] = useState<any>(null)
143
+ const [showTitle, setShowTitle] = useState(false)
144
+
145
+ const isCheckoutMultiBusinessEnabled: Boolean = configs?.checkout_multi_business_enabled?.value === '1'
146
+ const isQuickAddProduct = configs?.add_product_with_one_click?.value === '1'
147
+ const openCarts = (Object.values(orderState?.carts)?.filter((cart: any) => cart?.products && cart?.products?.length && cart?.status !== 2 && cart?.valid_schedule && cart?.valid_products && cart?.valid_address && cart?.valid_maximum && cart?.valid_minimum && !cart?.wallets) || null) || []
148
+ const currentCart: any = Object.values(orderState.carts).find((cart: any) => cart?.business?.slug === business?.slug) ?? {}
149
+ const isOpenFiltProducts = isOpenSearchBar && !!searchValue
150
+ const filtProductsHeight = Platform.OS === 'ios' ? 165 : 100
151
+ const viewOrderButtonVisible = !loading && auth && currentCart?.products?.length > 0 && categoryState.products.length !== 0
152
+
153
+ const onRedirect = (route: string, params?: any) => {
154
+ navigation.navigate(route, params)
155
+ }
156
+ const vibrateApp = (impact?: string) => {
157
+ const options = {
158
+ enableVibrateFallback: true,
159
+ ignoreAndroidSystemSettings: false
160
+ };
161
+ ReactNativeHapticFeedback.trigger(impact || "impactLight", options);
162
+ }
163
+ const onProductClick = async (product: any) => {
164
+ if (product.ingredients?.length === 0 && product.extras.length === 0 && !product.inventoried && auth && isQuickAddProduct) {
165
+ const isProductAddedToCart = currentCart?.products?.find((Cproduct: any) => Cproduct.id === product.id)
166
+ const productQuantity = isProductAddedToCart?.quantity
167
+ const addCurrentProduct = {
168
+ ...product,
169
+ quantity: 1
170
+ }
171
+ const updateCurrentProduct = {
172
+ name: product?.name,
173
+ id: product.id,
174
+ code: isProductAddedToCart?.code,
175
+ quantity: productQuantity + 1
176
+ }
177
+ vibrateApp()
178
+ const cartData = currentCart?.business_id ? currentCart : { business_id: business.id }
179
+ if (isProductAddedToCart) {
180
+ await updateProduct(updateCurrentProduct, cartData, isQuickAddProduct)
181
+ } else {
182
+ await addProduct(addCurrentProduct, cartData, isQuickAddProduct)
183
+ }
184
+ } else {
185
+ const productAddedToCartLength = currentCart?.products?.reduce((productsLength: number, Cproduct: any) => { return productsLength + (Cproduct?.id === product?.id ? Cproduct?.quantity : 0) }, 0) || 0
186
+ if (product?.type === 'service' && business?.professionals?.length > 0) {
187
+ setCurrentProduct(product)
188
+ setOpenService(true)
189
+ return
190
+ }
191
+ onRedirect('ProductDetails', {
192
+ product: product,
193
+ businessSlug: business.slug,
194
+ businessId: business.id,
195
+ productAddedToCartLength
196
+ })
197
+ }
198
+ events.emit('product_clicked', product)
199
+ }
200
+
201
+ const handleCancel = () => {
202
+ setIsOpenSearchBar(false)
203
+ handleChangeSearch('')
204
+ }
205
+
206
+ const handleUpsellingPage = (cart: any) => {
207
+ const isProductCartParam = !!cart?.products?.length
208
+ setOpenUpselling(false)
209
+ setCanOpenUpselling(false)
210
+ const cartsAvailable: any = Object.values(orderState?.carts)
211
+ ?.filter((_cart: any) => _cart?.valid && _cart?.status !== 2 && _cart?.products?.length)
212
+ ?.filter((_c: any) => !isProductCartParam ? _c.uuid !== cart?.uuid : _c)
213
+ if (cartsAvailable.length === 1 || !isCheckoutMultiBusinessEnabled) {
214
+ const cart = isCheckoutMultiBusinessEnabled ? cartsAvailable[0] : currentCart
215
+
216
+ props.onNavigationRedirect('CheckoutNavigator', {
217
+ screen: 'CheckoutPage',
218
+ cartUuid: cart?.uuid,
219
+ businessLogo: cart?.business?.logo,
220
+ businessName: cart?.business?.name,
221
+ cartTotal: cart?.total
222
+ }, true)
223
+ } else {
224
+ const groupKeys: any = {}
225
+ cartsAvailable.forEach((_cart: any) => {
226
+ groupKeys[_cart?.group?.uuid]
227
+ ? groupKeys[_cart?.group?.uuid] += 1
228
+ : groupKeys[_cart?.group?.uuid ?? 'null'] = 1
229
+ })
230
+
231
+ if (
232
+ (Object.keys(groupKeys).length === 1 && Object.keys(groupKeys)[0] === 'null') ||
233
+ Object.keys(groupKeys).length > 1
234
+ ) {
235
+ props.onNavigationRedirect('CheckoutNavigator', {
236
+ screen: 'MultiCheckout',
237
+ checkCarts: true
238
+ }, true)
239
+ } else {
240
+ props.onNavigationRedirect('CheckoutNavigator', {
241
+ screen: 'MultiCheckout',
242
+ cartUuid: cartsAvailable[0]?.group?.uuid
243
+ }, true)
244
+ }
245
+ }
246
+ }
247
+
248
+ const handleCloseUpsellingPage = () => {
249
+ setOpenUpselling(false)
250
+ }
251
+
252
+ const [selectedCategoryId, setSelectedCategoryId] = useState<any>(null)
253
+
254
+ const handlePageScroll = useCallback(({ nativeEvent }: any) => {
255
+ const scrollOffset = nativeEvent.contentOffset.y
256
+ setShowTitle(scrollOffset > 30)
257
+
258
+ if (businessState?.business?.lazy_load_products_recommended) {
259
+ const height = nativeEvent.contentSize.height
260
+ const hasMore = !(categoryState.pagination.totalPages === categoryState.pagination.currentPage)
261
+ if (scrollOffset + PIXELS_TO_SCROLL > height && !loading && hasMore && getNextProducts) {
262
+ getNextProducts()
263
+ showToast(ToastType.Info, t('LOADING_MORE_PRODUCTS', 'Loading more products'))
264
+ }
265
+ } else {
266
+ if (!scrollOffset || !categoriesLayout || !productListLayout || isCategoryClicked) return
267
+
268
+ for (const key in categoriesLayout) {
269
+ const categoryOffset = categoriesLayout[key].y + productListLayout?.y - 70
270
+ if (scrollOffset < 10) {
271
+ setSelectedCategoryId('cat_all');
272
+ return;
273
+ }
274
+ if (categoryOffset - 50 <= scrollOffset && scrollOffset <= categoryOffset + 50) {
275
+ if (selectedCategoryId !== key) {
276
+ setSelectedCategoryId(key)
277
+ }
278
+ }
279
+ }
280
+ }
281
+ }, [isCategoryClicked, selectedCategoryId, productListLayout])
282
+
283
+ const handleTouchDrag = useCallback(() => {
284
+ setCategoryClicked(false);
285
+ }, []);
134
286
 
135
- const isCheckoutMultiBusinessEnabled: Boolean = configs?.checkout_multi_business_enabled?.value === '1'
136
- const openCarts = (Object.values(orderState?.carts)?.filter((cart: any) => cart?.products && cart?.products?.length && cart?.status !== 2 && cart?.valid_schedule && cart?.valid_products && cart?.valid_address && cart?.valid_maximum && cart?.valid_minimum && !cart?.wallets) || null) || []
137
-
138
- const currentCart: any = Object.values(orderState.carts).find((cart: any) => cart?.business?.slug === business?.slug) ?? {}
139
- const isOpenFiltProducts = isOpenSearchBar && !!searchValue
140
- const filtProductsHeight = Platform.OS === 'ios' ? 0 : 100
141
- const onRedirect = (route: string, params?: any) => {
142
- navigation.navigate(route, params)
143
- }
144
-
145
- const onProductClick = (product: any) => {
146
- const productAddedToCartLength = currentCart?.products?.reduce((productsLength: number, Cproduct: any) => { return productsLength + (Cproduct?.id === product?.id ? Cproduct?.quantity : 0) }, 0) || 0
147
- if (product?.type === 'service' && business?.professionals?.length > 0) {
148
- setCurrentProduct(product)
149
- setOpenService(true)
150
- return
151
- }
152
- onRedirect('ProductDetails', {
153
- product: product,
154
- businessSlug: business.slug,
155
- businessId: business.id,
156
- productAddedToCartLength
157
- })
158
- }
159
-
160
- const handleCancel = () => {
161
- setIsOpenSearchBar(false)
162
- handleChangeSearch('')
163
- }
164
-
165
- const handleUpsellingPage = () => {
166
- if (isCheckoutMultiBusinessEnabled && openCarts.length > 1) {
167
- onRedirect('CheckoutNavigator', {
168
- screen: 'MultiCheckout'
169
- })
170
- } else {
171
- onRedirect('CheckoutNavigator', {
172
- screen: 'CheckoutPage',
173
- cartUuid: currentCart?.uuid,
174
- businessLogo: logo,
175
- businessName: business?.name,
176
- cartTotal: currentCart?.total
177
- })
178
- }
179
- setOpenUpselling(false)
180
- }
181
-
182
- const handleCloseUpsellingPage = () => {
183
- setOpenUpselling(false)
184
- }
185
-
186
- const [selectedCategoryId, setSelectedCategoryId] = useState<any>(null)
187
-
188
- const handlePageScroll = useCallback(({ nativeEvent }: any) => {
189
- const scrollOffset = nativeEvent.contentOffset.y
190
- if (businessState?.business?.lazy_load_products_recommended) {
191
- const height = nativeEvent.contentSize.height
192
- const hasMore = !(categoryState.pagination.totalPages === categoryState.pagination.currentPage)
193
- if (scrollOffset + PIXELS_TO_SCROLL > height && !loading && hasMore && getNextProducts) {
194
- getNextProducts()
195
- showToast(ToastType.Info, t('LOADING_MORE_PRODUCTS', 'Loading more products'))
196
- }
197
- } else {
198
- if (!scrollOffset || !categoriesLayout || !productListLayout || isCategoryClicked) return
199
-
200
- for (const key in categoriesLayout) {
201
- const categoryOffset = categoriesLayout[key].y + productListLayout?.y - 70
202
- if (scrollOffset < 10) {
203
- setSelectedCategoryId('cat_all');
204
- return;
205
- }
206
- if (categoryOffset - 50 <= scrollOffset && scrollOffset <= categoryOffset + 50) {
207
- if (selectedCategoryId !== key) {
208
- setSelectedCategoryId(key)
209
- }
210
- }
211
- }
212
- }
213
- }, [isCategoryClicked, selectedCategoryId, productListLayout])
214
-
215
- const handleTouchDrag = useCallback(() => {
216
- setCategoryClicked(false);
217
- }, []);
218
-
219
- const handleBackNavigation = () => {
220
- navigation?.canGoBack() ? navigation.goBack() : navigation.navigate('BottomTab')
221
- }
222
-
223
- const adjustBusiness = async (adjustBusinessId: number) => {
224
- const _carts = orderState?.carts?.[adjustBusinessId]
225
- const products = _carts?.products
226
- const unavailableProducts = products.filter((product: any) => product.valid !== true)
227
- const alreadyRemoved = await _retrieveStoreData('already-removed')
228
- _removeStoreData('already-removed')
229
- if (unavailableProducts.length > 0) {
230
- multiRemoveProducts && await multiRemoveProducts(unavailableProducts, _carts)
231
- return
232
- }
233
-
234
- if (alreadyRemoved === 'removed') {
235
- setAlertState({ open: true, content: [t('NOT_AVAILABLE_PRODUCT', 'This product is not available.')] })
236
- }
237
- }
238
-
239
- const removeCartByReOrder = async () => {
240
- const adjustBusinessId = await _retrieveStoreData('adjust-cart-products')
241
- if (currentCart && adjustBusinessId) {
242
- _removeStoreData('adjust-cart-products')
243
- adjustBusiness(adjustBusinessId)
244
- }
245
- }
246
-
247
- useEffect(() => {
248
- removeCartByReOrder()
249
- }, [currentCart])
250
-
251
- useEffect(() => {
252
- if (!isFocused) {
253
- handleChangeSearch('')
254
- setIsOpenSearchBar(false)
255
- }
256
- }, [isFocused])
257
-
258
- return (
259
- <>
260
- <View style={{ flex: 1 }}>
261
- <Animated.View style={{ position: 'relative' }}>
262
- <TopHeader
263
- style={{
264
- marginTop: Platform.OS === 'ios' ? insets.top : 0
265
- }}
266
- onLayout={(event: any) => setSearchBarHeight(event.nativeEvent.layout.height) }
267
- >
268
- {!isOpenSearchBar && (
269
- <>
270
- <TopActions onPress={() => handleBackNavigation()}>
271
- <IconAntDesign name='arrowleft' size={26} />
272
- </TopActions>
273
- {!errorQuantityProducts && (
274
- <View style={{ ...styles.headerItem }}>
275
- <TouchableOpacity
276
- onPress={() => setIsOpenSearchBar(true)}
277
- style={styles.searchIcon}
278
- >
279
- <OIcon src={theme.images.general.search} color={theme.colors.textNormal} width={16} />
280
- </TouchableOpacity>
281
- </View>
282
- )}
283
- </>
284
- )}
285
- {isOpenSearchBar && (
286
- <WrapSearchBar>
287
- <SearchBar
288
- autoFocus
289
- onSearch={handleChangeSearch}
290
- onCancel={() => handleCancel()}
291
- isCancelXButtonShow
292
- noBorderShow
293
- placeholder={t('SEARCH_PRODUCTS', 'Search Products')}
294
- lazyLoad={businessState?.business?.lazy_load_products_recommended}
295
- />
296
- </WrapSearchBar>
297
- )}
298
- </TopHeader>
299
- {!hideBusinessNearCity && loading && (
300
- <NearBusiness style={{ paddingBottom: 10 }}>
301
- <Placeholder Animation={Fade}>
302
- <View style={{ flexDirection: 'row' }}>
303
- {[...Array(10).keys()].map(i => (
304
- <View style={styles.businessSkeleton} key={i}>
305
- <PlaceholderLine style={{ width: '100%', height: '100%' }} />
306
- </View>
307
- ))}
308
- </View>
309
- </Placeholder>
310
- </NearBusiness>
311
- )}
312
- {!loading && !hideBusinessNearCity && businessState?.business?.city_id && (
313
- <NearBusiness>
314
- <BusinessesListing
315
- logosLayout
316
- propsToFetch={['id', 'logo', 'location', 'timezone', 'schedule', 'open', 'slug']}
317
- cityId={businessState?.business?.city_id}
318
- onBusinessClick={onBusinessClick}
319
- actualSlug={businessState?.business?.slug}
320
- />
321
- </NearBusiness>
322
- )}
323
- </Animated.View>
324
-
325
- {business?.categories?.length > 0 && isOpenFiltProducts && (
326
- <FiltProductsContainer
287
+ const handleBackNavigation = () => {
288
+ navigation?.canGoBack() ? navigation.goBack() : navigation.navigate('BottomTab')
289
+ }
290
+
291
+ const adjustBusiness = async (adjustBusinessId: number) => {
292
+ const _carts = orderState?.carts?.[adjustBusinessId]
293
+ const products = _carts?.products
294
+ const unavailableProducts = products.filter((product: any) => product.valid !== true)
295
+ const alreadyRemoved = await _retrieveStoreData('already-removed')
296
+ _removeStoreData('already-removed')
297
+ if (unavailableProducts.length > 0) {
298
+ multiRemoveProducts && await multiRemoveProducts(unavailableProducts, _carts)
299
+ return
300
+ }
301
+
302
+ if (alreadyRemoved === 'removed') {
303
+ setAlertState({ open: true, content: [t('NOT_AVAILABLE_PRODUCT', 'This product is not available.')] })
304
+ }
305
+ }
306
+
307
+ const removeCartByReOrder = async () => {
308
+ const adjustBusinessId = await _retrieveStoreData('adjust-cart-products')
309
+ if (currentCart && adjustBusinessId) {
310
+ _removeStoreData('adjust-cart-products')
311
+ adjustBusiness(adjustBusinessId)
312
+ }
313
+ }
314
+
315
+ useEffect(() => {
316
+ removeCartByReOrder()
317
+ }, [currentCart])
318
+
319
+ useEffect(() => {
320
+ if (!isFocused) {
321
+ handleChangeSearch('')
322
+ setIsOpenSearchBar(false)
323
+ }
324
+ }, [isFocused])
325
+
326
+ useEffect(() => {
327
+ function onKeyboardDidShow(e: KeyboardEvent) {
328
+ setKeyboardHeight(e?.endCoordinates?.height);
329
+ }
330
+
331
+ function onKeyboardDidHide() {
332
+ setKeyboardHeight(0);
333
+ }
334
+
335
+ const showSubscription = Keyboard.addListener('keyboardDidShow', onKeyboardDidShow);
336
+ const hideSubscription = Keyboard.addListener('keyboardDidHide', onKeyboardDidHide);
337
+ return () => {
338
+ showSubscription.remove();
339
+ hideSubscription.remove();
340
+ };
341
+ }, []);
342
+
343
+ const subtotalWithTaxes = currentCart?.taxes?.reduce((acc: any, item: any) => {
344
+ if (item?.type === 1)
345
+ return acc = acc + item?.summary?.tax
346
+ return acc = acc
347
+ }, currentCart?.subtotal)
348
+
349
+ const onChangeSearch = (query: any) => {
350
+ handleChangeSearch(query)
351
+ if (query) {
352
+ events.emit('products_searched', query)
353
+ }
354
+ }
355
+
356
+ useEffect(() => {
357
+ let categoryId: any = null
358
+ if (business?.lazy_load_products_recommended) {
359
+ if (categorySelected?.id) {
360
+ categoryId = categorySelected.id
361
+ }
362
+ } else {
363
+ if (selectedCategoryId) {
364
+ const originCategoryId = selectedCategoryId.replace('cat_', '')
365
+ if (!isNaN(originCategoryId)) {
366
+ categoryId = Number(originCategoryId)
367
+ }
368
+ }
369
+ }
370
+ if (categoryId) {
371
+ const _viewedCategory = business.categories.find(category => category.id === categoryId)
372
+ if (_viewedCategory?.id !== viewedCategory?.id) {
373
+ setViewedCategory(_viewedCategory)
374
+ events.emit('product_list_viewed', _viewedCategory)
375
+ }
376
+ }
377
+ }, [business?.lazy_load_products_recommended, selectedCategoryId, categorySelected?.id, viewedCategory])
378
+
379
+ useEffect(() => {
380
+ const handleArrowBack: any = () => {
381
+ navigation.goBack()
382
+ return true
383
+ }
384
+ BackHandler.addEventListener('hardwareBackPress', handleArrowBack);
385
+ return () => {
386
+ BackHandler.removeEventListener('hardwareBackPress', handleArrowBack);
387
+ }
388
+ }, [])
389
+
390
+ return (
391
+ <>
392
+ <View style={{ flex: 1, backgroundColor: backgroundColor }}>
393
+ <Animated.View style={{ position: 'relative' }}>
394
+ <TopHeader
395
+ style={{
396
+ marginTop: Platform.OS === 'ios' ? insets.top : 0
397
+ }}
398
+ onLayout={(event: any) => setSearchBarHeight(event.nativeEvent.layout.height)}
399
+ hideArrow={(businessSingleId && auth)}
400
+ >
401
+ {!isOpenSearchBar && (
402
+ <>
403
+ {!(businessSingleId && auth) && (
404
+ <TopActions onPress={() => handleBackNavigation()}>
405
+ <AntDesignIcon
406
+ name='arrowleft'
407
+ size={26}
408
+ />
409
+ </TopActions>
410
+ )}
411
+ {showTitle && (
412
+ <OText
413
+ size={16}
414
+ style={{ flex: 1, textAlign: 'center' }}
415
+ weight={Platform.OS === 'ios' ? '600' : 'bold'}
416
+ numberOfLines={2}
417
+ ellipsizeMode='tail'
418
+ >
419
+ {business?.name}
420
+ </OText>
421
+ )}
422
+ {!errorQuantityProducts && (
423
+ <View style={{ ...styles.headerItem }}>
424
+ <TouchableOpacity
425
+ onPress={() => setIsOpenSearchBar(true)}
426
+ style={styles.searchIcon}
427
+ >
428
+ <OIcon src={theme.images.general.search} color={theme.colors.textNormal} width={20} />
429
+ </TouchableOpacity>
430
+ </View>
431
+ )}
432
+ </>
433
+ )}
434
+ {isOpenSearchBar && (
435
+ <WrapSearchBar>
436
+ <SearchBar
437
+ autoFocus
438
+ onSearch={onChangeSearch}
439
+ onCancel={() => handleCancel()}
440
+ isCancelXButtonShow
441
+ noBorderShow
442
+ placeholder={t('SEARCH_PRODUCTS', 'Search Products')}
443
+ lazyLoad
444
+ />
445
+ </WrapSearchBar>
446
+ )}
447
+ </TopHeader>
448
+ {!hideBusinessNearCity && loading && (
449
+ <NearBusiness style={{ paddingBottom: 10 }}>
450
+ <Placeholder Animation={Fade}>
451
+ <View style={{ flexDirection: 'row' }}>
452
+ {[...Array(10).keys()].map(i => (
453
+ <View style={styles.businessSkeleton} key={i}>
454
+ <PlaceholderLine style={{ width: '100%', height: '100%' }} />
455
+ </View>
456
+ ))}
457
+ </View>
458
+ </Placeholder>
459
+ </NearBusiness>
460
+ )}
461
+ {!loading && !hideBusinessNearCity && businessState?.business?.city_id && (
462
+ <NearBusiness>
463
+ <BusinessesListing
464
+ logosLayout
465
+ propsToFetch={['id', 'logo', 'location', 'timezone', 'schedule', 'open', 'slug']}
466
+ cityId={businessState?.business?.city_id}
467
+ onBusinessClick={onBusinessClick}
468
+ actualSlug={businessState?.business?.slug}
469
+ />
470
+ </NearBusiness>
471
+ )}
472
+ </Animated.View>
473
+
474
+ {business?.categories?.length > 0 && isOpenFiltProducts && (
475
+ <FiltProductsContainer
476
+ style={{
477
+ height: Dimensions.get('window').height - filtProductsHeight - keyboardHeight - (keyboardHeight > 0 && viewOrderButtonVisible ? 55 : 0),
478
+ top: Platform.OS === 'ios' ? (searchBarHeight - 10) + insets.top : searchBarHeight,
479
+ }}
480
+ contentContainerStyle={{ flexGrow: 1 }}
481
+ >
482
+ <View style={{ padding: 20, backgroundColor: theme.colors.white }}>
483
+ <BusinessProductsList
484
+ categories={[
485
+ { id: null, name: t('ALL', 'All') },
486
+ { id: 'featured', name: t('FEATURED', 'Featured') },
487
+ ...business?.categories.sort((a: any, b: any) => a.rank - b.rank)
488
+ ]}
489
+ category={categorySelected}
490
+ categoryState={categoryState}
491
+ businessId={business.id}
492
+ errors={errors}
493
+ onProductClick={onProductClick}
494
+ handleSearchRedirect={handleSearchRedirect}
495
+ featured={featuredProducts}
496
+ searchValue={searchValue}
497
+ handleClearSearch={handleChangeSearch}
498
+ errorQuantityProducts={errorQuantityProducts}
499
+ handleCancelSearch={handleCancel}
500
+ categoriesLayout={categoriesLayout}
501
+ subcategoriesSelected={subcategoriesSelected}
502
+ lazyLoadProductsRecommended={business?.lazy_load_products_recommended}
503
+ setCategoriesLayout={setCategoriesLayout}
504
+ currentCart={currentCart}
505
+ setSubcategoriesSelected={setSubcategoriesSelected}
506
+ onClickCategory={handleChangeCategory}
507
+ handleUpdateProducts={handleUpdateProducts}
508
+ previouslyProducts={business?.previously_products}
509
+ navigation={navigation}
510
+ isFiltMode
511
+ businessSingleId={businessSingleId}
512
+ />
513
+ </View>
514
+ </FiltProductsContainer>
515
+ )}
516
+ {isOpenFiltProducts && (
517
+ <BackgroundGray isIos={Platform.OS === 'ios'} />
518
+ )}
519
+ <IOScrollView
520
+ stickyHeaderIndices={[business?.professionals?.length > 0 ? 4 : 3]}
327
521
  style={{
328
- height: Dimensions.get('window').height - filtProductsHeight,
329
- top: Platform.OS === 'ios' ? searchBarHeight + insets.top : searchBarHeight
522
+ ...styles.mainContainer,
523
+ marginBottom: currentCart?.products?.length > 0 && categoryState.products.length !== 0 ?
524
+ 50 : 0
330
525
  }}
331
- contentContainerStyle={{ flexGrow: 1 }}
526
+ ref={scrollViewRef}
527
+ onScroll={handlePageScroll}
528
+ onScrollBeginDrag={handleTouchDrag}
529
+ scrollEventThrottle={16}
530
+ bounces={false}
332
531
  >
333
- <View style={{ padding: 20, backgroundColor: theme.colors.white }}>
334
- <BusinessProductsList
335
- categories={[
336
- { id: null, name: t('ALL', 'All') },
337
- { id: 'featured', name: t('FEATURED', 'Featured') },
338
- ...business?.categories.sort((a: any, b: any) => a.rank - b.rank)
339
- ]}
340
- category={categorySelected}
341
- categoryState={categoryState}
342
- businessId={business.id}
343
- errors={errors}
344
- onProductClick={onProductClick}
345
- handleSearchRedirect={handleSearchRedirect}
346
- featured={featuredProducts}
347
- searchValue={searchValue}
348
- handleClearSearch={handleChangeSearch}
349
- errorQuantityProducts={errorQuantityProducts}
350
- handleCancelSearch={handleCancel}
351
- categoriesLayout={categoriesLayout}
352
- subcategoriesSelected={subcategoriesSelected}
353
- lazyLoadProductsRecommended={business?.lazy_load_products_recommended}
354
- setCategoriesLayout={setCategoriesLayout}
355
- currentCart={currentCart}
356
- setSubcategoriesSelected={setSubcategoriesSelected}
357
- onClickCategory={handleChangeCategory}
358
- handleUpdateProducts={handleUpdateProducts}
359
- previouslyProducts={business?.previously_products}
360
- navigation={navigation}
361
- isFiltMode
362
- />
363
- </View>
364
- </FiltProductsContainer>
365
- )}
366
- {isOpenFiltProducts && (
367
- <BackgroundGray isIos={Platform.OS === 'ios'} />
368
- )}
369
- <IOScrollView
370
- stickyHeaderIndices={[business?.professionals?.length > 0 ? 3 : 2]}
371
- style={{
372
- ...styles.mainContainer,
373
- marginBottom: currentCart?.products?.length > 0 && categoryState.products.length !== 0 ?
374
- 50 : 0
375
- }}
376
- ref={scrollViewRef}
377
- onScroll={handlePageScroll}
378
- onScrollBeginDrag={handleTouchDrag}
379
- scrollEventThrottle={16}
380
- bounces={false}
381
- >
382
- <BusinessBasicInformation
383
- navigation={navigation}
384
- businessState={businessState}
385
- openBusinessInformation={openBusinessInformation}
386
- header={header}
387
- logo={logo}
388
- isPreOrder={isPreOrder}
389
- />
390
- {business?.professionals?.length > 0 && (
391
- <ProfessionalFilterWrapper>
392
- <OText
393
- size={16}
394
- style={{ marginBottom: 16 }}
395
- weight={Platform.OS === 'ios' ? '600' : 'bold'}
396
- >
397
- {t('PROFESSIONALS', 'Professionals')}
398
- </OText>
399
- <ProfessionalFilter
400
- professionals={business?.professionals}
401
- professionalSelected={professionalSelected}
402
- handleChangeProfessionalSelected={handleChangeProfessionalSelected}
403
- />
404
- </ProfessionalFilterWrapper>
405
- )}
406
- <View
407
- style={{
408
- height: 8,
409
- backgroundColor: theme.colors.backgroundGray100,
410
- marginTop: isChewLayout && showLogo ? 10 : 0
411
- }}
412
- />
413
- {!loading && business?.id && !(business?.categories?.length === 0) && (
414
- <BusinessProductsCategories
415
- categories={[{ id: null, name: t('ALL', 'All') }, { id: 'featured', name: t('FEATURED', 'Featured') }, ...business?.categories.sort((a: any, b: any) => a.rank - b.rank)]}
416
- categorySelected={categorySelected}
417
- onClickCategory={handleChangeCategory}
418
- featured={featuredProducts}
419
- openBusinessInformation={openBusinessInformation}
420
- scrollViewRef={scrollViewRef}
421
- productListLayout={productListLayout}
422
- categoriesLayout={categoriesLayout}
423
- selectedCategoryId={selectedCategoryId}
424
- lazyLoadProductsRecommended={business?.lazy_load_products_recommended}
425
- setSelectedCategoryId={setSelectedCategoryId}
426
- setCategoryClicked={setCategoryClicked}
427
- />
428
- )}
429
- {!loading && business?.id && (
430
- <>
431
- <WrapContent
432
- onLayout={(event: any) => setProductListLayout(event.nativeEvent.layout)}
433
- >
434
- <BusinessProductsList
435
- categories={[
436
- { id: null, name: t('ALL', 'All') },
437
- { id: 'featured', name: t('FEATURED', 'Featured') },
438
- ...business?.categories.sort((a: any, b: any) => a.rank - b.rank)
439
- ]}
440
- category={categorySelected}
441
- categoryState={categoryState}
442
- businessId={business.id}
443
- errors={errors}
444
- onProductClick={onProductClick}
445
- handleSearchRedirect={handleSearchRedirect}
446
- featured={featuredProducts}
447
- searchValue={searchValue}
448
- handleClearSearch={handleChangeSearch}
449
- errorQuantityProducts={errorQuantityProducts}
450
- handleCancelSearch={handleCancel}
451
- categoriesLayout={categoriesLayout}
452
- subcategoriesSelected={subcategoriesSelected}
453
- lazyLoadProductsRecommended={business?.lazy_load_products_recommended}
454
- setCategoriesLayout={setCategoriesLayout}
455
- currentCart={currentCart}
456
- setSubcategoriesSelected={setSubcategoriesSelected}
457
- onClickCategory={handleChangeCategory}
458
- handleUpdateProducts={handleUpdateProducts}
459
- navigation={navigation}
460
- previouslyProducts={business?.previously_products}
461
- />
462
- </WrapContent>
463
- </>
464
- )}
465
- {loading && !error && (
466
- <>
467
- <BusinessProductsCategories
468
- categories={[]}
469
- categorySelected={categorySelected}
470
- onClickCategory={handleChangeCategory}
471
- featured={featuredProducts}
472
- openBusinessInformation={openBusinessInformation}
473
- loading={loading}
474
- />
475
- <WrapContent>
476
- <BusinessProductsList
477
- categories={[]}
478
- category={categorySelected}
479
- categoryState={categoryState}
480
- isBusinessLoading={loading}
481
- errorQuantityProducts={errorQuantityProducts}
482
- handleUpdateProducts={handleUpdateProducts}
483
- navigation={navigation}
484
- />
485
- </WrapContent>
486
- </>
487
- )}
488
- </IOScrollView>
489
- {!loading && auth && currentCart?.products?.length > 0 && categoryState.products.length !== 0 && (
490
- <View style={{ marginBottom: Platform.OS === 'ios' ? 20 : 0 }}>
491
- <FloatingButton
532
+ <BusinessBasicInformation
533
+ navigation={navigation}
534
+ businessState={businessState}
535
+ openBusinessInformation={openBusinessInformation}
536
+ header={header}
537
+ logo={logo}
538
+ isPreOrder={isPreOrder}
539
+ />
540
+ {business?.professionals?.length > 0 && (
541
+ <ProfessionalFilterWrapper>
542
+ <OText
543
+ size={16}
544
+ style={{ marginBottom: 16 }}
545
+ weight={Platform.OS === 'ios' ? '600' : 'bold'}
546
+ >
547
+ {t('PROFESSIONALS', 'Professionals')}
548
+ </OText>
549
+ <ProfessionalFilter
550
+ professionals={business?.professionals}
551
+ professionalSelected={professionalSelected}
552
+ handleChangeProfessionalSelected={handleChangeProfessionalSelected}
553
+ handleUpdateProfessionals={handleUpdateProfessionals}
554
+ />
555
+ </ProfessionalFilterWrapper>
556
+ )}
557
+ <PageBanner position='app_business_page' navigation={navigation} />
558
+ <View
559
+ style={{
560
+ height: 8,
561
+ backgroundColor: theme.colors.backgroundGray100,
562
+ marginTop: isChewLayout && showLogo ? 10 : 0
563
+ }}
564
+ />
565
+ {!loading && business?.id && !(business?.categories?.length === 0) && (
566
+ <BusinessProductsCategories
567
+ categories={[{ id: null, name: t('ALL', 'All') }, { id: 'featured', name: t('FEATURED', 'Featured') }, ...business?.categories.sort((a: any, b: any) => a.rank - b.rank)]}
568
+ categorySelected={categorySelected}
569
+ onClickCategory={handleChangeCategory}
570
+ featured={featuredProducts}
571
+ openBusinessInformation={openBusinessInformation}
572
+ scrollViewRef={scrollViewRef}
573
+ productListLayout={productListLayout}
574
+ categoriesLayout={categoriesLayout}
575
+ selectedCategoryId={selectedCategoryId}
576
+ lazyLoadProductsRecommended={business?.lazy_load_products_recommended}
577
+ setSelectedCategoryId={setSelectedCategoryId}
578
+ setCategoryClicked={setCategoryClicked}
579
+ />
580
+ )}
581
+ {!loading && business?.id && (
582
+ <>
583
+ <WrapContent
584
+ onLayout={(event: any) => setProductListLayout(event.nativeEvent.layout)}
585
+ style={{ paddingHorizontal: isChewLayout ? 20 : 40 }}
586
+ >
587
+ <BusinessProductsList
588
+ categories={[
589
+ { id: null, name: t('ALL', 'All') },
590
+ { id: 'featured', name: t('FEATURED', 'Featured') },
591
+ ...business?.categories.sort((a: any, b: any) => a.rank - b.rank)
592
+ ]}
593
+ category={categorySelected}
594
+ categoryState={categoryState}
595
+ businessId={business.id}
596
+ errors={errors}
597
+ onProductClick={onProductClick}
598
+ handleSearchRedirect={handleSearchRedirect}
599
+ featured={featuredProducts}
600
+ searchValue={searchValue}
601
+ handleClearSearch={handleChangeSearch}
602
+ errorQuantityProducts={errorQuantityProducts}
603
+ handleCancelSearch={handleCancel}
604
+ categoriesLayout={categoriesLayout}
605
+ subcategoriesSelected={subcategoriesSelected}
606
+ lazyLoadProductsRecommended={business?.lazy_load_products_recommended}
607
+ setCategoriesLayout={setCategoriesLayout}
608
+ currentCart={currentCart}
609
+ setSubcategoriesSelected={setSubcategoriesSelected}
610
+ onClickCategory={handleChangeCategory}
611
+ handleUpdateProducts={handleUpdateProducts}
612
+ navigation={navigation}
613
+ previouslyProducts={business?.previously_products}
614
+ businessSingleId={businessSingleId}
615
+ />
616
+ </WrapContent>
617
+ </>
618
+ )}
619
+ {loading && !error && (
620
+ <>
621
+ <BusinessProductsCategories
622
+ categories={[]}
623
+ categorySelected={categorySelected}
624
+ onClickCategory={handleChangeCategory}
625
+ featured={featuredProducts}
626
+ openBusinessInformation={openBusinessInformation}
627
+ loading={loading}
628
+ />
629
+ <WrapContent>
630
+ <BusinessProductsList
631
+ categories={[]}
632
+ category={categorySelected}
633
+ categoryState={categoryState}
634
+ isBusinessLoading={loading}
635
+ errorQuantityProducts={errorQuantityProducts}
636
+ handleUpdateProducts={handleUpdateProducts}
637
+ navigation={navigation}
638
+ />
639
+ </WrapContent>
640
+ </>
641
+ )}
642
+ </IOScrollView>
643
+ {viewOrderButtonVisible && (
644
+ <View style={{ marginBottom: 0 }}>
645
+ <FloatingButton
492
646
  btnText={
493
647
  openUpselling
494
648
  ? t('LOADING', 'Loading')
495
- : currentCart?.subtotal >= currentCart?.minimum
649
+ : subtotalWithTaxes >= currentCart?.minimum
496
650
  ? t('VIEW_ORDER', 'View Order')
497
651
  : `${t('MINIMUN_SUBTOTAL_ORDER', 'Minimum subtotal order:')} ${parsePrice(currentCart?.minimum)}`
498
652
  }
499
- isSecondaryBtn={currentCart?.subtotal < currentCart?.minimum || openUpselling}
500
- btnLeftValueShow={currentCart?.subtotal >= currentCart?.minimum && currentCart?.products?.length > 0}
501
- btnRightValueShow={currentCart?.subtotal >= currentCart?.minimum && currentCart?.products?.length > 0}
653
+ isSecondaryBtn={subtotalWithTaxes < currentCart?.minimum || openUpselling}
654
+ btnLeftValueShow={subtotalWithTaxes >= currentCart?.minimum && currentCart?.products?.length > 0}
655
+ btnRightValueShow={subtotalWithTaxes >= currentCart?.minimum && currentCart?.products?.length > 0}
502
656
  btnLeftValue={currentCart?.products.reduce((prev: number, product: any) => prev + product.quantity, 0)}
503
657
  btnRightValue={parsePrice(currentCart?.total)}
504
- disabled={currentCart?.subtotal < currentCart?.minimum || openUpselling}
658
+ disabled={subtotalWithTaxes < currentCart?.minimum || openUpselling}
505
659
  handleClick={() => setOpenUpselling(true)}
506
660
  />
507
- </View>
508
- )}
509
- {openUpselling && (
510
- <UpsellingRedirect
511
- businessId={currentCart?.business_id}
512
- business={currentCart?.business}
513
- cartProducts={currentCart?.products}
514
- cart={currentCart}
515
- setOpenUpselling={setOpenUpselling}
516
- handleUpsellingPage={handleUpsellingPage}
517
- handleCloseUpsellingPage={handleCloseUpsellingPage}
518
- openUpselling={openUpselling}
519
- canOpenUpselling={canOpenUpselling}
520
- setCanOpenUpselling={setCanOpenUpselling}
521
- onRedirect={onRedirect}
522
- />
523
- )}
524
- <Alert
525
- open={alertState?.open || false}
526
- title=''
527
- content={[t('NOT_AVAILABLE_PRODUCTS', 'These products are not available.')]}
528
- onAccept={() => setAlertState({ open: false, content: [] })}
529
- onClose={() => setAlertState({ open: false, content: [] })}
530
- />
531
- </View>
532
- <OModal
533
- open={openService}
534
- onClose={() => setOpenService(false)}
535
- entireModal
536
- >
537
- <ServiceForm
538
- navigation={navigation}
539
- product={currentProduct}
540
- businessSlug={business.slug}
541
- businessId={business.id}
542
- professionalList={business?.professionals}
543
- professionalSelected={professionalSelected}
544
- handleChangeProfessional={handleChangeProfessionalSelected}
545
- onSave={() => setOpenService(false)}
546
- onClose={() => setOpenService(false)}
547
- />
548
- </OModal>
549
- </>
550
- )
661
+ </View>
662
+ )}
663
+ {openUpselling && (
664
+ <UpsellingRedirect
665
+ businessId={currentCart?.business_id}
666
+ business={currentCart?.business}
667
+ cartProducts={currentCart?.products}
668
+ cart={currentCart}
669
+ setOpenUpselling={setOpenUpselling}
670
+ handleUpsellingPage={handleUpsellingPage}
671
+ handleCloseUpsellingPage={handleCloseUpsellingPage}
672
+ openUpselling={openUpselling}
673
+ canOpenUpselling={canOpenUpselling}
674
+ setCanOpenUpselling={setCanOpenUpselling}
675
+ onRedirect={onRedirect}
676
+ />
677
+ )}
678
+ <Alert
679
+ open={alertState?.open || false}
680
+ title=''
681
+ content={[t('NOT_AVAILABLE_PRODUCTS', 'These products are not available.')]}
682
+ onAccept={() => setAlertState({ open: false, content: [] })}
683
+ onClose={() => setAlertState({ open: false, content: [] })}
684
+ />
685
+ </View>
686
+ <OModal
687
+ open={openService}
688
+ onClose={() => setOpenService(false)}
689
+ entireModal
690
+ >
691
+ <ServiceForm
692
+ navigation={navigation}
693
+ product={currentProduct}
694
+ businessSlug={business.slug}
695
+ businessId={business.id}
696
+ professionalList={business?.professionals}
697
+ professionalSelected={professionalSelected}
698
+ handleChangeProfessional={handleChangeProfessionalSelected}
699
+ handleChangeProfessional={handleChangeProfessionalSelected}
700
+ handleUpdateProfessionals={handleUpdateProfessionals}
701
+ onSave={() => setOpenService(false)}
702
+ onClose={() => setOpenService(false)}
703
+ />
704
+ </OModal>
705
+ </>
706
+ )
551
707
  }
552
708
 
553
709
  export const BusinessProductsListing = (props: BusinessProductsListingParams) => {
554
- const businessProductslistingProps = {
555
- ...props,
556
- isForceSearch: Platform.OS === 'ios',
557
- UIComponent: BusinessProductsListingUI
558
- }
559
- return (
560
- <BusinessAndProductList {...businessProductslistingProps} />
561
- )
710
+ const businessProductslistingProps = {
711
+ ...props,
712
+ isForceSearch: Platform.OS === 'ios',
713
+ UIComponent: BusinessProductsListingUI
714
+ }
715
+ return (
716
+ <BusinessAndProductList {...businessProductslistingProps} />
717
+ )
562
718
  }