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