ordering-ui-react-native 0.15.71 → 0.15.74
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 +1 -1
- package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +5 -5
- package/themes/original/src/components/AddressList/index.tsx +29 -17
- package/themes/original/src/components/BusinessProductsList/index.tsx +34 -32
- package/themes/original/src/components/BusinessProductsListing/index.tsx +55 -9
- package/themes/original/src/components/BusinessProductsListing/styles.tsx +22 -0
- package/themes/original/src/components/BusinessTypeFilter/index.tsx +1 -2
- package/themes/original/src/components/BusinessesListing/index.tsx +13 -9
- package/themes/original/src/components/Cart/index.tsx +17 -11
- package/themes/original/src/components/Checkout/index.tsx +1 -1
- package/themes/original/src/components/MessageListing/index.tsx +10 -1
- package/themes/original/src/components/OrderTypeSelector/index.tsx +3 -1
- package/themes/original/src/components/OrdersOption/index.tsx +11 -2
- package/themes/original/src/components/PaymentOptionWallet/index.tsx +3 -2
- package/themes/original/src/components/PaymentOptionWallet/styles.tsx +1 -1
- package/themes/original/src/components/ProductForm/index.tsx +26 -26
- package/themes/original/src/components/ProductOptionSubOption/index.tsx +5 -3
- package/themes/original/src/components/SingleProductCard/index.tsx +9 -4
- package/themes/original/src/components/UpsellingProducts/index.tsx +86 -70
- package/themes/original/src/components/UserFormDetails/index.tsx +21 -19
- package/themes/original/src/components/UserProfileForm/index.tsx +20 -18
- package/themes/original/src/components/Wallets/index.tsx +23 -10
- package/themes/original/src/types/index.tsx +8 -3
package/package.json
CHANGED
|
@@ -385,7 +385,7 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
385
385
|
order?.offers?.length > 0 && order?.offers?.filter((offer: any) => offer?.target === 1)?.map((offer: any) => (
|
|
386
386
|
<Table key={offer.id}>
|
|
387
387
|
<OSRow>
|
|
388
|
-
<OText
|
|
388
|
+
<OText mBottom={4}>
|
|
389
389
|
{offer.name}
|
|
390
390
|
{offer.rate_type === 1 && (
|
|
391
391
|
<OText>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
|
|
@@ -431,7 +431,7 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
431
431
|
order?.taxes?.length > 0 && order?.taxes?.filter((tax: any) => tax?.type === 2 && tax?.rate !== 0).map((tax: any) => (
|
|
432
432
|
<Table key={tax.id}>
|
|
433
433
|
<OSRow>
|
|
434
|
-
<OText
|
|
434
|
+
<OText mBottom={4}>
|
|
435
435
|
{tax.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
|
|
436
436
|
{`(${verifyDecimals(tax?.rate, parseNumber)}%)`}{' '}
|
|
437
437
|
</OText>
|
|
@@ -444,7 +444,7 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
444
444
|
order?.fees?.length > 0 && order?.fees?.filter((fee: any) => !(fee.fixed === 0 && fee.percentage === 0))?.map((fee: any) => (
|
|
445
445
|
<Table key={fee.id}>
|
|
446
446
|
<OSRow>
|
|
447
|
-
<OText
|
|
447
|
+
<OText mBottom={4}>
|
|
448
448
|
{fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
|
|
449
449
|
({fee?.fixed > 0 && `${parsePrice(fee?.fixed)} + `}{fee.percentage}%){' '}
|
|
450
450
|
</OText>
|
|
@@ -457,7 +457,7 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
457
457
|
order?.offers?.length > 0 && order?.offers?.filter((offer: any) => offer?.target === 3)?.map((offer: any) => (
|
|
458
458
|
<Table key={offer.id}>
|
|
459
459
|
<OSRow>
|
|
460
|
-
<OText
|
|
460
|
+
<OText mBottom={4}>
|
|
461
461
|
{offer.name}
|
|
462
462
|
{offer.rate_type === 1 && (
|
|
463
463
|
<OText>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
|
|
@@ -485,7 +485,7 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
485
485
|
order?.offers?.length > 0 && order?.offers?.filter((offer: any) => offer?.target === 2)?.map((offer: any) => (
|
|
486
486
|
<Table key={offer.id}>
|
|
487
487
|
<OSRow>
|
|
488
|
-
<OText
|
|
488
|
+
<OText mBottom={4}>
|
|
489
489
|
{offer.name}
|
|
490
490
|
{offer.rate_type === 1 && (
|
|
491
491
|
<OText>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useEffect } from 'react'
|
|
2
2
|
import { AddressList as AddressListController, useLanguage, useOrder, useSession } from 'ordering-components/native'
|
|
3
3
|
import { AddressListContainer, AddressItem } from './styles'
|
|
4
|
-
import { Platform, StyleSheet, View } from 'react-native'
|
|
4
|
+
import { Platform, RefreshControl, StyleSheet, View } from 'react-native'
|
|
5
5
|
import { OButton, OText, OAlert, OModal, OIcon } from '../shared'
|
|
6
6
|
import { Container } from '../../layouts/Container'
|
|
7
7
|
import { AddressListParams } from '../../types'
|
|
@@ -27,7 +27,8 @@ const AddressListUI = (props: AddressListParams) => {
|
|
|
27
27
|
actionStatus,
|
|
28
28
|
isFromBusinesses,
|
|
29
29
|
isFromProductsList,
|
|
30
|
-
afterSignup
|
|
30
|
+
afterSignup,
|
|
31
|
+
loadAddresses
|
|
31
32
|
} = props
|
|
32
33
|
|
|
33
34
|
const theme = useTheme();
|
|
@@ -35,6 +36,7 @@ const AddressListUI = (props: AddressListParams) => {
|
|
|
35
36
|
const [orderState] = useOrder()
|
|
36
37
|
const [, t] = useLanguage()
|
|
37
38
|
const [{ auth }] = useSession()
|
|
39
|
+
const [refreshing] = useState(false);
|
|
38
40
|
|
|
39
41
|
const [isProfile, setIsProfile] = useState(isFromProfile || route?.params?.isFromProfile);
|
|
40
42
|
|
|
@@ -121,6 +123,12 @@ const AddressListUI = (props: AddressListParams) => {
|
|
|
121
123
|
})
|
|
122
124
|
}
|
|
123
125
|
|
|
126
|
+
const handleOnRefresh = () => {
|
|
127
|
+
if (!addressList.loading) {
|
|
128
|
+
loadAddresses();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
124
132
|
const goToBack = () => navigation?.canGoBack() && navigation.goBack()
|
|
125
133
|
const onNavigationRedirect = (route: string, params?: any) => navigation.navigate(route, params)
|
|
126
134
|
|
|
@@ -135,22 +143,26 @@ const AddressListUI = (props: AddressListParams) => {
|
|
|
135
143
|
}, [])
|
|
136
144
|
|
|
137
145
|
return (
|
|
138
|
-
<Container
|
|
146
|
+
<Container
|
|
147
|
+
noPadding
|
|
148
|
+
refreshControl={
|
|
149
|
+
<RefreshControl
|
|
150
|
+
refreshing={refreshing}
|
|
151
|
+
onRefresh={() => handleOnRefresh()}
|
|
152
|
+
/>
|
|
153
|
+
}
|
|
154
|
+
>
|
|
155
|
+
{isProfile && (
|
|
156
|
+
<NavBar
|
|
157
|
+
title={t('SAVED_PLACES', 'My saved places')}
|
|
158
|
+
titleAlign={'center'}
|
|
159
|
+
onActionLeft={goToBack}
|
|
160
|
+
showCall={false}
|
|
161
|
+
style={{ paddingHorizontal: 40, paddingVertical: Platform.OS === 'ios' ? 0 : 20 }}
|
|
162
|
+
/>
|
|
163
|
+
)}
|
|
139
164
|
{(!addressList.loading || (isFromProductsList || isFromBusinesses || isFromProfile || isProfile)) && (
|
|
140
165
|
<AddressListContainer>
|
|
141
|
-
{isProfile && (
|
|
142
|
-
<NavBar
|
|
143
|
-
title={t('SAVED_PLACES', 'My saved places')}
|
|
144
|
-
titleAlign={'center'}
|
|
145
|
-
onActionLeft={() => goToBack()}
|
|
146
|
-
showCall={false}
|
|
147
|
-
btnStyle={{ paddingLeft: 0 }}
|
|
148
|
-
paddingTop={0}
|
|
149
|
-
isVertical
|
|
150
|
-
titleWrapStyle={{ paddingHorizontal: 0 }}
|
|
151
|
-
titleStyle={{ marginLeft: 0, marginRight: 0 }}
|
|
152
|
-
/>
|
|
153
|
-
)}
|
|
154
166
|
{
|
|
155
167
|
route &&
|
|
156
168
|
(
|
|
@@ -172,7 +184,7 @@ const AddressListUI = (props: AddressListParams) => {
|
|
|
172
184
|
titleStyle={{ marginLeft: 0, marginRight: 0 }}
|
|
173
185
|
/>
|
|
174
186
|
)}
|
|
175
|
-
{addressList.loading && (
|
|
187
|
+
{addressList.loading && addressList?.addresses?.length === 0 && (
|
|
176
188
|
<>
|
|
177
189
|
{[...Array(5)].map((item, i) => (
|
|
178
190
|
<Placeholder key={i} style={{ paddingVertical: 20 }} Animation={Fade}>
|
|
@@ -32,7 +32,8 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
|
|
|
32
32
|
setSubcategoriesSelected,
|
|
33
33
|
subcategoriesSelected,
|
|
34
34
|
onClickCategory,
|
|
35
|
-
lazyLoadProductsRecommended
|
|
35
|
+
lazyLoadProductsRecommended,
|
|
36
|
+
isFiltMode
|
|
36
37
|
} = props;
|
|
37
38
|
|
|
38
39
|
const [, t] = useLanguage();
|
|
@@ -48,24 +49,24 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
|
|
|
48
49
|
setCategoriesLayout(_categoriesLayout)
|
|
49
50
|
}
|
|
50
51
|
|
|
51
|
-
const onClickSubcategory = (subCategory
|
|
52
|
+
const onClickSubcategory = (subCategory: any, parentCategory: any) => {
|
|
52
53
|
if (parentCategory && lazyLoadProductsRecommended) {
|
|
53
54
|
onClickCategory(parentCategory)
|
|
54
55
|
}
|
|
55
56
|
if (!subCategory) {
|
|
56
|
-
setSubcategoriesSelected?.(subcategoriesSelected.filter((_subcategory
|
|
57
|
+
setSubcategoriesSelected?.(subcategoriesSelected.filter((_subcategory: any) => _subcategory?.parent_category_id !== parentCategory?.id))
|
|
57
58
|
return
|
|
58
59
|
}
|
|
59
|
-
const categoryFounded = subcategoriesSelected.find((_subcategory
|
|
60
|
+
const categoryFounded = subcategoriesSelected.find((_subcategory: any) => subCategory?.id === _subcategory?.id)
|
|
60
61
|
if (categoryFounded) {
|
|
61
|
-
setSubcategoriesSelected?.(subcategoriesSelected.filter((_subcategory
|
|
62
|
+
setSubcategoriesSelected?.(subcategoriesSelected.filter((_subcategory: any) => subCategory?.id !== _subcategory?.id))
|
|
62
63
|
} else {
|
|
63
64
|
setSubcategoriesSelected?.([...subcategoriesSelected, subCategory])
|
|
64
65
|
}
|
|
65
66
|
}
|
|
66
67
|
|
|
67
|
-
const SubcategoriesComponent = ({ category }
|
|
68
|
-
const allsubcategorySelected = !subcategoriesSelected?.some((subcategory
|
|
68
|
+
const SubcategoriesComponent = ({ category }: any) => {
|
|
69
|
+
const allsubcategorySelected = !subcategoriesSelected?.some((subcategory: any) => category?.id === subcategory?.parent_category_id)
|
|
69
70
|
|
|
70
71
|
return (
|
|
71
72
|
<SubCategoriesContainer>
|
|
@@ -80,8 +81,8 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
|
|
|
80
81
|
textStyle={{ color: allsubcategorySelected ? theme.colors.white : theme.colors.textNormal, fontSize: 12 }}
|
|
81
82
|
/>
|
|
82
83
|
</ContainerButton>
|
|
83
|
-
{category?.subcategories?.map((subcategory
|
|
84
|
-
const isSubcategorySelected = subcategoriesSelected?.find((_subcategory
|
|
84
|
+
{category?.subcategories?.map((subcategory: any) => {
|
|
85
|
+
const isSubcategorySelected = subcategoriesSelected?.find((_subcategory: any) => _subcategory?.id === subcategory?.id)
|
|
85
86
|
return (
|
|
86
87
|
<ContainerButton
|
|
87
88
|
key={subcategory?.id}
|
|
@@ -112,21 +113,21 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
|
|
|
112
113
|
</HeaderWrapper>
|
|
113
114
|
{category.id &&
|
|
114
115
|
categoryState.products
|
|
115
|
-
?.filter((product
|
|
116
|
-
!subcategoriesSelected.find((subcategory
|
|
117
|
-
subcategoriesSelected?.some((subcategory
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
116
|
+
?.filter((product: any) =>
|
|
117
|
+
!subcategoriesSelected.find((subcategory: any) => subcategory?.parent_category_id === category?.id) ||
|
|
118
|
+
subcategoriesSelected?.some((subcategory: any) => subcategory.id === product?.category_id))
|
|
119
|
+
?.sort((a: any, b: any) => a.rank - b.rank)
|
|
120
|
+
?.map((product: any, i : number) => (
|
|
121
|
+
<SingleProductCard
|
|
122
|
+
key={'prod_' + product.id + `_${i}`}
|
|
123
|
+
isSoldOut={product.inventoried && !product.quantity}
|
|
124
|
+
product={product}
|
|
125
|
+
businessId={businessId}
|
|
126
|
+
onProductClick={() => onProductClick(product)}
|
|
127
|
+
productAddedToCartLength={currentCart?.products?.reduce((productsLength: number, Cproduct: any) => { return productsLength + (Cproduct?.id === product?.id ? Cproduct?.quantity : 0) }, 0)}
|
|
128
|
+
/>
|
|
129
|
+
))
|
|
130
|
+
}
|
|
130
131
|
{!category.id &&
|
|
131
132
|
featured &&
|
|
132
133
|
categoryState?.products?.find((product: any) => product.featured) && (
|
|
@@ -141,7 +142,7 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
|
|
|
141
142
|
(product: any, i: any) =>
|
|
142
143
|
product.featured && (
|
|
143
144
|
<SingleProductCard
|
|
144
|
-
key={'feat_' + product.id}
|
|
145
|
+
key={'feat_' + product.id + `_${i}`}
|
|
145
146
|
isSoldOut={product.inventoried && !product.quantity}
|
|
146
147
|
product={product}
|
|
147
148
|
businessId={businessId}
|
|
@@ -156,16 +157,16 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
|
|
|
156
157
|
|
|
157
158
|
{!category?.id && categories.filter(category => category?.id !== null).map((category, i, _categories) => {
|
|
158
159
|
const _products = !isUseParentCategory
|
|
159
|
-
? categoryState?.products?.filter((product
|
|
160
|
-
: categoryState?.products?.filter((product
|
|
160
|
+
? categoryState?.products?.filter((product: any) => product?.category_id === category?.id) ?? []
|
|
161
|
+
: categoryState?.products?.filter((product: any) => category?.children?.some((cat: any) => cat.category_id === product?.category_id)) ?? []
|
|
161
162
|
const products = subcategoriesSelected?.length > 0
|
|
162
|
-
? _products?.filter((product
|
|
163
|
-
!subcategoriesSelected.find((subcategory
|
|
164
|
-
subcategoriesSelected?.some((subcategory
|
|
163
|
+
? _products?.filter((product: any) =>
|
|
164
|
+
!subcategoriesSelected.find((subcategory: any) => subcategory?.parent_category_id === category?.id) ||
|
|
165
|
+
subcategoriesSelected?.some((subcategory: any) => subcategory.id === product?.category_id))
|
|
165
166
|
: _products
|
|
166
167
|
|
|
167
168
|
const shortCategoryDescription = category?.description?.length > 80 ? `${category?.description?.substring(0, 80)}...` : category?.description
|
|
168
|
-
|
|
169
|
+
|
|
169
170
|
return (
|
|
170
171
|
<React.Fragment key={'cat_' + category.id}>
|
|
171
172
|
{products.length > 0 && (
|
|
@@ -226,7 +227,7 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
|
|
|
226
227
|
</OText>
|
|
227
228
|
</View>
|
|
228
229
|
)}
|
|
229
|
-
{category?.subcategories?.length > 0 && (
|
|
230
|
+
{category?.subcategories?.length > 0 && !isFiltMode && (
|
|
230
231
|
<SubcategoriesComponent category={category} />
|
|
231
232
|
)}
|
|
232
233
|
<>
|
|
@@ -272,6 +273,7 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
|
|
|
272
273
|
!isBusinessLoading &&
|
|
273
274
|
categoryState.products.length === 0 &&
|
|
274
275
|
!errors &&
|
|
276
|
+
!isFiltMode &&
|
|
275
277
|
!(
|
|
276
278
|
(searchValue && errorQuantityProducts) ||
|
|
277
279
|
(!searchValue && !errorQuantityProducts)
|
|
@@ -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,
|
|
@@ -22,13 +22,16 @@ import {
|
|
|
22
22
|
TopHeader,
|
|
23
23
|
WrapSearchBar,
|
|
24
24
|
WrapContent,
|
|
25
|
-
BusinessProductsListingContainer
|
|
25
|
+
BusinessProductsListingContainer,
|
|
26
|
+
FiltProductsContainer,
|
|
27
|
+
ContainerSafeAreaView,
|
|
28
|
+
BackgroundGray
|
|
26
29
|
} from './styles'
|
|
27
30
|
import { FloatingButton } from '../FloatingButton'
|
|
28
31
|
import { UpsellingRedirect } from './UpsellingRedirect'
|
|
29
32
|
import Animated from 'react-native-reanimated'
|
|
30
33
|
|
|
31
|
-
const PIXELS_TO_SCROLL =
|
|
34
|
+
const PIXELS_TO_SCROLL = 2000
|
|
32
35
|
|
|
33
36
|
const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
34
37
|
const {
|
|
@@ -95,7 +98,8 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
95
98
|
const [subcategoriesSelected, setSubcategoriesSelected] = useState([])
|
|
96
99
|
|
|
97
100
|
const currentCart: any = Object.values(orderState.carts).find((cart: any) => cart?.business?.slug === business?.slug) ?? {}
|
|
98
|
-
|
|
101
|
+
const isOpenFiltProducts = isOpenSearchBar && !!searchValue
|
|
102
|
+
const filtProductsHeight = Platform.OS === 'ios' ? 0 : 35
|
|
99
103
|
const onRedirect = (route: string, params?: any) => {
|
|
100
104
|
navigation.navigate(route, params)
|
|
101
105
|
}
|
|
@@ -179,11 +183,12 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
179
183
|
}, [])
|
|
180
184
|
|
|
181
185
|
return (
|
|
182
|
-
<
|
|
186
|
+
<ContainerSafeAreaView
|
|
183
187
|
style={{ flex: 1 }}
|
|
188
|
+
isOpenFiltProducts={isOpenFiltProducts}
|
|
184
189
|
>
|
|
185
190
|
<Animated.View style={{ position: 'relative' }}>
|
|
186
|
-
<TopHeader>
|
|
191
|
+
<TopHeader isIos={Platform.OS === 'ios'}>
|
|
187
192
|
{!isOpenSearchBar && (
|
|
188
193
|
<>
|
|
189
194
|
<View style={{ ...styles.headerItem, flex: 1 }}>
|
|
@@ -221,6 +226,46 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
221
226
|
)}
|
|
222
227
|
</TopHeader>
|
|
223
228
|
</Animated.View>
|
|
229
|
+
|
|
230
|
+
{business?.categories?.length > 0 && isOpenFiltProducts && (
|
|
231
|
+
<FiltProductsContainer
|
|
232
|
+
style={{
|
|
233
|
+
height: Dimensions.get('window').height - filtProductsHeight
|
|
234
|
+
}}
|
|
235
|
+
>
|
|
236
|
+
<View style={{ padding: 20, backgroundColor: theme.colors.white }}>
|
|
237
|
+
<BusinessProductsList
|
|
238
|
+
categories={[
|
|
239
|
+
{ id: null, name: t('ALL', 'All') },
|
|
240
|
+
{ id: 'featured', name: t('FEATURED', 'Featured') },
|
|
241
|
+
...business?.categories.sort((a: any, b: any) => a.rank - b.rank)
|
|
242
|
+
]}
|
|
243
|
+
category={categorySelected}
|
|
244
|
+
categoryState={categoryState}
|
|
245
|
+
businessId={business.id}
|
|
246
|
+
errors={errors}
|
|
247
|
+
onProductClick={onProductClick}
|
|
248
|
+
handleSearchRedirect={handleSearchRedirect}
|
|
249
|
+
featured={featuredProducts}
|
|
250
|
+
searchValue={searchValue}
|
|
251
|
+
handleClearSearch={handleChangeSearch}
|
|
252
|
+
errorQuantityProducts={errorQuantityProducts}
|
|
253
|
+
handleCancelSearch={handleCancel}
|
|
254
|
+
categoriesLayout={categoriesLayout}
|
|
255
|
+
subcategoriesSelected={subcategoriesSelected}
|
|
256
|
+
lazyLoadProductsRecommended={business?.lazy_load_products_recommended}
|
|
257
|
+
setCategoriesLayout={setCategoriesLayout}
|
|
258
|
+
currentCart={currentCart}
|
|
259
|
+
setSubcategoriesSelected={setSubcategoriesSelected}
|
|
260
|
+
onClickCategory={handleChangeCategory}
|
|
261
|
+
isFiltMode
|
|
262
|
+
/>
|
|
263
|
+
</View>
|
|
264
|
+
</FiltProductsContainer>
|
|
265
|
+
)}
|
|
266
|
+
{isOpenFiltProducts && (
|
|
267
|
+
<BackgroundGray />
|
|
268
|
+
)}
|
|
224
269
|
<BusinessProductsListingContainer
|
|
225
270
|
stickyHeaderIndices={[2]}
|
|
226
271
|
style={styles.mainContainer}
|
|
@@ -255,7 +300,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
255
300
|
lazyLoadProductsRecommended={business?.lazy_load_products_recommended}
|
|
256
301
|
setSelectedCategoryId={setSelectedCategoryId}
|
|
257
302
|
setCategoryClicked={setCategoryClicked}
|
|
258
|
-
|
|
303
|
+
|
|
259
304
|
/>
|
|
260
305
|
)}
|
|
261
306
|
</>
|
|
@@ -288,6 +333,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
288
333
|
setCategoriesLayout={setCategoriesLayout}
|
|
289
334
|
currentCart={currentCart}
|
|
290
335
|
setSubcategoriesSelected={setSubcategoriesSelected}
|
|
336
|
+
onClickCategory={handleChangeCategory}
|
|
291
337
|
/>
|
|
292
338
|
</WrapContent>
|
|
293
339
|
</>
|
|
@@ -326,7 +372,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
326
372
|
isSecondaryBtn={currentCart?.subtotal < currentCart?.minimum || openUpselling}
|
|
327
373
|
btnLeftValueShow={currentCart?.subtotal >= currentCart?.minimum && currentCart?.products?.length > 0}
|
|
328
374
|
btnRightValueShow={currentCart?.subtotal >= currentCart?.minimum && currentCart?.products?.length > 0}
|
|
329
|
-
btnLeftValue={currentCart?.products
|
|
375
|
+
btnLeftValue={currentCart?.products.reduce((prev: number, product: any) => prev + product.quantity, 0)}
|
|
330
376
|
btnRightValue={parsePrice(currentCart?.total)}
|
|
331
377
|
disabled={currentCart?.subtotal < currentCart?.minimum || openUpselling}
|
|
332
378
|
handleClick={() => setOpenUpselling(true)}
|
|
@@ -347,7 +393,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
347
393
|
onRedirect={onRedirect}
|
|
348
394
|
/>
|
|
349
395
|
)}
|
|
350
|
-
</
|
|
396
|
+
</ContainerSafeAreaView>
|
|
351
397
|
)
|
|
352
398
|
}
|
|
353
399
|
|
|
@@ -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
|
+
`
|
|
@@ -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 }}
|
|
@@ -47,7 +47,7 @@ import { getTypesText, convertToRadian } from '../../utils';
|
|
|
47
47
|
import { OrderProgress } from '../OrderProgress';
|
|
48
48
|
import { useFocusEffect, useIsFocused } from '@react-navigation/native';
|
|
49
49
|
|
|
50
|
-
const PIXELS_TO_SCROLL =
|
|
50
|
+
const PIXELS_TO_SCROLL = 2000;
|
|
51
51
|
|
|
52
52
|
const BusinessesListingUI = (props: BusinessesListingParams) => {
|
|
53
53
|
const {
|
|
@@ -116,7 +116,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
|
|
|
116
116
|
const [featuredBusiness, setFeaturedBusinesses] = useState(Array);
|
|
117
117
|
const [isFarAway, setIsFarAway] = useState(false)
|
|
118
118
|
const [businessTypes, setBusinessTypes] = useState(null)
|
|
119
|
-
|
|
119
|
+
const [orderTypeValue, setOrderTypeValue] = useState(orderState?.options.value)
|
|
120
120
|
const isPreorderEnabled = (configs?.preorder_status_enabled?.value === '1' || configs?.preorder_status_enabled?.value === 'true') &&
|
|
121
121
|
Number(configs?.max_days_preorder?.value) > 0
|
|
122
122
|
const isPreOrderSetting = configs?.preorder_status_enabled?.value === '1'
|
|
@@ -203,6 +203,12 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
|
|
|
203
203
|
})
|
|
204
204
|
}, [orderState?.options?.address?.location])
|
|
205
205
|
|
|
206
|
+
useEffect(() => {
|
|
207
|
+
if(!orderState?.loading){
|
|
208
|
+
setOrderTypeValue(orderState?.options?.type)
|
|
209
|
+
}
|
|
210
|
+
}, [orderState?.options?.type])
|
|
211
|
+
|
|
206
212
|
useFocusEffect(
|
|
207
213
|
useCallback(() => {
|
|
208
214
|
resetInactivityTimeout()
|
|
@@ -257,8 +263,8 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
|
|
|
257
263
|
)}
|
|
258
264
|
<OrderControlContainer>
|
|
259
265
|
<View style={styles.wrapperOrderOptions}>
|
|
260
|
-
<WrapMomentOption onPress={() => navigation.navigate('OrderTypes', { configTypes: configTypes })}>
|
|
261
|
-
<OText size={12} numberOfLines={1} ellipsizeMode={'tail'} color={theme.colors.textSecondary}>{t(getTypesText(orderState?.options?.type || 1), 'Delivery')}</OText>
|
|
266
|
+
<WrapMomentOption onPress={() => navigation.navigate('OrderTypes', { configTypes: configTypes, setOrderTypeValue })}>
|
|
267
|
+
<OText size={12} numberOfLines={1} ellipsizeMode={'tail'} color={theme.colors.textSecondary}>{t(getTypesText(orderTypeValue || orderState?.options?.type || 1), 'Delivery')}</OText>
|
|
262
268
|
<OIcon
|
|
263
269
|
src={theme.images.general.arrow_down}
|
|
264
270
|
width={10}
|
|
@@ -273,7 +279,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
|
|
|
273
279
|
numberOfLines={1}
|
|
274
280
|
ellipsizeMode="tail"
|
|
275
281
|
color={theme.colors.textSecondary}>
|
|
276
|
-
{orderState.options?.
|
|
282
|
+
{orderState.options?.moment
|
|
277
283
|
? parseDate(orderState.options?.moment, { outputFormat: configs?.dates_moment_format?.value })
|
|
278
284
|
: t('ASAP_ABBREVIATION', 'ASAP')}
|
|
279
285
|
</OText>
|
|
@@ -325,7 +331,6 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
|
|
|
325
331
|
{featuredBusiness.map((bAry: any, idx) => (
|
|
326
332
|
<View key={'f-listing_' + idx}>
|
|
327
333
|
<BusinessFeaturedController
|
|
328
|
-
key={bAry[0].id}
|
|
329
334
|
business={bAry[0]}
|
|
330
335
|
isBusinessOpen={bAry[0]?.open}
|
|
331
336
|
handleCustomClick={handleBusinessClick}
|
|
@@ -333,7 +338,6 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
|
|
|
333
338
|
/>
|
|
334
339
|
{bAry.length > 1 && (
|
|
335
340
|
<BusinessFeaturedController
|
|
336
|
-
key={bAry[1].id}
|
|
337
341
|
business={bAry[1]}
|
|
338
342
|
isBusinessOpen={bAry[1]?.open}
|
|
339
343
|
handleCustomClick={handleBusinessClick}
|
|
@@ -372,9 +376,9 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
|
|
|
372
376
|
/>
|
|
373
377
|
)}
|
|
374
378
|
{businessesList.businesses?.map(
|
|
375
|
-
(business: any) => (
|
|
379
|
+
(business: any, i : number) => (
|
|
376
380
|
<BusinessController
|
|
377
|
-
key={business.id}
|
|
381
|
+
key={`${business.id}_` + i}
|
|
378
382
|
business={business}
|
|
379
383
|
isBusinessOpen={business.open}
|
|
380
384
|
handleCustomClick={handleBusinessClick}
|
|
@@ -166,9 +166,9 @@ const CartUI = (props: any) => {
|
|
|
166
166
|
handleClickCheckout={() => setOpenUpselling(true)}
|
|
167
167
|
checkoutButtonDisabled={(openUpselling && !canOpenUpselling) || cart?.subtotal < cart?.minimum || !cart?.valid_address}
|
|
168
168
|
>
|
|
169
|
-
{cart?.products?.length > 0 && cart?.products.map((product: any) => (
|
|
169
|
+
{cart?.products?.length > 0 && cart?.products.map((product: any, i: number) => (
|
|
170
170
|
<ProductItemAccordion
|
|
171
|
-
key={product.code}
|
|
171
|
+
key={`${product.code}_${i}`}
|
|
172
172
|
isCartPending={isCartPending}
|
|
173
173
|
isCartProduct
|
|
174
174
|
product={product}
|
|
@@ -202,8 +202,8 @@ const CartUI = (props: any) => {
|
|
|
202
202
|
</OSTable>
|
|
203
203
|
)}
|
|
204
204
|
{
|
|
205
|
-
cart?.offers?.length > 0 && cart?.offers?.filter((offer: any) => offer?.target === 1)?.map((offer: any) => (
|
|
206
|
-
<OSTable key={offer.id}>
|
|
205
|
+
cart?.offers?.length > 0 && cart?.offers?.filter((offer: any) => offer?.target === 1)?.map((offer: any, i: number) => (
|
|
206
|
+
<OSTable key={`${offer.id}_${i}`}>
|
|
207
207
|
<OSRow>
|
|
208
208
|
<OText size={12} lineHeight={18}>{offer.name}</OText>
|
|
209
209
|
{offer.rate_type === 1 && (
|
|
@@ -234,8 +234,8 @@ const CartUI = (props: any) => {
|
|
|
234
234
|
</OSTable>
|
|
235
235
|
)}
|
|
236
236
|
{
|
|
237
|
-
cart.taxes?.length > 0 && cart.taxes.filter((tax: any) => tax.type === 2 && tax?.rate !== 0).map((tax: any) => (
|
|
238
|
-
<OSTable key={tax.id}>
|
|
237
|
+
cart.taxes?.length > 0 && cart.taxes.filter((tax: any) => tax.type === 2 && tax?.rate !== 0).map((tax: any, i: number) => (
|
|
238
|
+
<OSTable key={`${tax.id}_${i}`}>
|
|
239
239
|
<OSRow>
|
|
240
240
|
<OText size={12} lineHeight={18} numberOfLines={1} >
|
|
241
241
|
{tax.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
|
|
@@ -250,8 +250,8 @@ const CartUI = (props: any) => {
|
|
|
250
250
|
))
|
|
251
251
|
}
|
|
252
252
|
{
|
|
253
|
-
cart?.fees?.length > 0 && cart?.fees?.filter((fee: any) => !(fee.fixed === 0 && fee.percentage === 0)).map((fee: any) => (
|
|
254
|
-
<OSTable key={fee
|
|
253
|
+
cart?.fees?.length > 0 && cart?.fees?.filter((fee: any) => !(fee.fixed === 0 && fee.percentage === 0)).map((fee: any, i: number) => (
|
|
254
|
+
<OSTable key={`${fee.id}_${i}`}>
|
|
255
255
|
<OSRow>
|
|
256
256
|
<OText size={12} lineHeight={18} numberOfLines={1}>
|
|
257
257
|
{fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
|
|
@@ -293,8 +293,8 @@ const CartUI = (props: any) => {
|
|
|
293
293
|
</OSTable>
|
|
294
294
|
)}
|
|
295
295
|
{
|
|
296
|
-
cart?.offers?.length > 0 && cart?.offers?.filter((offer: any) => offer?.target === 2)?.map((offer: any) => (
|
|
297
|
-
<OSTable key={offer.id}>
|
|
296
|
+
cart?.offers?.length > 0 && cart?.offers?.filter((offer: any) => offer?.target === 2)?.map((offer: any, i: number) => (
|
|
297
|
+
<OSTable key={`${offer.id}_${i}`}>
|
|
298
298
|
<OSRow>
|
|
299
299
|
<OText size={12} lineHeight={18}>{offer.name}</OText>
|
|
300
300
|
{offer.rate_type === 1 && (
|
|
@@ -409,7 +409,7 @@ const CartUI = (props: any) => {
|
|
|
409
409
|
)}
|
|
410
410
|
</OSBill>
|
|
411
411
|
)}
|
|
412
|
-
{cart?.valid_products
|
|
412
|
+
{cart?.valid_products ? (
|
|
413
413
|
<CheckoutAction>
|
|
414
414
|
<OButton
|
|
415
415
|
text={(cart?.subtotal >= cart?.minimum || !cart?.minimum) && cart?.valid_address ? (
|
|
@@ -428,6 +428,12 @@ const CartUI = (props: any) => {
|
|
|
428
428
|
style={{ width: '100%', flexDirection: 'row', justifyContent: 'center', borderRadius: 7.6, shadowOpacity: 0 }}
|
|
429
429
|
/>
|
|
430
430
|
</CheckoutAction>
|
|
431
|
+
) : (
|
|
432
|
+
<View style={{ alignItems: 'center', width: '100%' }}>
|
|
433
|
+
<OText size={12} color={theme.colors.red} style={{ textAlign: 'center', marginTop: 5 }}>
|
|
434
|
+
{t('WARNING_INVALID_PRODUCTS_CHECKOUT', 'To continue with your checkout, please remove from your cart the products that are not available.')}
|
|
435
|
+
</OText>
|
|
436
|
+
</View>
|
|
431
437
|
)}
|
|
432
438
|
</BusinessItemAccordion>
|
|
433
439
|
|
|
@@ -649,7 +649,7 @@ const CheckoutUI = (props: any) => {
|
|
|
649
649
|
color={theme.colors.error}
|
|
650
650
|
size={12}
|
|
651
651
|
>
|
|
652
|
-
{t('
|
|
652
|
+
{t('WARNING_INVALID_PRODUCTS_CHECKOUT', 'To continue with your checkout, please remove from your cart the products that are not available.')}
|
|
653
653
|
</OText>
|
|
654
654
|
)}
|
|
655
655
|
{placeSpotTypes.includes(options?.type) && !cart?.place && (
|
|
@@ -36,7 +36,9 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
36
36
|
loadOrders,
|
|
37
37
|
setSelectedOrderId,
|
|
38
38
|
setOrderList,
|
|
39
|
-
setOpenMessges
|
|
39
|
+
setOpenMessges,
|
|
40
|
+
setRefreshOrders,
|
|
41
|
+
refreshOrders
|
|
40
42
|
} = props
|
|
41
43
|
|
|
42
44
|
const theme = useTheme();
|
|
@@ -99,6 +101,13 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
99
101
|
setOrderList(orderList)
|
|
100
102
|
}, [orderList, loading])
|
|
101
103
|
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
if(refreshOrders){
|
|
106
|
+
loadOrders(false, false, false, true)
|
|
107
|
+
setRefreshOrders && setRefreshOrders(false)
|
|
108
|
+
}
|
|
109
|
+
}, [refreshOrders])
|
|
110
|
+
|
|
102
111
|
return (
|
|
103
112
|
<>
|
|
104
113
|
{!loading && orders.length === 0 && (
|