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