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