ordering-ui-react-native 0.17.50 → 0.17.51-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 (220) 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 +31 -5
  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 +249 -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 +4 -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 +122 -68
  78. package/themes/original/src/components/BusinessController/styles.tsx +23 -4
  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 +110 -108
  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 +103 -19
  85. package/themes/original/src/components/BusinessProductsCategories/index.tsx +1 -2
  86. package/themes/original/src/components/BusinessProductsList/index.tsx +23 -14
  87. package/themes/original/src/components/BusinessProductsList/styles.tsx +8 -3
  88. package/themes/original/src/components/BusinessProductsListing/UpsellingRedirect.tsx +1 -1
  89. package/themes/original/src/components/BusinessProductsListing/index.tsx +668 -514
  90. package/themes/original/src/components/BusinessProductsListing/styles.tsx +2 -2
  91. package/themes/original/src/components/BusinessReviews/index.tsx +3 -1
  92. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +1 -1
  93. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +95 -80
  94. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +1 -11
  95. package/themes/original/src/components/BusinessesListing/index.tsx +0 -1
  96. package/themes/original/src/components/Cart/index.tsx +100 -67
  97. package/themes/original/src/components/CartContent/index.tsx +115 -19
  98. package/themes/original/src/components/CartContent/styles.tsx +17 -7
  99. package/themes/original/src/components/Checkout/index.tsx +367 -174
  100. package/themes/original/src/components/Checkout/styles.tsx +4 -2
  101. package/themes/original/src/components/CitiesControl/index.tsx +89 -0
  102. package/themes/original/src/components/CitiesControl/styles.tsx +17 -0
  103. package/themes/original/src/components/CouponControl/index.tsx +10 -3
  104. package/themes/original/src/components/DriverTips/index.tsx +52 -34
  105. package/themes/original/src/components/FacebookLogin/styles.tsx +3 -1
  106. package/themes/original/src/components/Favorite/index.tsx +8 -9
  107. package/themes/original/src/components/Favorite/styles.tsx +1 -1
  108. package/themes/original/src/components/FavoriteList/index.tsx +51 -80
  109. package/themes/original/src/components/FloatingButton/index.tsx +1 -2
  110. package/themes/original/src/components/FloatingButton/styles.tsx +1 -1
  111. package/themes/original/src/components/GPSButton/index.tsx +6 -4
  112. package/themes/original/src/components/GPSButton/styles.ts +3 -3
  113. package/themes/original/src/components/GiftCard/GiftCardUI/index.tsx +96 -0
  114. package/themes/original/src/components/GiftCard/GiftCardUI/styles.tsx +5 -0
  115. package/themes/original/src/components/GiftCard/PurchaseGiftCard/index.tsx +100 -0
  116. package/themes/original/src/components/GiftCard/PurchaseGiftCard/styles.tsx +8 -0
  117. package/themes/original/src/components/GiftCard/RedeemGiftCard/index.tsx +191 -0
  118. package/themes/original/src/components/GiftCard/RedeemGiftCard/styles.tsx +8 -0
  119. package/themes/original/src/components/GiftCard/SendGiftCard/index.tsx +165 -0
  120. package/themes/original/src/components/GiftCard/SendGiftCard/styles.tsx +9 -0
  121. package/themes/original/src/components/GoogleLogin/styles.tsx +1 -1
  122. package/themes/original/src/components/GoogleMap/index.tsx +15 -4
  123. package/themes/original/src/components/Help/index.tsx +8 -8
  124. package/themes/original/src/components/HelpAccountAndPayment/index.tsx +10 -31
  125. package/themes/original/src/components/HelpAccountAndPayment/styles.tsx +5 -3
  126. package/themes/original/src/components/HelpGuide/index.tsx +6 -6
  127. package/themes/original/src/components/HelpGuide/styles.tsx +6 -0
  128. package/themes/original/src/components/HelpOrder/index.tsx +6 -15
  129. package/themes/original/src/components/HelpOrder/styles.tsx +8 -1
  130. package/themes/original/src/components/Home/index.tsx +13 -4
  131. package/themes/original/src/components/LastOrder/index.tsx +1 -34
  132. package/themes/original/src/components/LoginForm/Otp/index.tsx +55 -13
  133. package/themes/original/src/components/LoginForm/Otp/styles.tsx +0 -1
  134. package/themes/original/src/components/LoginForm/index.tsx +64 -26
  135. package/themes/original/src/components/LottieAnimation/index.tsx +89 -55
  136. package/themes/original/src/components/MessageListing/index.tsx +16 -42
  137. package/themes/original/src/components/Messages/index.tsx +32 -10
  138. package/themes/original/src/components/MomentOption/index.tsx +195 -88
  139. package/themes/original/src/components/MultiCart/index.tsx +50 -0
  140. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +151 -49
  141. package/themes/original/src/components/MultiCheckout/index.tsx +308 -88
  142. package/themes/original/src/components/MultiCheckout/styles.tsx +3 -1
  143. package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +37 -224
  144. package/themes/original/src/components/MultiOrdersDetails/index.tsx +68 -21
  145. package/themes/original/src/components/MultiOrdersDetails/styles.tsx +1 -1
  146. package/themes/original/src/components/MyOrders/index.tsx +77 -52
  147. package/themes/original/src/components/NavBar/index.tsx +18 -18
  148. package/themes/original/src/components/NotFoundSource/index.tsx +14 -10
  149. package/themes/original/src/components/Notifications/index.tsx +46 -50
  150. package/themes/original/src/components/Notifications/styles.tsx +6 -3
  151. package/themes/original/src/components/OrderDetails/OrderEta.tsx +76 -0
  152. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +15 -3
  153. package/themes/original/src/components/OrderDetails/index.tsx +190 -358
  154. package/themes/original/src/components/OrderDetails/styles.tsx +0 -1
  155. package/themes/original/src/components/OrderItAgain/index.tsx +3 -1
  156. package/themes/original/src/components/OrderProgress/index.tsx +93 -114
  157. package/themes/original/src/components/OrderProgress/styles.tsx +5 -0
  158. package/themes/original/src/components/OrderSummary/index.tsx +85 -57
  159. package/themes/original/src/components/OrderTypeSelector/index.tsx +1 -1
  160. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +24 -19
  161. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +14 -14
  162. package/themes/original/src/components/OrdersOption/index.tsx +76 -66
  163. package/themes/original/src/components/OrdersOption/styles.tsx +1 -1
  164. package/themes/original/src/components/PageBanner/index.tsx +107 -40
  165. package/themes/original/src/components/PageBanner/styles.tsx +4 -1
  166. package/themes/original/src/components/PaymentOptionCard/index.tsx +180 -0
  167. package/themes/original/src/components/PaymentOptionStripe/styles.tsx +1 -1
  168. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  169. package/themes/original/src/components/PaymentOptions/index.tsx +64 -7
  170. package/themes/original/src/components/PhoneInputNumber/index.tsx +3 -3
  171. package/themes/original/src/components/PlaceSpot/index.tsx +12 -6
  172. package/themes/original/src/components/ProductForm/index.tsx +114 -36
  173. package/themes/original/src/components/ProductForm/styles.tsx +5 -7
  174. package/themes/original/src/components/ProductItemAccordion/index.tsx +22 -19
  175. package/themes/original/src/components/ProductOptionSubOption/index.tsx +24 -14
  176. package/themes/original/src/components/ProductOptionSubOption/styles.tsx +3 -4
  177. package/themes/original/src/components/ProfessionalFilter/SingleProfessionalCard/index.tsx +108 -0
  178. package/themes/original/src/components/ProfessionalFilter/index.tsx +20 -50
  179. package/themes/original/src/components/ProfessionalProfile/index.tsx +36 -7
  180. package/themes/original/src/components/Promotions/index.tsx +234 -220
  181. package/themes/original/src/components/Promotions/styles.tsx +10 -3
  182. package/themes/original/src/components/ReviewDriver/index.tsx +3 -3
  183. package/themes/original/src/components/ReviewOrder/index.tsx +26 -9
  184. package/themes/original/src/components/ReviewOrder/styles.tsx +7 -0
  185. package/themes/original/src/components/ReviewProducts/index.tsx +23 -11
  186. package/themes/original/src/components/ReviewTrigger/index.tsx +27 -9
  187. package/themes/original/src/components/ReviewTrigger/styles.tsx +8 -1
  188. package/themes/original/src/components/ScheduleAccordion/index.tsx +68 -0
  189. package/themes/original/src/components/ScheduleAccordion/styles.tsx +14 -0
  190. package/themes/original/src/components/ServiceForm/index.tsx +66 -17
  191. package/themes/original/src/components/Sessions/index.tsx +11 -8
  192. package/themes/original/src/components/Sessions/styles.tsx +5 -0
  193. package/themes/original/src/components/SignupForm/index.tsx +43 -20
  194. package/themes/original/src/components/SingleOrderCard/index.tsx +130 -52
  195. package/themes/original/src/components/SingleOrderCard/styles.tsx +11 -2
  196. package/themes/original/src/components/SingleProductCard/index.tsx +72 -34
  197. package/themes/original/src/components/SingleProductCard/styles.tsx +22 -4
  198. package/themes/original/src/components/SingleProductReview/styles.tsx +1 -1
  199. package/themes/original/src/components/StripeCardsList/index.tsx +13 -3
  200. package/themes/original/src/components/StripeElementsForm/index.tsx +67 -34
  201. package/themes/original/src/components/UpsellingProducts/index.tsx +238 -224
  202. package/themes/original/src/components/UpsellingProducts/styles.tsx +12 -1
  203. package/themes/original/src/components/UserDetails/index.tsx +8 -4
  204. package/themes/original/src/components/UserFormDetails/index.tsx +76 -7
  205. package/themes/original/src/components/UserFormDetails/styles.tsx +1 -1
  206. package/themes/original/src/components/UserProfile/index.tsx +88 -79
  207. package/themes/original/src/components/UserProfileForm/index.tsx +27 -29
  208. package/themes/original/src/components/UserProfileForm/styles.tsx +7 -0
  209. package/themes/original/src/components/WalletTransactionItem/index.tsx +2 -2
  210. package/themes/original/src/components/WalletTransactions/index.tsx +3 -3
  211. package/themes/original/src/components/Wallets/index.tsx +67 -24
  212. package/themes/original/src/components/Wallets/styles.tsx +3 -4
  213. package/themes/original/src/components/shared/HeaderTitle.tsx +8 -3
  214. package/themes/original/src/components/shared/OButton.tsx +6 -2
  215. package/themes/original/src/components/shared/OInput.tsx +16 -2
  216. package/themes/original/src/components/shared/OModal.tsx +3 -3
  217. package/themes/original/src/layouts/Container.tsx +1 -1
  218. package/themes/original/src/types/index.tsx +40 -11
  219. package/themes/original/src/utils/index.tsx +375 -58
  220. 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'
@@ -43,522 +45,674 @@ import { ProfessionalFilter } from '../ProfessionalFilter';
43
45
  import { ServiceForm } from '../ServiceForm';
44
46
  import { BusinessesListing } from '../BusinessesListing/Layout/Original'
45
47
  import { PageBanner } from '../PageBanner'
48
+ import { vibrateApp } from '../../utils';
46
49
 
47
50
  const PIXELS_TO_SCROLL = 2000
48
51
 
49
52
  const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
50
- const {
51
- navigation,
52
- errors,
53
- businessState,
54
- categoryState,
55
- handleChangeSearch,
56
- categorySelected,
57
- searchValue,
58
- handleChangeCategory,
59
- handleSearchRedirect,
60
- featuredProducts,
61
- errorQuantityProducts,
62
- header,
63
- logo,
64
- alertState,
65
- setAlertState,
66
- multiRemoveProducts,
67
- getNextProducts,
68
- handleUpdateProducts,
69
- professionalSelected,
70
- handleChangeProfessionalSelected,
71
- onBusinessClick
72
- } = props
73
-
74
- const insets = useSafeAreaInsets()
75
- const theme = useTheme();
76
- const [, t] = useLanguage()
77
- const [{ auth }] = useSession()
78
- const [orderState, { clearCart }] = useOrder()
79
- const [{ parsePrice }] = useUtils()
80
- const [, { showToast }] = useToast()
81
- const [{ configs }] = useConfig()
82
- const isFocused = useIsFocused();
83
- const isPreOrder = configs?.preorder_status_enabled?.value === '1'
84
-
85
- const isChewLayout = theme?.business_view?.components?.header?.components?.layout?.type === 'chew'
86
- const showLogo = !theme?.business_view?.components?.header?.components?.business?.components?.logo?.hidden
87
- const hideBusinessNearCity = theme?.business_view?.components?.near_business?.hidden ?? true
88
-
89
- const styles = StyleSheet.create({
90
- mainContainer: {
91
- flex: 1
92
- },
93
- BackIcon: {
94
- paddingRight: 20,
95
- },
96
- headerItem: {
97
- flexDirection: 'row',
98
- alignItems: 'center',
99
- marginVertical: 2,
100
- marginHorizontal: 20,
101
- },
102
- btnBackArrow: {
103
- borderWidth: 0,
104
- backgroundColor: theme.colors.clear,
105
- shadowColor: theme.colors.clear,
106
- padding: 40,
107
- },
108
- searchIcon: {
109
- borderWidth: 0,
110
- padding: 15,
111
- justifyContent: 'center',
112
- shadowColor: theme.colors.clear,
113
- },
114
- businessSkeleton: {
115
- borderRadius: 8,
116
- marginRight: 20,
117
- width: 56,
118
- height: 56
119
- },
120
- })
121
-
122
- const { business, loading, error } = businessState
123
- const [openBusinessInformation, setOpenBusinessInformation] = useState(false)
124
- const [isOpenSearchBar, setIsOpenSearchBar] = useState(false)
125
- const [openUpselling, setOpenUpselling] = useState(false)
126
- const [canOpenUpselling, setCanOpenUpselling] = useState(false)
127
- const scrollViewRef = useRef<any>(null)
128
- const [categoriesLayout, setCategoriesLayout] = useState<any>({})
129
- const [productListLayout, setProductListLayout] = useState<any>(null)
130
- const [isCategoryClicked, setCategoryClicked] = useState(false)
131
- const [subcategoriesSelected, setSubcategoriesSelected] = useState([])
132
- const [openService, setOpenService] = useState(false)
133
- 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)
134
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
+ }, []);
135
286
 
136
- const isCheckoutMultiBusinessEnabled: Boolean = configs?.checkout_multi_business_enabled?.value === '1'
137
- 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) || []
138
-
139
- const currentCart: any = Object.values(orderState.carts).find((cart: any) => cart?.business?.slug === business?.slug) ?? {}
140
- const isOpenFiltProducts = isOpenSearchBar && !!searchValue
141
- const filtProductsHeight = Platform.OS === 'ios' ? 0 : 100
142
- const onRedirect = (route: string, params?: any) => {
143
- navigation.navigate(route, params)
144
- }
145
-
146
- const onProductClick = (product: any) => {
147
- const productAddedToCartLength = currentCart?.products?.reduce((productsLength: number, Cproduct: any) => { return productsLength + (Cproduct?.id === product?.id ? Cproduct?.quantity : 0) }, 0) || 0
148
- if (product?.type === 'service' && business?.professionals?.length > 0) {
149
- setCurrentProduct(product)
150
- setOpenService(true)
151
- return
152
- }
153
- onRedirect('ProductDetails', {
154
- product: product,
155
- businessSlug: business.slug,
156
- businessId: business.id,
157
- productAddedToCartLength
158
- })
159
- }
160
-
161
- const handleCancel = () => {
162
- setIsOpenSearchBar(false)
163
- handleChangeSearch('')
164
- }
165
-
166
- const handleUpsellingPage = () => {
167
- if (isCheckoutMultiBusinessEnabled && openCarts.length > 1) {
168
- onRedirect('CheckoutNavigator', {
169
- screen: 'MultiCheckout'
170
- })
171
- } else {
172
- onRedirect('CheckoutNavigator', {
173
- screen: 'CheckoutPage',
174
- cartUuid: currentCart?.uuid,
175
- businessLogo: logo,
176
- businessName: business?.name,
177
- cartTotal: currentCart?.total
178
- })
179
- }
180
- setOpenUpselling(false)
181
- }
182
-
183
- const handleCloseUpsellingPage = () => {
184
- setOpenUpselling(false)
185
- }
186
-
187
- const [selectedCategoryId, setSelectedCategoryId] = useState<any>(null)
188
-
189
- const handlePageScroll = useCallback(({ nativeEvent }: any) => {
190
- const scrollOffset = nativeEvent.contentOffset.y
191
- if (businessState?.business?.lazy_load_products_recommended) {
192
- const height = nativeEvent.contentSize.height
193
- const hasMore = !(categoryState.pagination.totalPages === categoryState.pagination.currentPage)
194
- if (scrollOffset + PIXELS_TO_SCROLL > height && !loading && hasMore && getNextProducts) {
195
- getNextProducts()
196
- showToast(ToastType.Info, t('LOADING_MORE_PRODUCTS', 'Loading more products'))
197
- }
198
- } else {
199
- if (!scrollOffset || !categoriesLayout || !productListLayout || isCategoryClicked) return
200
-
201
- for (const key in categoriesLayout) {
202
- const categoryOffset = categoriesLayout[key].y + productListLayout?.y - 70
203
- if (scrollOffset < 10) {
204
- setSelectedCategoryId('cat_all');
205
- return;
206
- }
207
- if (categoryOffset - 50 <= scrollOffset && scrollOffset <= categoryOffset + 50) {
208
- if (selectedCategoryId !== key) {
209
- setSelectedCategoryId(key)
210
- }
211
- }
212
- }
213
- }
214
- }, [isCategoryClicked, selectedCategoryId, productListLayout])
215
-
216
- const handleTouchDrag = useCallback(() => {
217
- setCategoryClicked(false);
218
- }, []);
219
-
220
- const handleBackNavigation = () => {
221
- navigation?.canGoBack() ? navigation.goBack() : navigation.navigate('BottomTab')
222
- }
223
-
224
- const adjustBusiness = async (adjustBusinessId: number) => {
225
- const _carts = orderState?.carts?.[adjustBusinessId]
226
- const products = _carts?.products
227
- const unavailableProducts = products.filter((product: any) => product.valid !== true)
228
- const alreadyRemoved = await _retrieveStoreData('already-removed')
229
- _removeStoreData('already-removed')
230
- if (unavailableProducts.length > 0) {
231
- multiRemoveProducts && await multiRemoveProducts(unavailableProducts, _carts)
232
- return
233
- }
234
-
235
- if (alreadyRemoved === 'removed') {
236
- setAlertState({ open: true, content: [t('NOT_AVAILABLE_PRODUCT', 'This product is not available.')] })
237
- }
238
- }
239
-
240
- const removeCartByReOrder = async () => {
241
- const adjustBusinessId = await _retrieveStoreData('adjust-cart-products')
242
- if (currentCart && adjustBusinessId) {
243
- _removeStoreData('adjust-cart-products')
244
- adjustBusiness(adjustBusinessId)
245
- }
246
- }
247
-
248
- useEffect(() => {
249
- removeCartByReOrder()
250
- }, [currentCart])
251
-
252
- useEffect(() => {
253
- if (!isFocused) {
254
- handleChangeSearch('')
255
- setIsOpenSearchBar(false)
256
- }
257
- }, [isFocused])
258
-
259
- return (
260
- <>
261
- <View style={{ flex: 1 }}>
262
- <Animated.View style={{ position: 'relative' }}>
263
- <TopHeader
264
- style={{
265
- marginTop: Platform.OS === 'ios' ? insets.top : 0
266
- }}
267
- onLayout={(event: any) => setSearchBarHeight(event.nativeEvent.layout.height) }
268
- >
269
- {!isOpenSearchBar && (
270
- <>
271
- <TopActions onPress={() => handleBackNavigation()}>
272
- <IconAntDesign name='arrowleft' size={26} />
273
- </TopActions>
274
- {!errorQuantityProducts && (
275
- <View style={{ ...styles.headerItem }}>
276
- <TouchableOpacity
277
- onPress={() => setIsOpenSearchBar(true)}
278
- style={styles.searchIcon}
279
- >
280
- <OIcon src={theme.images.general.search} color={theme.colors.textNormal} width={16} />
281
- </TouchableOpacity>
282
- </View>
283
- )}
284
- </>
285
- )}
286
- {isOpenSearchBar && (
287
- <WrapSearchBar>
288
- <SearchBar
289
- autoFocus
290
- onSearch={handleChangeSearch}
291
- onCancel={() => handleCancel()}
292
- isCancelXButtonShow
293
- noBorderShow
294
- placeholder={t('SEARCH_PRODUCTS', 'Search Products')}
295
- lazyLoad={businessState?.business?.lazy_load_products_recommended}
296
- />
297
- </WrapSearchBar>
298
- )}
299
- </TopHeader>
300
- {!hideBusinessNearCity && loading && (
301
- <NearBusiness style={{ paddingBottom: 10 }}>
302
- <Placeholder Animation={Fade}>
303
- <View style={{ flexDirection: 'row' }}>
304
- {[...Array(10).keys()].map(i => (
305
- <View style={styles.businessSkeleton} key={i}>
306
- <PlaceholderLine style={{ width: '100%', height: '100%' }} />
307
- </View>
308
- ))}
309
- </View>
310
- </Placeholder>
311
- </NearBusiness>
312
- )}
313
- {!loading && !hideBusinessNearCity && businessState?.business?.city_id && (
314
- <NearBusiness>
315
- <BusinessesListing
316
- logosLayout
317
- propsToFetch={['id', 'logo', 'location', 'timezone', 'schedule', 'open', 'slug']}
318
- cityId={businessState?.business?.city_id}
319
- onBusinessClick={onBusinessClick}
320
- actualSlug={businessState?.business?.slug}
321
- />
322
- </NearBusiness>
323
- )}
324
- </Animated.View>
325
-
326
- {business?.categories?.length > 0 && isOpenFiltProducts && (
327
- <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]}
328
521
  style={{
329
- height: Dimensions.get('window').height - filtProductsHeight,
330
- top: Platform.OS === 'ios' ? searchBarHeight + insets.top : searchBarHeight
522
+ ...styles.mainContainer,
523
+ marginBottom: currentCart?.products?.length > 0 && categoryState.products.length !== 0 ?
524
+ 50 : 0
331
525
  }}
332
- contentContainerStyle={{ flexGrow: 1 }}
526
+ ref={scrollViewRef}
527
+ onScroll={handlePageScroll}
528
+ onScrollBeginDrag={handleTouchDrag}
529
+ scrollEventThrottle={16}
530
+ bounces={false}
333
531
  >
334
- <View style={{ padding: 20, backgroundColor: theme.colors.white }}>
335
- <BusinessProductsList
336
- categories={[
337
- { id: null, name: t('ALL', 'All') },
338
- { id: 'featured', name: t('FEATURED', 'Featured') },
339
- ...business?.categories.sort((a: any, b: any) => a.rank - b.rank)
340
- ]}
341
- category={categorySelected}
342
- categoryState={categoryState}
343
- businessId={business.id}
344
- errors={errors}
345
- onProductClick={onProductClick}
346
- handleSearchRedirect={handleSearchRedirect}
347
- featured={featuredProducts}
348
- searchValue={searchValue}
349
- handleClearSearch={handleChangeSearch}
350
- errorQuantityProducts={errorQuantityProducts}
351
- handleCancelSearch={handleCancel}
352
- categoriesLayout={categoriesLayout}
353
- subcategoriesSelected={subcategoriesSelected}
354
- lazyLoadProductsRecommended={business?.lazy_load_products_recommended}
355
- setCategoriesLayout={setCategoriesLayout}
356
- currentCart={currentCart}
357
- setSubcategoriesSelected={setSubcategoriesSelected}
358
- onClickCategory={handleChangeCategory}
359
- handleUpdateProducts={handleUpdateProducts}
360
- previouslyProducts={business?.previously_products}
361
- navigation={navigation}
362
- isFiltMode
363
- />
364
- </View>
365
- </FiltProductsContainer>
366
- )}
367
- {isOpenFiltProducts && (
368
- <BackgroundGray isIos={Platform.OS === 'ios'} />
369
- )}
370
- <IOScrollView
371
- stickyHeaderIndices={[business?.professionals?.length > 0 ? 3 : 2]}
372
- style={{
373
- ...styles.mainContainer,
374
- marginBottom: currentCart?.products?.length > 0 && categoryState.products.length !== 0 ?
375
- 50 : 0
376
- }}
377
- ref={scrollViewRef}
378
- onScroll={handlePageScroll}
379
- onScrollBeginDrag={handleTouchDrag}
380
- scrollEventThrottle={16}
381
- bounces={false}
382
- >
383
- <BusinessBasicInformation
384
- navigation={navigation}
385
- businessState={businessState}
386
- openBusinessInformation={openBusinessInformation}
387
- header={header}
388
- logo={logo}
389
- isPreOrder={isPreOrder}
390
- />
391
- {business?.professionals?.length > 0 && (
392
- <ProfessionalFilterWrapper>
393
- <OText
394
- size={16}
395
- style={{ marginBottom: 16 }}
396
- weight={Platform.OS === 'ios' ? '600' : 'bold'}
397
- >
398
- {t('PROFESSIONALS', 'Professionals')}
399
- </OText>
400
- <ProfessionalFilter
401
- professionals={business?.professionals}
402
- professionalSelected={professionalSelected}
403
- handleChangeProfessionalSelected={handleChangeProfessionalSelected}
404
- />
405
- </ProfessionalFilterWrapper>
406
- )}
407
- <PageBanner position='app_business_page' />
408
- <View
409
- style={{
410
- height: 8,
411
- backgroundColor: theme.colors.backgroundGray100,
412
- marginTop: isChewLayout && showLogo ? 10 : 0
413
- }}
414
- />
415
- {!loading && business?.id && !(business?.categories?.length === 0) && (
416
- <BusinessProductsCategories
417
- categories={[{ id: null, name: t('ALL', 'All') }, { id: 'featured', name: t('FEATURED', 'Featured') }, ...business?.categories.sort((a: any, b: any) => a.rank - b.rank)]}
418
- categorySelected={categorySelected}
419
- onClickCategory={handleChangeCategory}
420
- featured={featuredProducts}
421
- openBusinessInformation={openBusinessInformation}
422
- scrollViewRef={scrollViewRef}
423
- productListLayout={productListLayout}
424
- categoriesLayout={categoriesLayout}
425
- selectedCategoryId={selectedCategoryId}
426
- lazyLoadProductsRecommended={business?.lazy_load_products_recommended}
427
- setSelectedCategoryId={setSelectedCategoryId}
428
- setCategoryClicked={setCategoryClicked}
429
- />
430
- )}
431
- {!loading && business?.id && (
432
- <>
433
- <WrapContent
434
- onLayout={(event: any) => setProductListLayout(event.nativeEvent.layout)}
435
- >
436
- <BusinessProductsList
437
- categories={[
438
- { id: null, name: t('ALL', 'All') },
439
- { id: 'featured', name: t('FEATURED', 'Featured') },
440
- ...business?.categories.sort((a: any, b: any) => a.rank - b.rank)
441
- ]}
442
- category={categorySelected}
443
- categoryState={categoryState}
444
- businessId={business.id}
445
- errors={errors}
446
- onProductClick={onProductClick}
447
- handleSearchRedirect={handleSearchRedirect}
448
- featured={featuredProducts}
449
- searchValue={searchValue}
450
- handleClearSearch={handleChangeSearch}
451
- errorQuantityProducts={errorQuantityProducts}
452
- handleCancelSearch={handleCancel}
453
- categoriesLayout={categoriesLayout}
454
- subcategoriesSelected={subcategoriesSelected}
455
- lazyLoadProductsRecommended={business?.lazy_load_products_recommended}
456
- setCategoriesLayout={setCategoriesLayout}
457
- currentCart={currentCart}
458
- setSubcategoriesSelected={setSubcategoriesSelected}
459
- onClickCategory={handleChangeCategory}
460
- handleUpdateProducts={handleUpdateProducts}
461
- navigation={navigation}
462
- previouslyProducts={business?.previously_products}
463
- />
464
- </WrapContent>
465
- </>
466
- )}
467
- {loading && !error && (
468
- <>
469
- <BusinessProductsCategories
470
- categories={[]}
471
- categorySelected={categorySelected}
472
- onClickCategory={handleChangeCategory}
473
- featured={featuredProducts}
474
- openBusinessInformation={openBusinessInformation}
475
- loading={loading}
476
- />
477
- <WrapContent>
478
- <BusinessProductsList
479
- categories={[]}
480
- category={categorySelected}
481
- categoryState={categoryState}
482
- isBusinessLoading={loading}
483
- errorQuantityProducts={errorQuantityProducts}
484
- handleUpdateProducts={handleUpdateProducts}
485
- navigation={navigation}
486
- />
487
- </WrapContent>
488
- </>
489
- )}
490
- </IOScrollView>
491
- {!loading && auth && currentCart?.products?.length > 0 && categoryState.products.length !== 0 && (
492
- <View style={{ marginBottom: Platform.OS === 'ios' ? 20 : 0 }}>
493
- <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
494
646
  btnText={
495
647
  openUpselling
496
648
  ? t('LOADING', 'Loading')
497
- : currentCart?.subtotal >= currentCart?.minimum
649
+ : subtotalWithTaxes >= currentCart?.minimum
498
650
  ? t('VIEW_ORDER', 'View Order')
499
651
  : `${t('MINIMUN_SUBTOTAL_ORDER', 'Minimum subtotal order:')} ${parsePrice(currentCart?.minimum)}`
500
652
  }
501
- isSecondaryBtn={currentCart?.subtotal < currentCart?.minimum || openUpselling}
502
- btnLeftValueShow={currentCart?.subtotal >= currentCart?.minimum && currentCart?.products?.length > 0}
503
- 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}
504
656
  btnLeftValue={currentCart?.products.reduce((prev: number, product: any) => prev + product.quantity, 0)}
505
657
  btnRightValue={parsePrice(currentCart?.total)}
506
- disabled={currentCart?.subtotal < currentCart?.minimum || openUpselling}
658
+ disabled={subtotalWithTaxes < currentCart?.minimum || openUpselling}
507
659
  handleClick={() => setOpenUpselling(true)}
508
660
  />
509
- </View>
510
- )}
511
- {openUpselling && (
512
- <UpsellingRedirect
513
- businessId={currentCart?.business_id}
514
- business={currentCart?.business}
515
- cartProducts={currentCart?.products}
516
- cart={currentCart}
517
- setOpenUpselling={setOpenUpselling}
518
- handleUpsellingPage={handleUpsellingPage}
519
- handleCloseUpsellingPage={handleCloseUpsellingPage}
520
- openUpselling={openUpselling}
521
- canOpenUpselling={canOpenUpselling}
522
- setCanOpenUpselling={setCanOpenUpselling}
523
- onRedirect={onRedirect}
524
- />
525
- )}
526
- <Alert
527
- open={alertState?.open || false}
528
- title=''
529
- content={[t('NOT_AVAILABLE_PRODUCTS', 'These products are not available.')]}
530
- onAccept={() => setAlertState({ open: false, content: [] })}
531
- onClose={() => setAlertState({ open: false, content: [] })}
532
- />
533
- </View>
534
- <OModal
535
- open={openService}
536
- onClose={() => setOpenService(false)}
537
- entireModal
538
- >
539
- <ServiceForm
540
- navigation={navigation}
541
- product={currentProduct}
542
- businessSlug={business.slug}
543
- businessId={business.id}
544
- professionalList={business?.professionals}
545
- professionalSelected={professionalSelected}
546
- handleChangeProfessional={handleChangeProfessionalSelected}
547
- onSave={() => setOpenService(false)}
548
- onClose={() => setOpenService(false)}
549
- />
550
- </OModal>
551
- </>
552
- )
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
+ )
553
707
  }
554
708
 
555
709
  export const BusinessProductsListing = (props: BusinessProductsListingParams) => {
556
- const businessProductslistingProps = {
557
- ...props,
558
- isForceSearch: Platform.OS === 'ios',
559
- UIComponent: BusinessProductsListingUI
560
- }
561
- return (
562
- <BusinessAndProductList {...businessProductslistingProps} />
563
- )
710
+ const businessProductslistingProps = {
711
+ ...props,
712
+ isForceSearch: Platform.OS === 'ios',
713
+ UIComponent: BusinessProductsListingUI
714
+ }
715
+ return (
716
+ <BusinessAndProductList {...businessProductslistingProps} />
717
+ )
564
718
  }