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