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