ordering-ui-react-native 0.12.72 → 0.12.76
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/src/components/Messages/index.tsx +1 -1
- package/src/utils/index.tsx +3 -1
- package/themes/business/index.tsx +3 -1
- package/themes/business/src/components/NewOrderNotification/index.tsx +4 -4
- package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +1 -1
- package/themes/business/src/components/OrdersOption/index.tsx +0 -2
- package/themes/doordash/src/components/BusinessProductsCategories/index.tsx +30 -30
- package/themes/original/src/components/ActiveOrders/index.tsx +3 -5
- package/themes/original/src/components/BusinessMenuList/index.tsx +6 -0
- package/themes/original/src/components/BusinessPreorder/index.tsx +18 -5
- package/themes/original/src/components/BusinessPreorder/styles.tsx +2 -6
- package/themes/original/src/components/BusinessProductsCategories/index.tsx +29 -32
- package/themes/original/src/components/BusinessProductsListing/index.tsx +25 -8
- package/themes/original/src/components/BusinessTypeFilter/styles.tsx +1 -1
- package/themes/original/src/components/OrdersOption/index.tsx +1 -1
- package/themes/original/src/types/index.tsx +3 -1
package/package.json
CHANGED
|
@@ -118,7 +118,7 @@ const MessagesUI = (props: MessagesParams) => {
|
|
|
118
118
|
const messageConsole = (message: any) => {
|
|
119
119
|
return message.change?.attribute !== 'driver_id'
|
|
120
120
|
?
|
|
121
|
-
`${t('ORDER', 'Order')} ${message.change.attribute} ${t('CHANGED_FROM', 'Changed from')} ${message.change.old !== null && t(ORDER_STATUS[parseInt(message.change.old, 10)])} ${t('TO', 'to')} ${t(ORDER_STATUS[parseInt(message.change.new, 10)])}`
|
|
121
|
+
`${t('ORDER', 'Order')} ${t(message.change.attribute.toUpperCase(), message.change.attribute.replace('_', ' '))} ${t('CHANGED_FROM', 'Changed from')} ${message.change.old !== null && t(ORDER_STATUS[parseInt(message.change.old, 10)])} ${t('TO', 'to')} ${t(ORDER_STATUS[parseInt(message.change.new, 10)])}`
|
|
122
122
|
: message.change.new
|
|
123
123
|
?
|
|
124
124
|
`${message.driver?.name} ${message.driver?.lastname !== null ? message.driver.lastname : ''} ${t('WAS_ASSIGNED_AS_DRIVER', 'Was assigned as driver')} ${message.comment ? message.comment.length : ''}`
|
package/src/utils/index.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import FontAwesome from 'react-native-vector-icons/FontAwesome';
|
|
3
3
|
import {CODES} from 'ordering-components/native'
|
|
4
|
+
import { useLanguage } from 'ordering-components/native'
|
|
4
5
|
|
|
5
6
|
export const flatArray = (arr: any) => [].concat(...arr)
|
|
6
7
|
|
|
@@ -42,10 +43,11 @@ export const getTraduction = (key: string, t: any) => {
|
|
|
42
43
|
* @param {string} time business delivery time
|
|
43
44
|
*/
|
|
44
45
|
export const convertHoursToMinutes = (time: any) => {
|
|
46
|
+
const [, t] = useLanguage()
|
|
45
47
|
if (!time) return '0min'
|
|
46
48
|
const [hour, minute] = time.split(':')
|
|
47
49
|
const result = (parseInt(hour, 10) * 60) + parseInt(minute, 10)
|
|
48
|
-
return `${result}min`
|
|
50
|
+
return `${result}${t('MIN', 'min')}`
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
export const getIconCard = (brand: string, size: number) => {
|
|
@@ -36,6 +36,7 @@ import { UserProfileForm } from './src/components/UserProfileForm';
|
|
|
36
36
|
import { VerifyPhone } from './src/components/VerifyPhone';
|
|
37
37
|
import { DriverMap } from './src/components/DriverMap';
|
|
38
38
|
import { MapViewUI as MapView } from './src/components/MapView'
|
|
39
|
+
import { NewOrderNotification } from './src/components/NewOrderNotification';
|
|
39
40
|
//OComponents
|
|
40
41
|
import {
|
|
41
42
|
OText,
|
|
@@ -74,8 +75,9 @@ export {
|
|
|
74
75
|
LoginForm,
|
|
75
76
|
LogoutButton,
|
|
76
77
|
MessagesOption,
|
|
77
|
-
NotFoundSource,
|
|
78
78
|
MapView,
|
|
79
|
+
NewOrderNotification,
|
|
80
|
+
NotFoundSource,
|
|
79
81
|
OrderDetailsBusiness,
|
|
80
82
|
OrderDetailsDelivery,
|
|
81
83
|
OrderMessage,
|
|
@@ -59,19 +59,19 @@ export const NewOrderNotification = (props: any) => {
|
|
|
59
59
|
setModalOpen(false)
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
const handleNotification =
|
|
62
|
+
const handleNotification = (order: any) => {
|
|
63
|
+
setModalOpen(true)
|
|
63
64
|
clearInterval(soundTimeout)
|
|
64
65
|
handlePlayNotificationSound()
|
|
65
66
|
setNewOrderId(order.id)
|
|
66
|
-
|
|
67
|
-
}, [newOrderId, notificationSound, soundTimeout])
|
|
67
|
+
}
|
|
68
68
|
|
|
69
69
|
useEffect(() => {
|
|
70
70
|
events.on('order_added', handleNotification)
|
|
71
71
|
return () => {
|
|
72
72
|
events.off('order_added', handleNotification)
|
|
73
73
|
}
|
|
74
|
-
}, [
|
|
74
|
+
}, [])
|
|
75
75
|
|
|
76
76
|
const handleUpdateOrder = useCallback(async (order: any) => {
|
|
77
77
|
if (order?.driver) {
|
|
@@ -161,7 +161,7 @@ export const OrderHeaderComponent = (props: OrderHeader) => {
|
|
|
161
161
|
|
|
162
162
|
<OText numberOfLines={2} size={20} weight="600">
|
|
163
163
|
<>
|
|
164
|
-
{`${t('INVOICE_ORDER_NO', 'Order No.')} ${order
|
|
164
|
+
{`${t('INVOICE_ORDER_NO', 'Order No.')} ${order?.id} `}
|
|
165
165
|
{!order?.isLogistic && (!order?.order_group_id || !logisticOrderStatus?.includes(order?.status)) && (
|
|
166
166
|
<>
|
|
167
167
|
{t('IS', 'is')}{' '}
|
|
@@ -20,7 +20,6 @@ import {
|
|
|
20
20
|
} from './styles';
|
|
21
21
|
import { PreviousOrders } from '../PreviousOrders';
|
|
22
22
|
import { OrdersOptionParams } from '../../types';
|
|
23
|
-
import { NewOrderNotification } from '../NewOrderNotification';
|
|
24
23
|
|
|
25
24
|
import { TouchableOpacity } from 'react-native-gesture-handler';
|
|
26
25
|
import GestureRecognizer from 'react-native-swipe-gestures';
|
|
@@ -549,7 +548,6 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
549
548
|
</View>
|
|
550
549
|
{/* </GestureRecognizer> */}
|
|
551
550
|
|
|
552
|
-
<NewOrderNotification />
|
|
553
551
|
{openModal && (
|
|
554
552
|
<OModal open={openModal} entireModal customClose>
|
|
555
553
|
<ModalContainer
|
|
@@ -26,7 +26,7 @@ const BusinessProductsCategoriesUI = (props: any) => {
|
|
|
26
26
|
|
|
27
27
|
const [tabLayouts, setTabLayouts] = useState<any>({});
|
|
28
28
|
const [scrollOffsetX, setScrollOffsetX] = useState<any>(0);
|
|
29
|
-
|
|
29
|
+
const tabsRef = useRef<any>(null);
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
const theme = useTheme();
|
|
@@ -56,47 +56,47 @@ const BusinessProductsCategoriesUI = (props: any) => {
|
|
|
56
56
|
const handleCategoryScroll = (category: any) => {
|
|
57
57
|
setCategoryClicked(true);
|
|
58
58
|
setSelectedCategoryId(`cat_${category?.id}`);
|
|
59
|
-
|
|
60
|
-
if (!lazyLoadProductsRecommended) {
|
|
61
|
-
if (category?.id) {
|
|
62
|
-
scrollViewRef.current.scrollTo({
|
|
63
|
-
y: categoriesLayout[`cat_${category?.id}`]?.y + productListLayout?.y + 270,
|
|
64
|
-
animated: true
|
|
65
|
-
})
|
|
66
|
-
} else {
|
|
67
|
-
scrollViewRef.current.scrollTo({
|
|
68
|
-
y: productListLayout?.y - 70,
|
|
69
|
-
animated: true
|
|
70
|
-
})
|
|
71
|
-
}
|
|
72
|
-
} else {
|
|
73
|
-
handlerClickCategory(category)
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
59
|
|
|
77
|
-
|
|
78
|
-
|
|
60
|
+
if (!lazyLoadProductsRecommended) {
|
|
61
|
+
if (category?.id) {
|
|
62
|
+
scrollViewRef.current.scrollTo({
|
|
63
|
+
y: categoriesLayout[`cat_${category?.id}`]?.y + productListLayout?.y + 270,
|
|
64
|
+
animated: true
|
|
65
|
+
})
|
|
66
|
+
} else {
|
|
67
|
+
scrollViewRef.current.scrollTo({
|
|
68
|
+
y: productListLayout?.y - 70,
|
|
69
|
+
animated: true
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
} else {
|
|
73
|
+
handlerClickCategory(category)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
const handleOnLayout = (event: any, categoryId: any) => {
|
|
79
79
|
const _tabLayouts = { ...tabLayouts }
|
|
80
80
|
const categoryKey = 'cat_' + categoryId
|
|
81
81
|
_tabLayouts[categoryKey] = event.nativeEvent.layout
|
|
82
82
|
setTabLayouts(_tabLayouts)
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
if (!selectedCategoryId || Object.keys(tabLayouts).length === 0) return
|
|
87
|
+
tabsRef.current.scrollTo({
|
|
88
|
+
x: tabLayouts[selectedCategoryId]?.x - 40,
|
|
89
|
+
animated: true
|
|
90
|
+
})
|
|
91
|
+
}, [selectedCategoryId, tabLayouts])
|
|
92
92
|
|
|
93
93
|
|
|
94
94
|
return (
|
|
95
|
-
<ScrollView ref={tabsRef} horizontal contentContainerStyle={contentStyle}
|
|
95
|
+
<ScrollView ref={tabsRef} horizontal contentContainerStyle={contentStyle}
|
|
96
96
|
style={{ ...styles.container, borderBottomWidth: loading ? 0 : 1 }} showsHorizontalScrollIndicator={false}
|
|
97
97
|
onScroll={(e: any) => setScrollOffsetX(e.nativeEvent.contentOffset.x)}
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
scrollEventThrottle={16}
|
|
99
|
+
>
|
|
100
100
|
{loading && (
|
|
101
101
|
<Placeholder Animation={Fade}>
|
|
102
102
|
<View style={{ flexDirection: 'row' }}>
|
|
@@ -117,10 +117,8 @@ export const ActiveOrders = (props: ActiveOrdersParams) => {
|
|
|
117
117
|
{pagination?.totalPages && pagination?.currentPage < pagination?.totalPages && (
|
|
118
118
|
<LoadMore>
|
|
119
119
|
<OButton
|
|
120
|
-
|
|
121
|
-
textStyle={{ color: theme.colors.primary, fontSize: 14 }}
|
|
120
|
+
textStyle={{ color: '#fff' }}
|
|
122
121
|
text={t('LOAD_MORE_ORDERS', 'Load more orders')}
|
|
123
|
-
borderColor={theme.colors.primary}
|
|
124
122
|
onClick={loadMoreOrders}
|
|
125
123
|
style={styles.loadMoreButton}
|
|
126
124
|
/>
|
|
@@ -154,9 +152,9 @@ const styles = StyleSheet.create({
|
|
|
154
152
|
minWidth: 230,
|
|
155
153
|
},
|
|
156
154
|
loadMoreButton: {
|
|
157
|
-
width:
|
|
158
|
-
height: 46,
|
|
155
|
+
width: '100%',
|
|
159
156
|
marginLeft: 'auto',
|
|
160
157
|
marginRight: 'auto',
|
|
158
|
+
borderRadius: 7.6
|
|
161
159
|
},
|
|
162
160
|
});
|
|
@@ -81,6 +81,7 @@ const BusinessMenuListUI = (props: BusinessMenuListParams) => {
|
|
|
81
81
|
<IconAntDesign
|
|
82
82
|
name='close'
|
|
83
83
|
color={theme.colors.textThird}
|
|
84
|
+
style={{ marginLeft: 7 }}
|
|
84
85
|
size={24}
|
|
85
86
|
/>
|
|
86
87
|
</TouchableOpacity>
|
|
@@ -115,6 +116,11 @@ const BusinessMenuListUI = (props: BusinessMenuListParams) => {
|
|
|
115
116
|
</DropOption>
|
|
116
117
|
</TouchableOpacity>
|
|
117
118
|
))}
|
|
119
|
+
{businessMenuList?.menus && businessMenuList?.menus.length === 0 && (
|
|
120
|
+
<View>
|
|
121
|
+
<OText>{t('NO_RESULTS_FOUND', 'Sorry, no results found')}</OText>
|
|
122
|
+
</View>
|
|
123
|
+
)}
|
|
118
124
|
</MenuListWrapper>
|
|
119
125
|
</OModal>
|
|
120
126
|
</>
|
|
@@ -123,6 +123,17 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
|
|
|
123
123
|
color: '#B1BCCC',
|
|
124
124
|
fontSize: 14,
|
|
125
125
|
fontWeight: '500'
|
|
126
|
+
},
|
|
127
|
+
wrapperIcon: {
|
|
128
|
+
overflow: 'hidden',
|
|
129
|
+
backgroundColor: 'transparent',
|
|
130
|
+
marginBottom: 12,
|
|
131
|
+
width: 25,
|
|
132
|
+
height: 25,
|
|
133
|
+
marginStart: 7,
|
|
134
|
+
alignItems: 'center',
|
|
135
|
+
justifyContent: 'center',
|
|
136
|
+
zIndex: 99999
|
|
126
137
|
}
|
|
127
138
|
})
|
|
128
139
|
|
|
@@ -264,12 +275,13 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
|
|
|
264
275
|
|
|
265
276
|
return (
|
|
266
277
|
<>
|
|
267
|
-
<PreOrderContainer>
|
|
278
|
+
<PreOrderContainer contentContainerStyle={{ paddingVertical: 30, paddingHorizontal: 40 }}>
|
|
268
279
|
<TouchableOpacity onPress={() => goToBack && goToBack()} style={{ marginBottom: 12 }}>
|
|
269
280
|
<IconAntDesign
|
|
270
281
|
name='close'
|
|
271
282
|
color={theme.colors.textThird}
|
|
272
283
|
size={24}
|
|
284
|
+
style={{ marginLeft: -4}}
|
|
273
285
|
/>
|
|
274
286
|
</TouchableOpacity>
|
|
275
287
|
<BusinessInfoWrapper>
|
|
@@ -350,7 +362,7 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
|
|
|
350
362
|
{t('ORDER_TIME', 'Order time')}
|
|
351
363
|
</OText>
|
|
352
364
|
<View style={{ flex: 1 }}>
|
|
353
|
-
{selectDate && datesWhitelist[0]
|
|
365
|
+
{selectDate && datesWhitelist[0]?.start !== null && (
|
|
354
366
|
<CalendarStrip
|
|
355
367
|
scrollable
|
|
356
368
|
style={styles.calendar}
|
|
@@ -398,7 +410,7 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
|
|
|
398
410
|
<OButton
|
|
399
411
|
text={t('GO_TO_MENU', 'Go to menu')}
|
|
400
412
|
textStyle={{color: 'white'}}
|
|
401
|
-
style={{borderRadius: 7.6, marginBottom:
|
|
413
|
+
style={{borderRadius: 7.6, marginBottom: 20, marginTop: 30}}
|
|
402
414
|
onClick={() => handleClickBusiness()}
|
|
403
415
|
/>
|
|
404
416
|
</PreOrderContainer>
|
|
@@ -409,8 +421,8 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
|
|
|
409
421
|
customClose
|
|
410
422
|
entireModal
|
|
411
423
|
>
|
|
412
|
-
<PreorderTypeListWrapper>
|
|
413
|
-
<TouchableOpacity onPress={() => setIsPreorderTypeList(false)} style={
|
|
424
|
+
<PreorderTypeListWrapper contentContainerStyle={{ paddingVertical: 20, paddingHorizontal: 40}}>
|
|
425
|
+
<TouchableOpacity onPress={() => setIsPreorderTypeList(false)} style={styles.wrapperIcon}>
|
|
414
426
|
<IconAntDesign
|
|
415
427
|
name='close'
|
|
416
428
|
color={theme.colors.textThird}
|
|
@@ -421,6 +433,7 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
|
|
|
421
433
|
<TouchableOpacity
|
|
422
434
|
key={index}
|
|
423
435
|
onPress={() => handleClickPreorderType(option)}
|
|
436
|
+
style={{ zIndex: 99999 }}
|
|
424
437
|
>
|
|
425
438
|
<DropOption
|
|
426
439
|
numberOfLines={1}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import styled, { css } from 'styled-components/native'
|
|
2
2
|
|
|
3
|
-
export const PreOrderContainer = styled.ScrollView
|
|
4
|
-
padding: 20px 40px 30px 40px;
|
|
5
|
-
`
|
|
3
|
+
export const PreOrderContainer = styled.ScrollView``
|
|
6
4
|
|
|
7
5
|
export const BusinessInfoWrapper = styled.View`
|
|
8
6
|
flex-direction: row;
|
|
@@ -45,9 +43,7 @@ export const TimeItem = styled.View`
|
|
|
45
43
|
`}
|
|
46
44
|
`
|
|
47
45
|
|
|
48
|
-
export const PreorderTypeListWrapper = styled.ScrollView
|
|
49
|
-
padding: 20px 40px 30px 40px;
|
|
50
|
-
`
|
|
46
|
+
export const PreorderTypeListWrapper = styled.ScrollView``
|
|
51
47
|
|
|
52
48
|
export const DropOption = styled.View`
|
|
53
49
|
padding: 10px;
|
|
@@ -18,7 +18,9 @@ const BusinessProductsCategoriesUI = (props: any) => {
|
|
|
18
18
|
categoriesLayout,
|
|
19
19
|
selectedCategoryId,
|
|
20
20
|
handlerClickCategory,
|
|
21
|
-
lazyLoadProductsRecommended
|
|
21
|
+
lazyLoadProductsRecommended,
|
|
22
|
+
setCategoryClicked,
|
|
23
|
+
setSelectedCategoryId
|
|
22
24
|
} = props;
|
|
23
25
|
|
|
24
26
|
const theme = useTheme();
|
|
@@ -36,9 +38,23 @@ const BusinessProductsCategoriesUI = (props: any) => {
|
|
|
36
38
|
featuredStyle: {
|
|
37
39
|
display: 'none',
|
|
38
40
|
},
|
|
41
|
+
tabStyle: {
|
|
42
|
+
marginTop: 10,
|
|
43
|
+
height: 4,
|
|
44
|
+
borderTopStartRadius: 4,
|
|
45
|
+
borderTopEndRadius: 4,
|
|
46
|
+
backgroundColor: theme.colors.textPrimary,
|
|
47
|
+
},
|
|
48
|
+
tabDeactived: {
|
|
49
|
+
marginTop: 10,
|
|
50
|
+
height: 4
|
|
51
|
+
}
|
|
39
52
|
});
|
|
40
53
|
|
|
41
54
|
const handleCategoryScroll = (category: any) => {
|
|
55
|
+
setCategoryClicked(true);
|
|
56
|
+
setSelectedCategoryId(`cat_${category?.id}`);
|
|
57
|
+
|
|
42
58
|
if (!lazyLoadProductsRecommended) {
|
|
43
59
|
if (category?.id) {
|
|
44
60
|
scrollViewRef.current.scrollTo({
|
|
@@ -57,11 +73,11 @@ const BusinessProductsCategoriesUI = (props: any) => {
|
|
|
57
73
|
}
|
|
58
74
|
|
|
59
75
|
const handleOnLayout = (event: any, categoryId: any) => {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
76
|
+
const _tabLayouts = { ...tabLayouts }
|
|
77
|
+
const categoryKey = 'cat_' + categoryId
|
|
78
|
+
_tabLayouts[categoryKey] = event.nativeEvent.layout
|
|
79
|
+
setTabLayouts(_tabLayouts)
|
|
80
|
+
}
|
|
65
81
|
|
|
66
82
|
useEffect(() => {
|
|
67
83
|
if (!selectedCategoryId || Object.keys(tabLayouts).length === 0) return
|
|
@@ -102,39 +118,20 @@ const BusinessProductsCategoriesUI = (props: any) => {
|
|
|
102
118
|
{
|
|
103
119
|
borderColor:
|
|
104
120
|
(!lazyLoadProductsRecommended
|
|
105
|
-
?
|
|
106
|
-
:
|
|
107
|
-
|
|
108
|
-
|
|
121
|
+
? (selectedCategoryId === (category.id ? `cat_${category.id}` : null))
|
|
122
|
+
: (categorySelected?.id === category.id))
|
|
123
|
+
? theme.colors.textNormal
|
|
124
|
+
: theme.colors.border,
|
|
109
125
|
},
|
|
110
126
|
]}
|
|
111
127
|
onLayout={(event: any) => handleOnLayout(event, category.id)}
|
|
112
128
|
>
|
|
113
129
|
<OText
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
? (selectedCategoryId === (category.id ? `cat_${category.id}` : null))
|
|
117
|
-
: (categorySelected?.id === category.id))
|
|
118
|
-
? 14
|
|
119
|
-
: 12
|
|
120
|
-
}
|
|
121
|
-
weight={
|
|
122
|
-
(!lazyLoadProductsRecommended
|
|
123
|
-
? (selectedCategoryId === (category.id ? `cat_${category.id}` : null))
|
|
124
|
-
: (categorySelected?.id === category.id))
|
|
125
|
-
? '600'
|
|
126
|
-
: '400'
|
|
127
|
-
}
|
|
128
|
-
color={
|
|
129
|
-
(!lazyLoadProductsRecommended
|
|
130
|
-
? (selectedCategoryId === (category.id ? `cat_${category.id}` : null))
|
|
131
|
-
: (categorySelected?.id === category.id))
|
|
132
|
-
? theme.colors.textNormal
|
|
133
|
-
: theme.colors.textSecondary
|
|
134
|
-
}
|
|
135
|
-
style={{ alignSelf: 'center' }}>
|
|
130
|
+
color={selectedCategoryId === `cat_${category.id}` ? theme.colors.textPrimary : theme.colors.textSecondary}
|
|
131
|
+
>
|
|
136
132
|
{category.name}
|
|
137
133
|
</OText>
|
|
134
|
+
<View style={selectedCategoryId === `cat_${category.id}` ? styles.tabStyle : styles.tabDeactived} />
|
|
138
135
|
</Tab>
|
|
139
136
|
))}
|
|
140
137
|
</ScrollView>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useEffect, useRef, useState } from 'react'
|
|
1
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react'
|
|
2
2
|
import { View, TouchableOpacity, StyleSheet, SafeAreaView, Platform } from 'react-native'
|
|
3
3
|
import { useTheme } from 'styled-components/native';
|
|
4
4
|
import {
|
|
@@ -27,6 +27,8 @@ import {
|
|
|
27
27
|
import { FloatingButton } from '../FloatingButton'
|
|
28
28
|
import { ProductForm } from '../ProductForm'
|
|
29
29
|
import { UpsellingProducts } from '../UpsellingProducts'
|
|
30
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
31
|
+
import Animated from 'react-native-reanimated'
|
|
30
32
|
|
|
31
33
|
const PIXELS_TO_SCROLL = 1000
|
|
32
34
|
|
|
@@ -53,7 +55,8 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
53
55
|
const [{ auth }] = useSession()
|
|
54
56
|
const [orderState] = useOrder()
|
|
55
57
|
const [{ parsePrice }] = useUtils()
|
|
56
|
-
|
|
58
|
+
const [, { showToast }] = useToast()
|
|
59
|
+
const { top } = useSafeAreaInsets();
|
|
57
60
|
|
|
58
61
|
const styles = StyleSheet.create({
|
|
59
62
|
mainContainer: {
|
|
@@ -90,6 +93,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
90
93
|
const scrollViewRef = useRef<any>(null)
|
|
91
94
|
const [categoriesLayout, setCategoriesLayout] = useState<any>({})
|
|
92
95
|
const [productListLayout, setProductListLayout] = useState<any>(null)
|
|
96
|
+
const [isCategoryClicked, setCategoryClicked] = useState(false)
|
|
93
97
|
|
|
94
98
|
const currentCart: any = Object.values(orderState.carts).find((cart: any) => cart?.business?.slug === business?.slug) ?? {}
|
|
95
99
|
|
|
@@ -131,7 +135,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
131
135
|
|
|
132
136
|
const [selectedCategoryId, setSelectedCategoryId] = useState<any>(null)
|
|
133
137
|
|
|
134
|
-
const
|
|
138
|
+
const handlePageScroll = useCallback(({ nativeEvent }: any) => {
|
|
135
139
|
const scrollOffset = nativeEvent.contentOffset.y
|
|
136
140
|
if (businessState?.business?.lazy_load_products_recommended) {
|
|
137
141
|
const height = nativeEvent.contentSize.height
|
|
@@ -141,9 +145,14 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
141
145
|
showToast(ToastType.Info, t('LOADING_MORE_PRODUCTS', 'Loading more products'))
|
|
142
146
|
}
|
|
143
147
|
} else {
|
|
144
|
-
if (!scrollOffset || !categoriesLayout || !productListLayout) return
|
|
148
|
+
if (!scrollOffset || !categoriesLayout || !productListLayout || isCategoryClicked) return
|
|
149
|
+
|
|
145
150
|
for (const key in categoriesLayout) {
|
|
146
151
|
const categoryOffset = categoriesLayout[key].y + productListLayout?.y - 70
|
|
152
|
+
if (scrollOffset < 10) {
|
|
153
|
+
setSelectedCategoryId('cat_all');
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
147
156
|
if (categoryOffset - 50 <= scrollOffset && scrollOffset <= categoryOffset + 50) {
|
|
148
157
|
if (selectedCategoryId !== key) {
|
|
149
158
|
setSelectedCategoryId(key)
|
|
@@ -151,7 +160,12 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
151
160
|
}
|
|
152
161
|
}
|
|
153
162
|
}
|
|
154
|
-
}
|
|
163
|
+
}, [isCategoryClicked, selectedCategoryId, productListLayout])
|
|
164
|
+
|
|
165
|
+
const handleTouchDrag = useCallback(() => {
|
|
166
|
+
setCategoryClicked(false);
|
|
167
|
+
}, []);
|
|
168
|
+
|
|
155
169
|
|
|
156
170
|
useEffect(() => {
|
|
157
171
|
if (!orderState.loading) {
|
|
@@ -163,7 +177,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
163
177
|
<SafeAreaView
|
|
164
178
|
style={{ flex: 1 }}
|
|
165
179
|
>
|
|
166
|
-
<
|
|
180
|
+
<Animated.View style={{ position: 'relative' }}>
|
|
167
181
|
<TopHeader>
|
|
168
182
|
{!isOpenSearchBar && (
|
|
169
183
|
<>
|
|
@@ -201,13 +215,14 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
201
215
|
</WrapSearchBar>
|
|
202
216
|
)}
|
|
203
217
|
</TopHeader>
|
|
204
|
-
</
|
|
218
|
+
</Animated.View>
|
|
205
219
|
<BusinessProductsListingContainer
|
|
206
220
|
stickyHeaderIndices={[2]}
|
|
207
221
|
style={styles.mainContainer}
|
|
208
222
|
ref={scrollViewRef}
|
|
209
223
|
isActiveFloatingButtom={currentCart?.products?.length > 0 && categoryState.products.length !== 0}
|
|
210
|
-
onScroll={
|
|
224
|
+
onScroll={handlePageScroll}
|
|
225
|
+
onScrollBeginDrag={handleTouchDrag}
|
|
211
226
|
scrollEventThrottle={16}
|
|
212
227
|
>
|
|
213
228
|
<BusinessBasicInformation
|
|
@@ -232,6 +247,8 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
232
247
|
categoriesLayout={categoriesLayout}
|
|
233
248
|
selectedCategoryId={selectedCategoryId}
|
|
234
249
|
lazyLoadProductsRecommended={business?.lazy_load_products_recommended}
|
|
250
|
+
setSelectedCategoryId={setSelectedCategoryId}
|
|
251
|
+
setCategoryClicked={setCategoryClicked}
|
|
235
252
|
/>
|
|
236
253
|
)}
|
|
237
254
|
</>
|
|
@@ -203,7 +203,7 @@ export const OrdersOption = (props: OrdersOptionParams) => {
|
|
|
203
203
|
useDefualtSessionManager: true,
|
|
204
204
|
paginationSettings: {
|
|
205
205
|
initialPage: 1,
|
|
206
|
-
pageSize:
|
|
206
|
+
pageSize: 10,
|
|
207
207
|
controlType: 'infinity'
|
|
208
208
|
}
|
|
209
209
|
}
|
|
@@ -170,7 +170,7 @@ export interface BusinessProductsListingParams {
|
|
|
170
170
|
getNextProducts?: () => {};
|
|
171
171
|
handleChangeCategory: (value: any) => {};
|
|
172
172
|
setProductLogin?: () => {};
|
|
173
|
-
updateProductModal?: (value: any) => {}
|
|
173
|
+
updateProductModal?: (value: any) => {};
|
|
174
174
|
}
|
|
175
175
|
export interface BusinessBasicInformationParams {
|
|
176
176
|
navigation?: any;
|
|
@@ -193,6 +193,8 @@ export interface BusinessProductsCategoriesParams {
|
|
|
193
193
|
categoriesLayout?: any;
|
|
194
194
|
selectedCategoryId?: any;
|
|
195
195
|
lazyLoadProductsRecommended?: any;
|
|
196
|
+
setSelectedCategoryId?: any
|
|
197
|
+
setCategoryClicked?: any
|
|
196
198
|
}
|
|
197
199
|
export interface BusinessProductsListParams {
|
|
198
200
|
errors?: any;
|