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