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