ordering-ui-react-native 0.15.31 → 0.15.33-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 (178) hide show
  1. package/package.json +4 -2
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/BusinessController/index.tsx +8 -2
  4. package/src/components/BusinessTypeFilter/index.tsx +4 -1
  5. package/src/components/BusinessesListing/index.tsx +1 -1
  6. package/src/components/Checkout/index.tsx +23 -3
  7. package/src/components/DriverTips/index.tsx +11 -6
  8. package/src/components/LanguageSelector/index.tsx +7 -2
  9. package/src/components/LoginForm/index.tsx +3 -1
  10. package/src/components/OrderDetails/index.tsx +2 -2
  11. package/src/components/PaymentOptions/index.tsx +9 -16
  12. package/src/components/PaymentOptionsWebView/index.tsx +123 -124
  13. package/src/components/SignupForm/index.tsx +3 -1
  14. package/src/components/SingleProductCard/index.tsx +16 -4
  15. package/src/components/StripeElementsForm/index.tsx +27 -48
  16. package/src/components/UpsellingProducts/index.tsx +1 -1
  17. package/src/components/UserProfileForm/index.tsx +63 -6
  18. package/src/components/UserProfileForm/styles.tsx +8 -0
  19. package/src/components/VerifyPhone/styles.tsx +1 -2
  20. package/src/components/shared/OModal.tsx +1 -1
  21. package/src/config.json +0 -2
  22. package/src/hooks/useCountdownTimer.tsx +26 -0
  23. package/src/navigators/HomeNavigator.tsx +6 -0
  24. package/src/pages/BusinessProductsList.tsx +1 -0
  25. package/src/pages/BusinessesListing.tsx +1 -1
  26. package/src/pages/Checkout.tsx +1 -1
  27. package/src/pages/Sessions.tsx +22 -0
  28. package/src/types/index.tsx +5 -11
  29. package/src/utils/index.tsx +68 -1
  30. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +103 -15
  31. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +6 -0
  32. package/themes/business/src/components/Chat/index.tsx +38 -86
  33. package/themes/business/src/components/DriverMap/index.tsx +6 -5
  34. package/themes/business/src/components/Home/index.tsx +128 -55
  35. package/themes/business/src/components/Home/styles.tsx +8 -1
  36. package/themes/business/src/components/LoginForm/index.tsx +89 -2
  37. package/themes/business/src/components/LoginForm/styles.tsx +6 -0
  38. package/themes/business/src/components/LogoutButton/index.tsx +1 -1
  39. package/themes/business/src/components/NewOrderNotification/index.tsx +79 -105
  40. package/themes/business/src/components/OrderDetails/Business.tsx +1 -1
  41. package/themes/business/src/components/OrderDetails/Delivery.tsx +32 -15
  42. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +157 -89
  43. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +6 -0
  44. package/themes/business/src/components/OrderDetails/styles.tsx +7 -0
  45. package/themes/business/src/components/OrdersListManager/index.tsx +52 -49
  46. package/themes/business/src/components/OrdersOption/index.tsx +57 -50
  47. package/themes/business/src/components/PreviousOrders/index.tsx +50 -14
  48. package/themes/business/src/components/shared/OModal.tsx +1 -1
  49. package/themes/business/src/types/index.tsx +5 -1
  50. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  51. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  52. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  53. package/themes/kiosk/src/components/Cart/index.tsx +98 -24
  54. package/themes/kiosk/src/components/Cart/styles.tsx +6 -0
  55. package/themes/kiosk/src/components/CartBottomSheet/index.tsx +1 -1
  56. package/themes/kiosk/src/components/CartBottomSheet/styles.tsx +1 -1
  57. package/themes/kiosk/src/components/CartContent/index.tsx +13 -3
  58. package/themes/kiosk/src/components/CartItem/index.tsx +20 -8
  59. package/themes/kiosk/src/components/Checkout/index.tsx +34 -22
  60. package/themes/kiosk/src/components/CustomerName/index.tsx +7 -8
  61. package/themes/kiosk/src/components/Intro/index.tsx +13 -13
  62. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  63. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  64. package/themes/kiosk/src/components/OrderDetails/index.tsx +167 -67
  65. package/themes/kiosk/src/components/OrderDetails/styles.tsx +5 -0
  66. package/themes/kiosk/src/components/OrderSummary/index.tsx +1 -1
  67. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +10 -12
  68. package/themes/kiosk/src/components/PaymentOptions/index.tsx +1 -1
  69. package/themes/kiosk/src/components/ProductForm/index.tsx +174 -125
  70. package/themes/kiosk/src/components/ProductForm/styles.tsx +1 -1
  71. package/themes/kiosk/src/components/ProductOption/index.tsx +1 -0
  72. package/themes/kiosk/src/components/ProductOption/styles.tsx +1 -0
  73. package/themes/kiosk/src/components/UpsellingProducts/index.tsx +48 -34
  74. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  75. package/themes/kiosk/src/types/index.d.ts +2 -0
  76. package/themes/original/index.tsx +184 -1
  77. package/themes/original/src/components/ActiveOrders/index.tsx +15 -132
  78. package/themes/original/src/components/ActiveOrders/styles.tsx +0 -54
  79. package/themes/original/src/components/AddressForm/index.tsx +15 -10
  80. package/themes/original/src/components/AddressList/index.tsx +56 -18
  81. package/themes/original/src/components/AppleLogin/index.tsx +117 -78
  82. package/themes/original/src/components/BusinessBasicInformation/index.tsx +96 -45
  83. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +28 -1
  84. package/themes/original/src/components/BusinessController/index.tsx +77 -29
  85. package/themes/original/src/components/BusinessController/styles.tsx +27 -0
  86. package/themes/original/src/components/BusinessFeaturedController/index.tsx +20 -1
  87. package/themes/original/src/components/BusinessFeaturedController/styles.tsx +23 -0
  88. package/themes/original/src/components/BusinessListingSearch/index.tsx +125 -7
  89. package/themes/original/src/components/BusinessListingSearch/styles.tsx +14 -1
  90. package/themes/original/src/components/BusinessMenuList/index.tsx +11 -4
  91. package/themes/original/src/components/BusinessPreorder/index.tsx +142 -122
  92. package/themes/original/src/components/BusinessProductsCategories/index.tsx +9 -7
  93. package/themes/original/src/components/BusinessProductsList/CategoryDescription/index.tsx +44 -0
  94. package/themes/original/src/components/BusinessProductsList/index.tsx +140 -37
  95. package/themes/original/src/components/BusinessProductsList/styles.tsx +29 -2
  96. package/themes/original/src/components/BusinessProductsListing/index.tsx +112 -14
  97. package/themes/original/src/components/BusinessProductsListing/styles.tsx +22 -0
  98. package/themes/original/src/components/BusinessReviews/index.tsx +4 -25
  99. package/themes/original/src/components/BusinessTypeFilter/index.tsx +1 -2
  100. package/themes/original/src/components/BusinessesListing/index.tsx +98 -72
  101. package/themes/original/src/components/Cart/index.tsx +21 -17
  102. package/themes/original/src/components/CartContent/index.tsx +2 -2
  103. package/themes/original/src/components/Checkout/index.tsx +59 -48
  104. package/themes/original/src/components/DriverTips/index.tsx +17 -12
  105. package/themes/original/src/components/Favorite/index.tsx +91 -0
  106. package/themes/original/src/components/Favorite/styles.tsx +22 -0
  107. package/themes/original/src/components/FavoriteList/index.tsx +287 -0
  108. package/themes/original/src/components/FavoriteList/styles.tsx +5 -0
  109. package/themes/original/src/components/ForgotPasswordForm/index.tsx +84 -4
  110. package/themes/original/src/components/GPSButton/index.tsx +15 -8
  111. package/themes/original/src/components/GoogleMap/index.tsx +1 -0
  112. package/themes/original/src/components/Help/index.tsx +21 -4
  113. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +115 -90
  114. package/themes/original/src/components/Home/index.tsx +1 -1
  115. package/themes/original/src/components/LastOrders/index.tsx +12 -1
  116. package/themes/original/src/components/LoginForm/Otp/index.tsx +90 -0
  117. package/themes/original/src/components/LoginForm/Otp/styles.tsx +7 -0
  118. package/themes/original/src/components/LoginForm/index.tsx +394 -155
  119. package/themes/original/src/components/LoginForm/styles.tsx +7 -4
  120. package/themes/original/src/components/LogoutButton/index.tsx +7 -1
  121. package/themes/original/src/components/MessageListing/index.tsx +10 -1
  122. package/themes/original/src/components/Messages/index.tsx +34 -25
  123. package/themes/original/src/components/Messages/styles.tsx +1 -3
  124. package/themes/original/src/components/MomentOption/index.tsx +10 -1
  125. package/themes/original/src/components/MomentOption/styles.tsx +1 -1
  126. package/themes/original/src/components/OrderDetails/index.tsx +56 -33
  127. package/themes/original/src/components/OrderDetails/styles.tsx +1 -2
  128. package/themes/original/src/components/OrderProgress/index.tsx +4 -4
  129. package/themes/original/src/components/OrderProgress/styles.tsx +1 -0
  130. package/themes/original/src/components/OrderSummary/index.tsx +3 -3
  131. package/themes/original/src/components/OrderTypeSelector/index.tsx +4 -2
  132. package/themes/original/src/components/OrdersOption/index.tsx +59 -58
  133. package/themes/original/src/components/OrdersOption/styles.tsx +0 -6
  134. package/themes/original/src/components/PaymentOptionCash/index.tsx +2 -2
  135. package/themes/original/src/components/PaymentOptionWallet/index.tsx +22 -24
  136. package/themes/original/src/components/PaymentOptionWallet/styles.tsx +1 -1
  137. package/themes/original/src/components/PaymentOptions/index.tsx +9 -21
  138. package/themes/original/src/components/PhoneInputNumber/index.tsx +1 -1
  139. package/themes/original/src/components/PreviousOrders/index.tsx +18 -145
  140. package/themes/original/src/components/ProductForm/index.tsx +76 -61
  141. package/themes/original/src/components/ProductForm/styles.tsx +2 -2
  142. package/themes/original/src/components/ProductItemAccordion/index.tsx +2 -2
  143. package/themes/original/src/components/ProductOptionSubOption/index.tsx +18 -12
  144. package/themes/original/src/components/Promotions/index.tsx +250 -0
  145. package/themes/original/src/components/Promotions/styles.tsx +60 -0
  146. package/themes/original/src/components/ReviewOrder/index.tsx +10 -9
  147. package/themes/original/src/components/ReviewProducts/index.tsx +1 -1
  148. package/themes/original/src/components/SearchBar/index.tsx +4 -1
  149. package/themes/original/src/components/Sessions/index.tsx +160 -0
  150. package/themes/original/src/components/Sessions/styles.tsx +15 -0
  151. package/themes/original/src/components/SignupForm/index.tsx +9 -4
  152. package/themes/original/src/components/SingleOrderCard/index.tsx +282 -0
  153. package/themes/original/src/components/SingleOrderCard/styles.tsx +54 -0
  154. package/themes/original/src/components/SingleProductCard/index.tsx +82 -30
  155. package/themes/original/src/components/SingleProductCard/styles.tsx +28 -1
  156. package/themes/original/src/components/StripeElementsForm/index.tsx +55 -74
  157. package/themes/original/src/components/TaxInformation/index.tsx +10 -4
  158. package/themes/original/src/components/UpsellingProducts/index.tsx +86 -74
  159. package/themes/original/src/components/UserDetails/index.tsx +4 -95
  160. package/themes/original/src/components/UserFormDetails/index.tsx +34 -24
  161. package/themes/original/src/components/UserProfile/index.tsx +66 -14
  162. package/themes/original/src/components/UserProfileForm/index.tsx +20 -18
  163. package/themes/original/src/components/UserVerification/index.tsx +178 -192
  164. package/themes/original/src/components/VerifyPhone/index.tsx +10 -7
  165. package/themes/original/src/components/VerifyPhone/styles.tsx +2 -1
  166. package/themes/original/src/components/Wallets/index.tsx +76 -9
  167. package/themes/original/src/components/Wallets/styles.tsx +21 -0
  168. package/themes/original/src/components/shared/HeaderTitle.tsx +21 -0
  169. package/themes/original/src/components/shared/OModal.tsx +4 -2
  170. package/themes/original/src/components/shared/index.tsx +2 -0
  171. package/themes/original/src/config/constants.tsx +6 -6
  172. package/themes/original/src/types/index.tsx +115 -9
  173. package/themes/original/src/utils/index.tsx +28 -2
  174. package/themes/single-business/src/components/AddressList/index.tsx +1 -1
  175. package/themes/single-business/src/components/OrderTypeSelector/index.tsx +6 -6
  176. package/themes/single-business/src/components/UserProfile/index.tsx +1 -1
  177. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
  178. package/src/components/StripeMethodForm/index.tsx +0 -174
@@ -1,4 +1,4 @@
1
- import styled from 'styled-components/native'
1
+ import styled, { css } from 'styled-components/native'
2
2
 
3
3
  export const ProductsContainer = styled.View`
4
4
  `
@@ -11,4 +11,31 @@ export const ErrorMessage = styled.View`
11
11
 
12
12
  export const WrapperNotFound = styled.View`
13
13
  height: 500px;
14
- `
14
+ `
15
+
16
+ export const RibbonBox = styled.View`
17
+ margin-left: 5px;
18
+ background-color: ${(props: any) => props.theme.colors.primary};
19
+ padding: 2px 8px;
20
+ max-width: 180px;
21
+ ${(props: any) => props.bgColor && css`
22
+ background-color: ${props.bgColor};
23
+ `}
24
+ ${(props: any) => props.isRoundRect && css`
25
+ border-radius: 7.6px;
26
+ `}
27
+ ${(props: any) => props.isCapsule && css`
28
+ border-radius: 50px;
29
+ `}
30
+ `
31
+
32
+ export const SubCategoriesContainer = styled.View`
33
+ flex-direction: row;
34
+ flex-wrap: wrap;
35
+ margin-bottom: 10px;
36
+ `
37
+
38
+ export const ContainerButton = styled.View`
39
+ `
40
+
41
+ export const HeaderWrapper = styled.View``
@@ -1,5 +1,5 @@
1
1
  import React, { useCallback, useEffect, useRef, useState } from 'react'
2
- import { View, TouchableOpacity, StyleSheet, SafeAreaView } from 'react-native'
2
+ import { View, TouchableOpacity, StyleSheet, SafeAreaView, Dimensions, Platform, KeyboardAvoidingViewBase, KeyboardAvoidingView } from 'react-native'
3
3
  import { useTheme } from 'styled-components/native';
4
4
  import {
5
5
  BusinessAndProductList,
@@ -12,22 +12,27 @@ import {
12
12
  useConfig
13
13
  } from 'ordering-components/native'
14
14
  import { OButton, OIcon, OModal, OText } from '../shared'
15
+ import Alert from '../../providers/AlertProvider'
15
16
  import { BusinessBasicInformation } from '../BusinessBasicInformation'
16
17
  import { SearchBar } from '../SearchBar'
17
18
  import { BusinessProductsCategories } from '../BusinessProductsCategories'
18
19
  import { BusinessProductsList } from '../BusinessProductsList'
19
20
  import { BusinessProductsListingParams } from '../../types'
21
+ import { _retrieveStoreData, _removeStoreData } from '../../providers/StoreUtil';
20
22
  import {
21
23
  TopHeader,
22
24
  WrapSearchBar,
23
25
  WrapContent,
24
- BusinessProductsListingContainer
26
+ BusinessProductsListingContainer,
27
+ FiltProductsContainer,
28
+ ContainerSafeAreaView,
29
+ BackgroundGray
25
30
  } from './styles'
26
31
  import { FloatingButton } from '../FloatingButton'
27
32
  import { UpsellingRedirect } from './UpsellingRedirect'
28
33
  import Animated from 'react-native-reanimated'
29
34
 
30
- const PIXELS_TO_SCROLL = 1000
35
+ const PIXELS_TO_SCROLL = 2000
31
36
 
32
37
  const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
33
38
  const {
@@ -44,13 +49,17 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
44
49
  errorQuantityProducts,
45
50
  header,
46
51
  logo,
52
+ alertState,
53
+ setAlertState,
54
+ multiRemoveProducts,
47
55
  getNextProducts,
56
+ handleUpdateProducts
48
57
  } = props
49
58
 
50
59
  const theme = useTheme();
51
60
  const [, t] = useLanguage()
52
61
  const [{ auth }] = useSession()
53
- const [orderState] = useOrder()
62
+ const [orderState, { clearCart }] = useOrder()
54
63
  const [{ parsePrice }] = useUtils()
55
64
  const [, { showToast }] = useToast()
56
65
  const [{ configs }] = useConfig()
@@ -72,6 +81,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
72
81
  borderWidth: 0,
73
82
  backgroundColor: theme.colors.clear,
74
83
  shadowColor: theme.colors.clear,
84
+ padding: 40,
75
85
  },
76
86
  searchIcon: {
77
87
  borderWidth: 0,
@@ -90,9 +100,11 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
90
100
  const [categoriesLayout, setCategoriesLayout] = useState<any>({})
91
101
  const [productListLayout, setProductListLayout] = useState<any>(null)
92
102
  const [isCategoryClicked, setCategoryClicked] = useState(false)
103
+ const [subcategoriesSelected, setSubcategoriesSelected] = useState([])
93
104
 
94
105
  const currentCart: any = Object.values(orderState.carts).find((cart: any) => cart?.business?.slug === business?.slug) ?? {}
95
-
106
+ const isOpenFiltProducts = isOpenSearchBar && !!searchValue
107
+ const filtProductsHeight = Platform.OS === 'ios' ? 0 : 35
96
108
  const onRedirect = (route: string, params?: any) => {
97
109
  navigation.navigate(route, params)
98
110
  }
@@ -162,12 +174,41 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
162
174
  navigation?.canGoBack() ? navigation.goBack() : navigation.navigate('BottomTab')
163
175
  }
164
176
 
177
+ const adjustBusiness = async (adjustBusinessId: number) => {
178
+ const _carts = orderState?.carts?.[adjustBusinessId]
179
+ const products = _carts?.products
180
+ const unavailableProducts = products.filter((product: any) => product.valid !== true)
181
+ const alreadyRemoved = await _retrieveStoreData('already-removed')
182
+ _removeStoreData('already-removed')
183
+ if (unavailableProducts.length > 0) {
184
+ multiRemoveProducts && await multiRemoveProducts(unavailableProducts, _carts)
185
+ return
186
+ }
187
+
188
+ if (alreadyRemoved === 'removed') {
189
+ setAlertState({ open: true, content: [t('NOT_AVAILABLE_PRODUCT', 'This product is not available.')] })
190
+ }
191
+ }
192
+
193
+ const removeCartByReOrder = async () => {
194
+ const adjustBusinessId = await _retrieveStoreData('adjust-cart-products')
195
+ if (currentCart && adjustBusinessId) {
196
+ _removeStoreData('adjust-cart-products')
197
+ adjustBusiness(adjustBusinessId)
198
+ }
199
+ }
200
+
201
+ useEffect(() => {
202
+ removeCartByReOrder()
203
+ }, [currentCart])
204
+
165
205
  return (
166
- <SafeAreaView
206
+ <ContainerSafeAreaView
167
207
  style={{ flex: 1 }}
208
+ isOpenFiltProducts={isOpenFiltProducts}
168
209
  >
169
210
  <Animated.View style={{ position: 'relative' }}>
170
- <TopHeader>
211
+ <TopHeader isIos={Platform.OS === 'ios'}>
171
212
  {!isOpenSearchBar && (
172
213
  <>
173
214
  <View style={{ ...styles.headerItem, flex: 1 }}>
@@ -205,6 +246,47 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
205
246
  )}
206
247
  </TopHeader>
207
248
  </Animated.View>
249
+
250
+ {business?.categories?.length > 0 && isOpenFiltProducts && (
251
+ <FiltProductsContainer
252
+ style={{
253
+ height: Dimensions.get('window').height - filtProductsHeight
254
+ }}
255
+ >
256
+ <View style={{ padding: 20, backgroundColor: theme.colors.white }}>
257
+ <BusinessProductsList
258
+ categories={[
259
+ { id: null, name: t('ALL', 'All') },
260
+ { id: 'featured', name: t('FEATURED', 'Featured') },
261
+ ...business?.categories.sort((a: any, b: any) => a.rank - b.rank)
262
+ ]}
263
+ category={categorySelected}
264
+ categoryState={categoryState}
265
+ businessId={business.id}
266
+ errors={errors}
267
+ onProductClick={onProductClick}
268
+ handleSearchRedirect={handleSearchRedirect}
269
+ featured={featuredProducts}
270
+ searchValue={searchValue}
271
+ handleClearSearch={handleChangeSearch}
272
+ errorQuantityProducts={errorQuantityProducts}
273
+ handleCancelSearch={handleCancel}
274
+ categoriesLayout={categoriesLayout}
275
+ subcategoriesSelected={subcategoriesSelected}
276
+ lazyLoadProductsRecommended={business?.lazy_load_products_recommended}
277
+ setCategoriesLayout={setCategoriesLayout}
278
+ currentCart={currentCart}
279
+ setSubcategoriesSelected={setSubcategoriesSelected}
280
+ onClickCategory={handleChangeCategory}
281
+ handleUpdateProducts={handleUpdateProducts}
282
+ isFiltMode
283
+ />
284
+ </View>
285
+ </FiltProductsContainer>
286
+ )}
287
+ {isOpenFiltProducts && (
288
+ <BackgroundGray />
289
+ )}
208
290
  <BusinessProductsListingContainer
209
291
  stickyHeaderIndices={[2]}
210
292
  style={styles.mainContainer}
@@ -239,6 +321,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
239
321
  lazyLoadProductsRecommended={business?.lazy_load_products_recommended}
240
322
  setSelectedCategoryId={setSelectedCategoryId}
241
323
  setCategoryClicked={setCategoryClicked}
324
+
242
325
  />
243
326
  )}
244
327
  </>
@@ -266,8 +349,13 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
266
349
  errorQuantityProducts={errorQuantityProducts}
267
350
  handleCancelSearch={handleCancel}
268
351
  categoriesLayout={categoriesLayout}
352
+ subcategoriesSelected={subcategoriesSelected}
353
+ lazyLoadProductsRecommended={business?.lazy_load_products_recommended}
269
354
  setCategoriesLayout={setCategoriesLayout}
270
355
  currentCart={currentCart}
356
+ setSubcategoriesSelected={setSubcategoriesSelected}
357
+ onClickCategory={handleChangeCategory}
358
+ handleUpdateProducts={handleUpdateProducts}
271
359
  />
272
360
  </WrapContent>
273
361
  </>
@@ -289,6 +377,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
289
377
  categoryState={categoryState}
290
378
  isBusinessLoading={loading}
291
379
  errorQuantityProducts={errorQuantityProducts}
380
+ handleUpdateProducts={handleUpdateProducts}
292
381
  />
293
382
  </WrapContent>
294
383
  </>
@@ -297,16 +386,18 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
297
386
  {!loading && auth && currentCart?.products?.length > 0 && categoryState.products.length !== 0 && (
298
387
  <FloatingButton
299
388
  btnText={
300
- currentCart?.subtotal >= currentCart?.minimum
301
- ? t('VIEW_ORDER', 'View Order')
302
- : `${t('MINIMUN_SUBTOTAL_ORDER', 'Minimum subtotal order:')} ${parsePrice(currentCart?.minimum)}`
389
+ openUpselling
390
+ ? t('LOADING', 'Loading')
391
+ : currentCart?.subtotal >= currentCart?.minimum
392
+ ? t('VIEW_ORDER', 'View Order')
393
+ : `${t('MINIMUN_SUBTOTAL_ORDER', 'Minimum subtotal order:')} ${parsePrice(currentCart?.minimum)}`
303
394
  }
304
- isSecondaryBtn={currentCart?.subtotal < currentCart?.minimum}
395
+ isSecondaryBtn={currentCart?.subtotal < currentCart?.minimum || openUpselling}
305
396
  btnLeftValueShow={currentCart?.subtotal >= currentCart?.minimum && currentCart?.products?.length > 0}
306
397
  btnRightValueShow={currentCart?.subtotal >= currentCart?.minimum && currentCart?.products?.length > 0}
307
- btnLeftValue={currentCart?.products?.length}
398
+ btnLeftValue={currentCart?.products.reduce((prev: number, product: any) => prev + product.quantity, 0)}
308
399
  btnRightValue={parsePrice(currentCart?.total)}
309
- disabled={currentCart?.subtotal < currentCart?.minimum}
400
+ disabled={currentCart?.subtotal < currentCart?.minimum || openUpselling}
310
401
  handleClick={() => setOpenUpselling(true)}
311
402
  />
312
403
  )}
@@ -325,7 +416,14 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
325
416
  onRedirect={onRedirect}
326
417
  />
327
418
  )}
328
- </SafeAreaView>
419
+ <Alert
420
+ open={alertState?.open || false}
421
+ title=''
422
+ content={[t('NOT_AVAILABLE_PRODUCTS', 'These products are not available.')]}
423
+ onAccept={() => setAlertState({ open: false, content: [] })}
424
+ onClose={() => setAlertState({ open: false, content: [] })}
425
+ />
426
+ </ContainerSafeAreaView>
329
427
  )
330
428
  }
331
429
 
@@ -1,5 +1,8 @@
1
1
  import styled, { css } from 'styled-components/native'
2
2
 
3
+ export const ContainerSafeAreaView = styled.SafeAreaView`
4
+ `
5
+
3
6
  export const WrapHeader = styled.View`
4
7
  position: relative;
5
8
  `
@@ -11,6 +14,7 @@ export const TopHeader = styled.View`
11
14
  z-index: 1;
12
15
  height: 60px;
13
16
  min-height: 60px;
17
+ margin-top: ${(props : any) => props.isIos ? '0' : '40px'};
14
18
  `
15
19
  export const AddressInput = styled.TouchableOpacity`
16
20
  flex: 1;
@@ -33,3 +37,21 @@ export const BusinessProductsListingContainer = styled.ScrollView`
33
37
  margin-bottom: 50px;
34
38
  `}
35
39
  `
40
+
41
+ export const FiltProductsContainer = styled.ScrollView`
42
+ position: absolute;
43
+ width: 100%;
44
+ z-index: 2000;
45
+ top: ${(props : any) => props.isIos ? '40px': '80px'};
46
+ margin-top: 20px;
47
+ `
48
+
49
+ export const BackgroundGray = styled.View`
50
+ flex: 1;
51
+ height: 100%;
52
+ background-color: rgba(0,0,0,0.5);
53
+ position: absolute;
54
+ margin-top: 100px;
55
+ z-index: 100;
56
+ width: 100%;
57
+ `
@@ -90,33 +90,12 @@ const BusinessReviewsUI = (props: BusinessReviewsParams) => {
90
90
  </View>
91
91
  );
92
92
 
93
- const ReviewItem = ({ comment, created_at, total, customer }: any) => (
93
+ const ReviewItem = ({ comment, created_at, total }: any) => (
94
94
  <View style={{ marginBottom: 30 }}>
95
- <View
96
- style={{ flexDirection: 'row', marginBottom: 19, alignItems: 'center' }}>
97
- <OIcon
98
- url={theme.images.dummies.customerPhoto}
99
- width={38}
100
- height={38}
101
- style={{
102
- borderRadius: 7.6,
103
- borderWidth: 1,
104
- borderColor: theme.colors.border,
105
- marginEnd: 9,
106
- }}
107
- />
108
- <View>
109
- <OText size={12} color={theme.colors.textNormal} weight={'500'}>
110
- {customer?.name || 'Jane Cooper'}
111
- </OText>
112
- <OText size={10} color={theme.colors.textSecondary}>
113
- {moment(created_at).format('MMMM d, yyyy • hh:mm')}
114
- </OText>
115
- </View>
116
- </View>
117
- <OText size={10} color={theme.colors.textNormal}>
118
- {comment}
95
+ <OText size={12} color={theme.colors.textSecondary}>
96
+ {moment(created_at).format('MMMM d, yyyy hh:mm')}
119
97
  </OText>
98
+ <OText size={12} color={theme.colors.textNormal}>{comment}</OText>
120
99
  </View>
121
100
  );
122
101
 
@@ -45,7 +45,6 @@ export const BusinessTypeFilterUI = (props: BusinessTypeFilterParams) => {
45
45
  const renderTypes = ({ item }: any) => {
46
46
  return (
47
47
  <TouchableOpacity
48
- key={item.id}
49
48
  onPress={() => handleChangeBusinessType(item.id)}
50
49
  style={{
51
50
  height: 34,
@@ -103,7 +102,7 @@ export const BusinessTypeFilterUI = (props: BusinessTypeFilterParams) => {
103
102
  showsHorizontalScrollIndicator={false}
104
103
  data={typesState?.types}
105
104
  renderItem={renderTypes}
106
- keyExtractor={(type) => type.name}
105
+ keyExtractor={(type, index) => `${type.name}_${index}`}
107
106
  />
108
107
  <TouchableOpacity
109
108
  style={{ marginLeft: 15 }}
@@ -1,6 +1,7 @@
1
1
  import React, { useCallback, useEffect, useRef, useState } from 'react';
2
2
  import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
3
3
  import Geolocation from '@react-native-community/geolocation'
4
+ import { getTrackingStatus, requestTrackingPermission } from 'react-native-tracking-transparency'
4
5
  import {
5
6
  View,
6
7
  StyleSheet,
@@ -47,7 +48,7 @@ import { getTypesText, convertToRadian } from '../../utils';
47
48
  import { OrderProgress } from '../OrderProgress';
48
49
  import { useFocusEffect, useIsFocused } from '@react-navigation/native';
49
50
 
50
- const PIXELS_TO_SCROLL = 1000;
51
+ const PIXELS_TO_SCROLL = 2000;
51
52
 
52
53
  const BusinessesListingUI = (props: BusinessesListingParams) => {
53
54
  const {
@@ -59,9 +60,10 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
59
60
  handleBusinessClick,
60
61
  paginationProps,
61
62
  handleChangeSearch,
62
- businessId
63
+ businessId,
64
+ isGuestUser,
65
+ handleUpdateBusinessList
63
66
  } = props;
64
-
65
67
  const theme = useTheme();
66
68
  const isFocused = useIsFocused();
67
69
  const appState = useRef(AppState.currentState)
@@ -117,11 +119,13 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
117
119
  const [featuredBusiness, setFeaturedBusinesses] = useState(Array);
118
120
  const [isFarAway, setIsFarAway] = useState(false)
119
121
  const [businessTypes, setBusinessTypes] = useState(null)
120
-
122
+ const [orderTypeValue, setOrderTypeValue] = useState(orderState?.options.value)
121
123
  const isPreorderEnabled = (configs?.preorder_status_enabled?.value === '1' || configs?.preorder_status_enabled?.value === 'true') &&
122
124
  Number(configs?.max_days_preorder?.value) > 0
123
-
125
+ const isPreOrderSetting = configs?.preorder_status_enabled?.value === '1'
124
126
  const timerId = useRef<any>(false)
127
+ const [favoriteIds, setFavoriteIds] = useState<any>([])
128
+
125
129
  // const panResponder = useRef(
126
130
  // PanResponder.create({
127
131
  // onMoveShouldSetPanResponder: (e, gestureState) => {
@@ -166,8 +170,15 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
166
170
  return R * c
167
171
  }
168
172
 
173
+ const resetInactivityTimeout = () => {
174
+ clearTimeout(timerId.current)
175
+ timerId.current = setInterval(() => {
176
+ getBusinesses(true)
177
+ }, 120000)
178
+ }
179
+
169
180
  useEffect(() => {
170
- if (businessesList.businesses.length > 0) {
181
+ if (!businessesList?.loading) {
171
182
  const fb = businessesList.businesses.filter((b) => b.featured === true && b?.open);
172
183
  const ary = [];
173
184
  while (fb.length > 0) {
@@ -175,16 +186,6 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
175
186
  }
176
187
  setFeaturedBusinesses(ary);
177
188
  }
178
- }, [businessesList.businesses]);
179
-
180
- const resetInactivityTimeout = () => {
181
- clearTimeout(timerId.current)
182
- timerId.current = setInterval(() => {
183
- getBusinesses(true)
184
- }, 300000)
185
- }
186
-
187
- useEffect(() => {
188
189
  resetInactivityTimeout()
189
190
  }, [businessesList.loading])
190
191
 
@@ -194,45 +195,53 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
194
195
  }
195
196
  }
196
197
 
198
+ const checkUserLocation = async () => {
199
+ let trackingStatus = await getTrackingStatus()
200
+ if (trackingStatus === 'not-determined') {
201
+ trackingStatus = await requestTrackingPermission()
202
+ }
203
+ if (trackingStatus === 'authorized' || trackingStatus === 'unavailable') {
204
+ Geolocation.getCurrentPosition((pos) => {
205
+ const crd = pos.coords
206
+ const distance = getDistance(crd.latitude, crd.longitude, orderState?.options?.address?.location?.lat, orderState?.options?.address?.location?.lng)
207
+ if (distance > 20) setIsFarAway(true)
208
+ else setIsFarAway(false)
209
+ }, (err) => {
210
+ console.log(`ERROR(${err.code}): ${err.message}`)
211
+ }, {
212
+ enableHighAccuracy: true, timeout: 15000, maximumAge: 10000
213
+ })
214
+ }
215
+ }
216
+
197
217
  useEffect(() => {
198
- Geolocation.getCurrentPosition((pos) => {
199
- const crd = pos.coords
200
- const distance = getDistance(crd.latitude, crd.longitude, orderState?.options?.address?.location?.lat, orderState?.options?.address?.location?.lng)
201
- if (distance > 20) setIsFarAway(true)
202
- else setIsFarAway(false)
203
- }, (err) => {
204
- console.log(`ERROR(${err.code}): ${err.message}`)
205
- }, {
206
- enableHighAccuracy: true, timeout: 15000, maximumAge: 10000
207
- })
218
+ checkUserLocation()
208
219
  }, [orderState?.options?.address?.location])
209
220
 
210
221
  useEffect(() => {
211
- const onFocusApp = (nextAppState: any) => {
212
- if (
213
- appState.current.match(/inactive|background/) &&
214
- nextAppState === "active"
215
- ) {
216
- getBusinesses(true);
217
- }
218
- appState.current = nextAppState;
219
- setAppStateVisible(appState.current);
222
+ if(!orderState?.loading){
223
+ setOrderTypeValue(orderState?.options?.type)
220
224
  }
221
-
222
- AppState.addEventListener("change", onFocusApp);
223
- return () => {
224
- AppState.removeEventListener('change', onFocusApp);
225
- };
226
- }, [])
225
+ }, [orderState?.options?.type])
227
226
 
228
227
  useFocusEffect(
229
228
  useCallback(() => {
230
- getBusinesses(true)
231
229
  resetInactivityTimeout()
232
230
  return () => clearTimeout(timerId.current)
233
231
  }, [navigation])
234
232
  )
235
233
 
234
+ useEffect(() => {
235
+ if (!businessesList?.businesses?.length) return
236
+ const ids = [...favoriteIds]
237
+ businessesList.businesses.forEach((business: any) => {
238
+ if (business?.favorite) {
239
+ ids.push(business?.id)
240
+ }
241
+ })
242
+ setFavoriteIds([...new Set(ids)])
243
+ }, [businessesList?.businesses?.length])
244
+
236
245
  return (
237
246
  <ScrollView style={styles.container} onScroll={(e) => handleScroll(e)} showsVerticalScrollIndicator={false}
238
247
  refreshControl={
@@ -243,7 +252,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
243
252
  }
244
253
  >
245
254
  <HeaderWrapper
246
- source={theme.images.backgrounds.business_list_header}
255
+ source={theme.images.general.homeHero}
247
256
  style={{ paddingTop: top + 20 }}>
248
257
  {!auth && (
249
258
  <TouchableOpacity onPress={() => navigation?.canGoBack() && navigation.goBack()} style={{ position: 'absolute', marginStart: 40, paddingVertical: 20 }}>
@@ -259,6 +268,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
259
268
  : navigation.navigate('AddressForm', {
260
269
  address: orderState.options?.address,
261
270
  isFromBusinesses: true,
271
+ isGuestUser: isGuestUser
262
272
  })
263
273
  }>
264
274
  <OIcon
@@ -280,33 +290,35 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
280
290
  )}
281
291
  <OrderControlContainer>
282
292
  <View style={styles.wrapperOrderOptions}>
283
- <WrapMomentOption onPress={() => navigation.navigate('OrderTypes', { configTypes: configTypes })}>
284
- <OText size={12} numberOfLines={1} ellipsizeMode={'tail'} color={theme.colors.textSecondary}>{t(getTypesText(orderState?.options?.type || 1), 'Delivery')}</OText>
293
+ <WrapMomentOption onPress={() => navigation.navigate('OrderTypes', { configTypes: configTypes, setOrderTypeValue })}>
294
+ <OText size={12} numberOfLines={1} ellipsizeMode={'tail'} color={theme.colors.textSecondary}>{t(getTypesText(orderTypeValue || orderState?.options?.type || 1), 'Delivery')}</OText>
285
295
  <OIcon
286
296
  src={theme.images.general.arrow_down}
287
297
  width={10}
288
298
  style={{ marginStart: 8 }}
289
299
  />
290
300
  </WrapMomentOption>
291
- <WrapMomentOption
292
- onPress={() => handleMomentClick()}>
293
- <OText
294
- size={12}
295
- numberOfLines={1}
296
- ellipsizeMode="tail"
297
- color={theme.colors.textSecondary}>
298
- {orderState.options?.momentß
299
- ? parseDate(orderState.options?.moment, { outputFormat: configs?.dates_moment_format?.value })
300
- : t('ASAP_ABBREVIATION', 'ASAP')}
301
- </OText>
302
- {isPreorderEnabled && (
303
- <OIcon
304
- src={theme.images.general.arrow_down}
305
- width={10}
306
- style={{ marginStart: 8 }}
307
- />
308
- )}
309
- </WrapMomentOption>
301
+ {isPreOrderSetting && (
302
+ <WrapMomentOption
303
+ onPress={() => handleMomentClick()}>
304
+ <OText
305
+ size={12}
306
+ numberOfLines={1}
307
+ ellipsizeMode="tail"
308
+ color={theme.colors.textSecondary}>
309
+ {orderState.options?.moment
310
+ ? parseDate(orderState.options?.moment, { outputFormat: configs?.dates_moment_format?.value })
311
+ : t('ASAP_ABBREVIATION', 'ASAP')}
312
+ </OText>
313
+ {isPreorderEnabled && (
314
+ <OIcon
315
+ src={theme.images.general.arrow_down}
316
+ width={10}
317
+ style={{ marginStart: 8 }}
318
+ />
319
+ )}
320
+ </WrapMomentOption>
321
+ )}
310
322
 
311
323
  {!businessId && (
312
324
  <SearchBar
@@ -318,9 +330,9 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
318
330
  onCancel={() => handleChangeSearch('')}
319
331
  placeholder={t('SEARCH', 'Search')}
320
332
  height={26}
321
- isDisabled={configs?.advanced_business_search_enabled?.value === '1' || !businessTypes}
333
+ isDisabled={!businessTypes}
322
334
  inputStyle={{ ...styles.searchInput, ...Platform.OS === 'ios' ? {} : { paddingBottom: 4 } }}
323
- onPress={() => { configs?.advanced_business_search_enabled?.value === '1' && navigation.navigate('BusinessSearch', { businessTypes }) }}
335
+ onSubmitEditing={() => { configs?.advanced_business_search_enabled?.value === '1' && navigation.navigate('BusinessSearch', { businessTypes, defaultTerm: searchValue }) }}
324
336
  />
325
337
  )}
326
338
 
@@ -338,7 +350,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
338
350
  {
339
351
  !businessId && !props.franchiseId && featuredBusiness && featuredBusiness.length > 0 && (
340
352
  <FeaturedWrapper>
341
- <OText size={16} style={{ marginLeft: 40 }} weight={Platform.OS === 'ios' ? '600' : 'bold'}>{t('FEATURED_BUSINESS', 'Featured business')}</OText>
353
+ <OText size={16} style={{ marginLeft: 40 }} weight={Platform.OS === 'ios' ? '600' : 'bold'}>{t('BUSINESS_FEATURE', 'Featured business')}</OText>
342
354
  <ScrollView
343
355
  showsHorizontalScrollIndicator={false}
344
356
  nestedScrollEnabled
@@ -346,7 +358,6 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
346
358
  {featuredBusiness.map((bAry: any, idx) => (
347
359
  <View key={'f-listing_' + idx}>
348
360
  <BusinessFeaturedController
349
- key={bAry[0].id}
350
361
  business={bAry[0]}
351
362
  isBusinessOpen={bAry[0]?.open}
352
363
  handleCustomClick={handleBusinessClick}
@@ -354,7 +365,6 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
354
365
  />
355
366
  {bAry.length > 1 && (
356
367
  <BusinessFeaturedController
357
- key={bAry[1].id}
358
368
  business={bAry[1]}
359
369
  isBusinessOpen={bAry[1]?.open}
360
370
  handleCustomClick={handleBusinessClick}
@@ -370,7 +380,12 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
370
380
  <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100 }} />
371
381
  {
372
382
  !businessId && !props.franchiseId && (
373
- <HighestRatedBusinesses onBusinessClick={handleBusinessClick} navigation={navigation} />
383
+ <HighestRatedBusinesses
384
+ onBusinessClick={handleBusinessClick}
385
+ navigation={navigation}
386
+ favoriteIds={favoriteIds}
387
+ setFavoriteIds={setFavoriteIds}
388
+ />
374
389
  )
375
390
  }
376
391
  <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100 }} />
@@ -393,14 +408,25 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
393
408
  />
394
409
  )}
395
410
  {businessesList.businesses?.map(
396
- (business: any) => (
411
+ (business: any, i : number) => (
397
412
  <BusinessController
398
- key={business.id}
413
+ key={`${business.id}_` + i}
399
414
  business={business}
400
415
  isBusinessOpen={business.open}
401
416
  handleCustomClick={handleBusinessClick}
402
417
  orderType={orderState?.options?.type}
403
418
  navigation={navigation}
419
+ businessHeader={business?.header}
420
+ businessFeatured={business?.featured}
421
+ businessLogo={business?.logo}
422
+ businessReviews={business?.reviews}
423
+ businessDeliveryPrice={business?.delivery_price}
424
+ businessDeliveryTime={business?.delivery_time}
425
+ businessPickupTime={business?.pickup_time}
426
+ businessDistance={business?.distance}
427
+ handleUpdateBusinessList={handleUpdateBusinessList}
428
+ favoriteIds={favoriteIds}
429
+ setFavoriteIds={setFavoriteIds}
404
430
  />
405
431
  )
406
432
  )}