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