ordering-ui-react-native 0.12.21 → 0.12.25
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/ActiveOrders/index.tsx +31 -14
- package/src/components/Messages/index.tsx +59 -4
- package/src/components/Messages/styles.tsx +3 -0
- package/themes/business/src/components/Chat/index.tsx +56 -8
- package/themes/business/src/components/Chat/styles.tsx +4 -0
- package/themes/doordash/src/components/Messages/index.tsx +62 -4
- package/themes/doordash/src/components/Messages/styles.tsx +2 -0
- package/themes/doordash/src/components/shared/OButton.tsx +2 -1
- package/themes/instacart/src/components/Messages/index.tsx +60 -5
- package/themes/instacart/src/components/Messages/styles.tsx +2 -0
- package/themes/kiosk/src/components/BusinessProductsListing/index.tsx +7 -1
- package/themes/kiosk/src/components/CartBottomSheet/styles.tsx +1 -1
- package/themes/kiosk/src/components/CategoriesMenu/index.tsx +8 -1
- package/themes/original/src/components/Messages/index.tsx +61 -5
- package/themes/original/src/components/Messages/styles.tsx +2 -2
- package/themes/original/src/components/ProductForm/index.tsx +40 -24
- package/themes/single-business/index.tsx +4 -0
- package/themes/single-business/src/components/AddressList/index.tsx +2 -2
- package/themes/single-business/src/components/BusinessProductsCategories/index.tsx +89 -16
- package/themes/single-business/src/components/BusinessProductsList/index.tsx +22 -8
- package/themes/single-business/src/components/BusinessProductsList/styles.tsx +1 -1
- package/themes/single-business/src/components/BusinessProductsListing/index.tsx +71 -26
- package/themes/single-business/src/components/LoginForm/index.tsx +43 -26
- package/themes/single-business/src/components/OrderListOption/index.tsx +231 -0
- package/themes/single-business/src/components/OrderListOption/styles.tsx +62 -0
- package/themes/single-business/src/components/OrdersListing/index.tsx +112 -0
- package/themes/single-business/src/components/SignupForm/index.tsx +15 -16
- package/themes/single-business/src/components/UserProfile/index.tsx +9 -3
- package/themes/single-business/src/types/index.tsx +9 -0
- package/themes/single-business/src/utils/index.tsx +32 -1
- package/themes/uber-eats/src/components/Messages/index.tsx +59 -4
- package/themes/uber-eats/src/components/Messages/styles.tsx +2 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react'
|
|
2
|
-
import { View, StyleSheet } from 'react-native'
|
|
1
|
+
import React, { useEffect, useState, useRef } from 'react'
|
|
2
|
+
import { View, StyleSheet, SafeAreaView } from 'react-native'
|
|
3
3
|
import { useTheme } from 'styled-components/native';
|
|
4
4
|
import {
|
|
5
5
|
BusinessAndProductList,
|
|
@@ -7,6 +7,8 @@ import {
|
|
|
7
7
|
useOrder,
|
|
8
8
|
useSession,
|
|
9
9
|
useUtils,
|
|
10
|
+
useToast,
|
|
11
|
+
ToastType
|
|
10
12
|
} from 'ordering-components/native'
|
|
11
13
|
import { OButton, OModal } from '../shared'
|
|
12
14
|
import { BusinessBasicInformation } from '../BusinessBasicInformation'
|
|
@@ -27,6 +29,8 @@ import { ProductForm } from '../ProductForm'
|
|
|
27
29
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
28
30
|
import { _setStoreData } from '../../providers/StoreUtil';
|
|
29
31
|
|
|
32
|
+
const PIXELS_TO_SCROLL = 1000
|
|
33
|
+
|
|
30
34
|
const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
31
35
|
const {
|
|
32
36
|
navigation,
|
|
@@ -41,7 +45,8 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
41
45
|
featuredProducts,
|
|
42
46
|
errorQuantityProducts,
|
|
43
47
|
header,
|
|
44
|
-
logo
|
|
48
|
+
logo,
|
|
49
|
+
getNextProducts
|
|
45
50
|
} = props
|
|
46
51
|
|
|
47
52
|
const theme = useTheme();
|
|
@@ -49,6 +54,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
49
54
|
const [{ auth }] = useSession()
|
|
50
55
|
const [orderState] = useOrder()
|
|
51
56
|
const [{ parsePrice }] = useUtils()
|
|
57
|
+
const [ ,{showToast}] = useToast()
|
|
52
58
|
const { top, bottom } = useSafeAreaInsets()
|
|
53
59
|
|
|
54
60
|
const styles = StyleSheet.create({
|
|
@@ -84,6 +90,11 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
84
90
|
const [curProduct, setCurProduct] = useState(null)
|
|
85
91
|
const [openUpselling, setOpenUpselling] = useState(false)
|
|
86
92
|
const [canOpenUpselling, setCanOpenUpselling] = useState(false)
|
|
93
|
+
const scrollViewRef = useRef<any>(null)
|
|
94
|
+
|
|
95
|
+
const [categoriesLayout, setCategoriesLayout] = useState<any>({})
|
|
96
|
+
const [productListLayout, setProductListLayout] = useState<any>(null)
|
|
97
|
+
const [selectedCategoryId, setSelectedCategoryId] = useState<any>(null)
|
|
87
98
|
|
|
88
99
|
const currentCart: any = Object.values(orderState.carts).find((cart: any) => cart?.business?.slug === business?.slug) ?? {}
|
|
89
100
|
|
|
@@ -122,6 +133,28 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
122
133
|
setOpenUpselling(false)
|
|
123
134
|
}
|
|
124
135
|
|
|
136
|
+
const handleScroll = ({ nativeEvent }: any) => {
|
|
137
|
+
const scrollOffset = nativeEvent.contentOffset.y
|
|
138
|
+
if (businessState?.business?.lazy_load_products_recommended) {
|
|
139
|
+
const height = nativeEvent.contentSize.height
|
|
140
|
+
const hasMore = !(categoryState.pagination.totalPages === categoryState.pagination.currentPage)
|
|
141
|
+
if (scrollOffset + PIXELS_TO_SCROLL > height && !loading && hasMore && getNextProducts) {
|
|
142
|
+
getNextProducts()
|
|
143
|
+
showToast(ToastType.Info, t('LOADING_MORE_PRODUCTS', 'Loading more products'))
|
|
144
|
+
}
|
|
145
|
+
} else {
|
|
146
|
+
if (!scrollOffset || !categoriesLayout || !productListLayout) return
|
|
147
|
+
for (const key in categoriesLayout) {
|
|
148
|
+
const categoryOffset = categoriesLayout[key].y + productListLayout?.y - 70
|
|
149
|
+
if (categoryOffset - 50 <= scrollOffset && scrollOffset <= categoryOffset + 50) {
|
|
150
|
+
if (selectedCategoryId !== key) {
|
|
151
|
+
setSelectedCategoryId(key)
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
125
158
|
useEffect(() => {
|
|
126
159
|
if (!orderState.loading) {
|
|
127
160
|
handleCloseProductModal()
|
|
@@ -131,16 +164,23 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
131
164
|
useEffect(() => {
|
|
132
165
|
if (businessState?.business?.logo) {
|
|
133
166
|
_setStoreData('b_logo', {businessLogo: businessState.business?.logo});
|
|
134
|
-
} else {
|
|
135
|
-
console.log('logo undefined!!')
|
|
136
167
|
}
|
|
137
168
|
}, [businessState])
|
|
138
169
|
|
|
139
170
|
return (
|
|
140
|
-
|
|
141
|
-
|
|
171
|
+
<SafeAreaView
|
|
172
|
+
style={{ flex: 1 }}
|
|
173
|
+
>
|
|
174
|
+
<BusinessProductsListingContainer
|
|
175
|
+
stickyHeaderIndices={[2]}
|
|
176
|
+
style={styles.mainContainer}
|
|
177
|
+
ref={scrollViewRef}
|
|
178
|
+
isActiveFloatingButtom={currentCart?.products?.length > 0 && categoryState.products.length !== 0}
|
|
179
|
+
onScroll={(e: any) => handleScroll(e)}
|
|
180
|
+
scrollEventThrottle={16}
|
|
181
|
+
>
|
|
142
182
|
<WrapHeader>
|
|
143
|
-
{!auth &&
|
|
183
|
+
{!auth &&
|
|
144
184
|
<TopHeader style={{top: top}}>
|
|
145
185
|
<OButton
|
|
146
186
|
imgLeftSrc={theme.images.general.arrow_left}
|
|
@@ -173,14 +213,30 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
173
213
|
</WrapSearchBar>
|
|
174
214
|
{!(business?.categories?.length === 0) && (
|
|
175
215
|
<BusinessProductsCategories
|
|
176
|
-
categories={[
|
|
216
|
+
categories={[
|
|
217
|
+
{ id: null, name: t('ALL', 'All') },
|
|
218
|
+
{ id: 'featured', name: t('FEATURED', 'Featured') },
|
|
219
|
+
...business?.categories?.sort((a: any, b: any) => a.rank - b.rank)
|
|
220
|
+
]}
|
|
177
221
|
categorySelected={categorySelected}
|
|
178
222
|
onClickCategory={handleChangeCategory}
|
|
179
223
|
featured={featuredProducts}
|
|
180
224
|
openBusinessInformation={openBusinessInformation}
|
|
225
|
+
scrollViewRef={scrollViewRef}
|
|
226
|
+
productListLayout={productListLayout}
|
|
227
|
+
categoriesLayout={categoriesLayout}
|
|
228
|
+
selectedCategoryId={selectedCategoryId}
|
|
229
|
+
setSelectedCategoryId={setSelectedCategoryId}
|
|
230
|
+
lazyLoadProductsRecommended={business?.lazy_load_products_recommended}
|
|
181
231
|
/>
|
|
182
232
|
)}
|
|
183
|
-
|
|
233
|
+
</>
|
|
234
|
+
)}
|
|
235
|
+
{!loading && business?.id && (
|
|
236
|
+
<>
|
|
237
|
+
<WrapContent
|
|
238
|
+
onLayout={(event: any) => setProductListLayout(event.nativeEvent.layout)}
|
|
239
|
+
>
|
|
184
240
|
<BusinessProductsList
|
|
185
241
|
categories={[
|
|
186
242
|
{ id: null, name: t('ALL', 'All') },
|
|
@@ -198,10 +254,12 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
198
254
|
handleClearSearch={handleChangeSearch}
|
|
199
255
|
errorQuantityProducts={errorQuantityProducts}
|
|
200
256
|
handleCancelSearch={handleCancel}
|
|
257
|
+
categoriesLayout={categoriesLayout}
|
|
258
|
+
setCategoriesLayout={setCategoriesLayout}
|
|
201
259
|
/>
|
|
202
260
|
</WrapContent>
|
|
203
|
-
|
|
204
|
-
|
|
261
|
+
</>
|
|
262
|
+
)}
|
|
205
263
|
{loading && !error && (
|
|
206
264
|
<>
|
|
207
265
|
<BusinessProductsCategories
|
|
@@ -256,20 +314,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
256
314
|
onSave={handlerProductAction}
|
|
257
315
|
/>
|
|
258
316
|
</OModal>
|
|
259
|
-
|
|
260
|
-
<UpsellingProducts
|
|
261
|
-
businessId={currentCart?.business_id}
|
|
262
|
-
business={currentCart?.business}
|
|
263
|
-
cartProducts={currentCart?.products}
|
|
264
|
-
cart={currentCart}
|
|
265
|
-
handleUpsellingPage={handleUpsellingPage}
|
|
266
|
-
handleCloseUpsellingPage={handleCloseUpsellingPage}
|
|
267
|
-
openUpselling={openUpselling}
|
|
268
|
-
canOpenUpselling={canOpenUpselling}
|
|
269
|
-
setCanOpenUpselling={setCanOpenUpselling}
|
|
270
|
-
/>
|
|
271
|
-
)} */}
|
|
272
|
-
</>
|
|
317
|
+
</SafeAreaView>
|
|
273
318
|
)
|
|
274
319
|
}
|
|
275
320
|
|
|
@@ -136,6 +136,10 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
136
136
|
fontWeight: 'normal',
|
|
137
137
|
fontSize: 16,
|
|
138
138
|
},
|
|
139
|
+
linkTxt: {
|
|
140
|
+
flexDirection: 'row',
|
|
141
|
+
justifyContent: 'center',
|
|
142
|
+
}
|
|
139
143
|
});
|
|
140
144
|
|
|
141
145
|
const inputRef = useRef<any>({});
|
|
@@ -425,6 +429,15 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
425
429
|
}}
|
|
426
430
|
defaultValue=""
|
|
427
431
|
/>
|
|
432
|
+
|
|
433
|
+
{onNavigationRedirect && forgotButtonText && (
|
|
434
|
+
<Pressable onPress={() => onNavigationRedirect('Forgot')}>
|
|
435
|
+
<OText size={14} mBottom={18}>
|
|
436
|
+
{forgotButtonText}
|
|
437
|
+
</OText>
|
|
438
|
+
</Pressable>
|
|
439
|
+
)}
|
|
440
|
+
|
|
428
441
|
<OButton
|
|
429
442
|
onClick={handleSubmit(onSubmit)}
|
|
430
443
|
text={loginButtonText}
|
|
@@ -438,13 +451,18 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
438
451
|
</FormInput>
|
|
439
452
|
)}
|
|
440
453
|
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
454
|
+
{onNavigationRedirect && registerButtonText && (
|
|
455
|
+
<View style={loginStyle.linkTxt}>
|
|
456
|
+
<OText size={14} space>
|
|
457
|
+
{t('NEW_ON_PLATFORM', 'New on Ordering?')}
|
|
458
|
+
</OText>
|
|
459
|
+
<Pressable onPress={() => onNavigationRedirect('Signup')}>
|
|
460
|
+
<OText size={14} color={theme.colors.primary}>
|
|
461
|
+
{registerButtonText}
|
|
462
|
+
</OText>
|
|
463
|
+
</Pressable>
|
|
464
|
+
</View>
|
|
465
|
+
)}
|
|
448
466
|
|
|
449
467
|
{useLoginByCellphone &&
|
|
450
468
|
loginTab === 'cellphone' &&
|
|
@@ -453,13 +471,24 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
453
471
|
(configs?.twilio_service_enabled?.value === 'true' ||
|
|
454
472
|
configs?.twilio_service_enabled?.value === '1') && (
|
|
455
473
|
<>
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
474
|
+
<View
|
|
475
|
+
style={{
|
|
476
|
+
flexDirection: 'row',
|
|
477
|
+
width: '100%',
|
|
478
|
+
justifyContent: 'space-between',
|
|
479
|
+
alignItems: 'center',
|
|
480
|
+
marginVertical: 30
|
|
481
|
+
}}>
|
|
482
|
+
<View style={loginStyle.line} />
|
|
483
|
+
<OText
|
|
484
|
+
size={14}
|
|
485
|
+
mBottom={10}
|
|
486
|
+
style={{ paddingHorizontal: 19 }}
|
|
487
|
+
color={theme.colors.disabled}>
|
|
488
|
+
{t('OR', 'or')}
|
|
489
|
+
</OText>
|
|
490
|
+
<View style={loginStyle.line} />
|
|
491
|
+
</View>
|
|
463
492
|
|
|
464
493
|
<ButtonsWrapper mBottom={20}>
|
|
465
494
|
<OButton
|
|
@@ -533,18 +562,6 @@ const LoginFormUI = (props: LoginParams) => {
|
|
|
533
562
|
</Placeholder>
|
|
534
563
|
</SkeletonWrapper>
|
|
535
564
|
)}
|
|
536
|
-
|
|
537
|
-
{/* {onNavigationRedirect && registerButtonText && (
|
|
538
|
-
<ButtonsWrapper>
|
|
539
|
-
<OButton
|
|
540
|
-
onClick={() => onNavigationRedirect('Signup')}
|
|
541
|
-
text={registerButtonText}
|
|
542
|
-
style={loginStyle.btnOutline}
|
|
543
|
-
borderColor={theme.colors.primary}
|
|
544
|
-
imgRightSrc={null}
|
|
545
|
-
/>
|
|
546
|
-
</ButtonsWrapper>
|
|
547
|
-
)} */}
|
|
548
565
|
</FormSide>
|
|
549
566
|
<OModal open={isModalVisible} onClose={() => setIsModalVisible(false)}>
|
|
550
567
|
<VerifyPhone
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { StyleSheet, TouchableOpacity, View } from 'react-native';
|
|
3
|
+
import { useLanguage, useUtils } from 'ordering-components/native';
|
|
4
|
+
import {
|
|
5
|
+
OrdersContainer,
|
|
6
|
+
Card,
|
|
7
|
+
Information,
|
|
8
|
+
OrderInformation,
|
|
9
|
+
BusinessInformation,
|
|
10
|
+
Price,
|
|
11
|
+
OptionTitle,
|
|
12
|
+
Status,
|
|
13
|
+
} from './styles';
|
|
14
|
+
|
|
15
|
+
import { useTheme } from 'styled-components/native';
|
|
16
|
+
import { getTextOrderStatus } from '../../utils';
|
|
17
|
+
import { OButton, OText } from '../shared'
|
|
18
|
+
|
|
19
|
+
export const OrderListOption = (props: any) => {
|
|
20
|
+
const {
|
|
21
|
+
orders,
|
|
22
|
+
titleContent,
|
|
23
|
+
typeStyle,
|
|
24
|
+
allowedOrderStatus,
|
|
25
|
+
isLoadingReorder,
|
|
26
|
+
handleReorder,
|
|
27
|
+
onNavigationRedirect,
|
|
28
|
+
} = props;
|
|
29
|
+
|
|
30
|
+
const theme = useTheme();
|
|
31
|
+
const [, t] = useLanguage();
|
|
32
|
+
const [{ parseDate, parsePrice }] = useUtils();
|
|
33
|
+
|
|
34
|
+
const [reorderSelected, setReorderSelected] = useState<number | null>(null);
|
|
35
|
+
const [isReviewedOrders, setIsReviewedOrders] = useState<Array<any>>([])
|
|
36
|
+
|
|
37
|
+
const handleClickCard = (uuid: string) => {
|
|
38
|
+
onNavigationRedirect &&
|
|
39
|
+
onNavigationRedirect('OrderDetails', { orderId: uuid });
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const handleReviewState = (orderId: any) => {
|
|
43
|
+
if (!orderId || isReviewedOrders.includes(orderId)) return
|
|
44
|
+
setIsReviewedOrders([...isReviewedOrders, orderId])
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const handleClickOrderReview = (order: any) => {
|
|
48
|
+
onNavigationRedirect &&
|
|
49
|
+
onNavigationRedirect('ReviewOrder', {
|
|
50
|
+
order: {
|
|
51
|
+
id: order?.id,
|
|
52
|
+
business_id: order?.business_id,
|
|
53
|
+
logo: order.business?.logo,
|
|
54
|
+
driver: order?.driver,
|
|
55
|
+
products: order?.products,
|
|
56
|
+
review: order?.review,
|
|
57
|
+
user_review: order?.user_review
|
|
58
|
+
},
|
|
59
|
+
handleReviewState: handleReviewState
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const handleReorderClick = (id: number) => {
|
|
64
|
+
setReorderSelected(id);
|
|
65
|
+
handleReorder(id);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const styles = StyleSheet.create({
|
|
69
|
+
reorderbutton: {
|
|
70
|
+
height: 23,
|
|
71
|
+
paddingLeft: 10,
|
|
72
|
+
paddingRight: 10,
|
|
73
|
+
borderRadius: 23,
|
|
74
|
+
shadowOpacity: 0,
|
|
75
|
+
backgroundColor: theme.colors.primaryContrast,
|
|
76
|
+
borderWidth: 0,
|
|
77
|
+
width: 80
|
|
78
|
+
},
|
|
79
|
+
reorderLoading: {
|
|
80
|
+
width: 80,
|
|
81
|
+
height: 23,
|
|
82
|
+
borderRadius: 23,
|
|
83
|
+
paddingHorizontal: 10,
|
|
84
|
+
},
|
|
85
|
+
reviewButton: {
|
|
86
|
+
width: 80,
|
|
87
|
+
height: 23,
|
|
88
|
+
maxHeight: 23,
|
|
89
|
+
backgroundColor: theme.colors.white,
|
|
90
|
+
alignItems: 'center',
|
|
91
|
+
justifyContent: 'center',
|
|
92
|
+
paddingHorizontal: 10,
|
|
93
|
+
borderRadius: 23,
|
|
94
|
+
borderWidth: 1,
|
|
95
|
+
borderColor: theme.colors.primaryContrast,
|
|
96
|
+
},
|
|
97
|
+
buttonText: {
|
|
98
|
+
color: theme.colors.primary,
|
|
99
|
+
fontSize: 10,
|
|
100
|
+
marginLeft: 2,
|
|
101
|
+
marginRight: 2,
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
const OrderStyleOne = ({ order }: any) => (
|
|
106
|
+
<Card
|
|
107
|
+
activeOpacity={1}
|
|
108
|
+
onPress={() => handleClickCard(order?.uuid)}
|
|
109
|
+
>
|
|
110
|
+
<Information>
|
|
111
|
+
<OrderInformation>
|
|
112
|
+
<BusinessInformation>
|
|
113
|
+
<OText size={12} lineHeight={18} weight={600} numberOfLines={1} ellipsizeMode={'tail'}>
|
|
114
|
+
{`${t('ORDER_NO', 'Order No')}.${order.id}`}
|
|
115
|
+
</OText>
|
|
116
|
+
<OText size={10} lineHeight={21} color={theme.colors.textSecondary}>
|
|
117
|
+
{order?.delivery_datetime_utc
|
|
118
|
+
? parseDate(order?.delivery_datetime_utc)
|
|
119
|
+
: parseDate(order?.delivery_datetime, { utc: false })}
|
|
120
|
+
</OText>
|
|
121
|
+
<OText
|
|
122
|
+
color={theme.colors.primary}
|
|
123
|
+
size={10}
|
|
124
|
+
lineHeight={15}
|
|
125
|
+
weight={400}
|
|
126
|
+
numberOfLines={2}>
|
|
127
|
+
{getTextOrderStatus(order.status, t)?.value}
|
|
128
|
+
</OText>
|
|
129
|
+
</BusinessInformation>
|
|
130
|
+
<Price>
|
|
131
|
+
<OText size={12} lineHeight={18}>
|
|
132
|
+
{parsePrice(order?.summary?.total || order?.total)}
|
|
133
|
+
</OText>
|
|
134
|
+
</Price>
|
|
135
|
+
</OrderInformation>
|
|
136
|
+
</Information>
|
|
137
|
+
</Card>
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
const OrderStyleTwo = ({ order }: any) => (
|
|
141
|
+
<TouchableOpacity
|
|
142
|
+
onPress={() => handleClickCard(order?.uuid)}
|
|
143
|
+
activeOpacity={1}
|
|
144
|
+
style={{ flexDirection: 'row' }}
|
|
145
|
+
>
|
|
146
|
+
<Card themetwo>
|
|
147
|
+
<Information themetwo>
|
|
148
|
+
<OText size={12} lineHeight={18} weight={'600'} numberOfLines={1} ellipsizeMode={'tail'}>
|
|
149
|
+
{`${t('ORDER_NO', 'Order No')}.${order.id}`}
|
|
150
|
+
</OText>
|
|
151
|
+
<OText
|
|
152
|
+
size={10}
|
|
153
|
+
lineHeight={21}
|
|
154
|
+
color={theme.colors.textSecondary}
|
|
155
|
+
style={{ marginVertical: 3 }}
|
|
156
|
+
numberOfLines={1}>
|
|
157
|
+
{order?.delivery_datetime_utc
|
|
158
|
+
? parseDate(order?.delivery_datetime_utc)
|
|
159
|
+
: parseDate(order?.delivery_datetime, { utc: false })}
|
|
160
|
+
</OText>
|
|
161
|
+
<OText
|
|
162
|
+
color={theme.colors.primary}
|
|
163
|
+
size={10}
|
|
164
|
+
lineHeight={15}
|
|
165
|
+
numberOfLines={1}>
|
|
166
|
+
{getTextOrderStatus(order.status, t)?.value}
|
|
167
|
+
</OText>
|
|
168
|
+
</Information>
|
|
169
|
+
<Status>
|
|
170
|
+
<OButton
|
|
171
|
+
text={t('REORDER', 'Reorder')}
|
|
172
|
+
imgRightSrc={''}
|
|
173
|
+
textStyle={styles.buttonText}
|
|
174
|
+
style={
|
|
175
|
+
isLoadingReorder && order.id === reorderSelected
|
|
176
|
+
? styles.reorderLoading
|
|
177
|
+
: styles.reorderbutton
|
|
178
|
+
}
|
|
179
|
+
onClick={() => handleReorderClick(order.id)}
|
|
180
|
+
isLoading={isLoadingReorder && order.id === reorderSelected}
|
|
181
|
+
/>
|
|
182
|
+
{allowedOrderStatus.includes(parseInt(order?.status)) &&
|
|
183
|
+
!order.review && !isReviewedOrders.includes(order?.id) &&
|
|
184
|
+
(
|
|
185
|
+
<TouchableOpacity
|
|
186
|
+
onPress={() => handleClickOrderReview(order)}
|
|
187
|
+
style={styles.reviewButton}>
|
|
188
|
+
<OText size={10} color={theme.colors.primary} numberOfLines={1}>
|
|
189
|
+
{t('REVIEW', 'Review')}
|
|
190
|
+
</OText>
|
|
191
|
+
</TouchableOpacity>
|
|
192
|
+
)}
|
|
193
|
+
</Status>
|
|
194
|
+
</Card>
|
|
195
|
+
</TouchableOpacity>
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
return (
|
|
199
|
+
<>
|
|
200
|
+
<OptionTitle>
|
|
201
|
+
<OText
|
|
202
|
+
size={16}
|
|
203
|
+
color={theme.colors.textPrimary}
|
|
204
|
+
mBottom={10}
|
|
205
|
+
>
|
|
206
|
+
{titleContent}
|
|
207
|
+
</OText>
|
|
208
|
+
</OptionTitle>
|
|
209
|
+
<OrdersContainer>
|
|
210
|
+
{orders.length > 0 &&
|
|
211
|
+
orders.map((order: any, index: any) => (
|
|
212
|
+
<React.Fragment key={order?.id || order?.uuid}>
|
|
213
|
+
{typeStyle === 1 && (
|
|
214
|
+
<OrderStyleOne order={order} />
|
|
215
|
+
)}
|
|
216
|
+
{typeStyle === 2 && (
|
|
217
|
+
<OrderStyleTwo order={order} />
|
|
218
|
+
)}
|
|
219
|
+
</React.Fragment>
|
|
220
|
+
))}
|
|
221
|
+
</OrdersContainer>
|
|
222
|
+
<View
|
|
223
|
+
style={{
|
|
224
|
+
height: 8,
|
|
225
|
+
backgroundColor: theme.colors.backgroundGray100,
|
|
226
|
+
marginBottom: 10
|
|
227
|
+
}}
|
|
228
|
+
/>
|
|
229
|
+
</>
|
|
230
|
+
);
|
|
231
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import styled, { css } from 'styled-components/native'
|
|
2
|
+
|
|
3
|
+
export const OrdersContainer = styled.View`
|
|
4
|
+
margin-bottom: 10px;
|
|
5
|
+
`
|
|
6
|
+
|
|
7
|
+
export const Card = styled.TouchableOpacity`
|
|
8
|
+
${(props: any) => props.themetwo ? css`
|
|
9
|
+
padding-vertical: 5px;
|
|
10
|
+
margin-bottom: 12px;
|
|
11
|
+
flex-direction: row;
|
|
12
|
+
width: 100%;
|
|
13
|
+
` : css`
|
|
14
|
+
flex: 1;
|
|
15
|
+
`};
|
|
16
|
+
`
|
|
17
|
+
|
|
18
|
+
export const Map = styled.View`
|
|
19
|
+
flex: 1;
|
|
20
|
+
height: 125px;
|
|
21
|
+
margin-bottom: 22px;
|
|
22
|
+
`
|
|
23
|
+
|
|
24
|
+
export const Information = styled.View`
|
|
25
|
+
${(props: any) => props.themetwo ? css`
|
|
26
|
+
justify-content: center;
|
|
27
|
+
align-items: flex-start;
|
|
28
|
+
margin-end: 7px;
|
|
29
|
+
flex: 1;
|
|
30
|
+
` : css`
|
|
31
|
+
flex-direction: row;
|
|
32
|
+
align-items: center;
|
|
33
|
+
padding-vertical: 5px;
|
|
34
|
+
margin-bottom: 12px;
|
|
35
|
+
`};
|
|
36
|
+
`
|
|
37
|
+
|
|
38
|
+
export const OrderInformation = styled.View`
|
|
39
|
+
flex-direction: row;
|
|
40
|
+
justify-content: space-between;
|
|
41
|
+
flex: 1;
|
|
42
|
+
`
|
|
43
|
+
|
|
44
|
+
export const BusinessInformation = styled.View`
|
|
45
|
+
flex-basis: 65%;
|
|
46
|
+
`
|
|
47
|
+
|
|
48
|
+
export const Price = styled.View`
|
|
49
|
+
justify-content: flex-start;
|
|
50
|
+
align-items: flex-end;
|
|
51
|
+
margin-left: 10px;
|
|
52
|
+
width: 30%;
|
|
53
|
+
`
|
|
54
|
+
|
|
55
|
+
export const OptionTitle = styled.View`
|
|
56
|
+
margin-top: 10px;
|
|
57
|
+
`
|
|
58
|
+
|
|
59
|
+
export const Status = styled.View`
|
|
60
|
+
align-items: center;
|
|
61
|
+
justify-content: space-between;
|
|
62
|
+
`
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { View, useWindowDimensions } from 'react-native'
|
|
3
|
+
import { useTheme } from 'styled-components/native'
|
|
4
|
+
import { useLanguage, OrderVerticalList } from 'ordering-components/native'
|
|
5
|
+
import { Placeholder, PlaceholderLine, Fade } from "rn-placeholder";
|
|
6
|
+
import { OButton, OText } from '../shared'
|
|
7
|
+
import { NotFoundSource } from '../NotFoundSource'
|
|
8
|
+
import { OrderListOption } from '../OrderListOption'
|
|
9
|
+
|
|
10
|
+
const OrdersListingUI = (props: any) => {
|
|
11
|
+
const {
|
|
12
|
+
ordersGroup,
|
|
13
|
+
reorderLoading,
|
|
14
|
+
loadMoreOrders,
|
|
15
|
+
handleReorder,
|
|
16
|
+
onNavigationRedirect,
|
|
17
|
+
} = props
|
|
18
|
+
|
|
19
|
+
const theme = useTheme()
|
|
20
|
+
const [, t] = useLanguage()
|
|
21
|
+
const { height } = useWindowDimensions()
|
|
22
|
+
|
|
23
|
+
const imageFails = theme.images.general.emptyActiveOrders
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<>
|
|
27
|
+
<OText size={20} style={{ marginTop: 20 }}>
|
|
28
|
+
{t('MY_ORDERS', 'My Orders')}
|
|
29
|
+
</OText>
|
|
30
|
+
|
|
31
|
+
{!ordersGroup.error && ordersGroup.all?.orders?.length > 0 && (
|
|
32
|
+
<>
|
|
33
|
+
{ordersGroup.upcoming?.orders?.length > 0 && (
|
|
34
|
+
<OrderListOption
|
|
35
|
+
titleContent={t('UPCOMING', 'Upcoming')}
|
|
36
|
+
typeStyle={1}
|
|
37
|
+
orders={ordersGroup.upcoming?.orders}
|
|
38
|
+
onNavigationRedirect={onNavigationRedirect}
|
|
39
|
+
/>
|
|
40
|
+
)}
|
|
41
|
+
{ordersGroup.active?.orders?.length > 0 && (
|
|
42
|
+
<OrderListOption
|
|
43
|
+
titleContent={t('ACTIVE', 'Active')}
|
|
44
|
+
typeStyle={1}
|
|
45
|
+
orders={ordersGroup.active?.orders}
|
|
46
|
+
onNavigationRedirect={onNavigationRedirect}
|
|
47
|
+
/>
|
|
48
|
+
)}
|
|
49
|
+
{ordersGroup.past?.orders?.length > 0 && (
|
|
50
|
+
<OrderListOption
|
|
51
|
+
titleContent={t('PAST', 'Past')}
|
|
52
|
+
typeStyle={2}
|
|
53
|
+
orders={ordersGroup.past?.orders}
|
|
54
|
+
allowedOrderStatus={[1, 2, 5, 6, 10, 11, 12]}
|
|
55
|
+
isLoadingReorder={reorderLoading}
|
|
56
|
+
handleReorder={handleReorder}
|
|
57
|
+
onNavigationRedirect={onNavigationRedirect}
|
|
58
|
+
/>
|
|
59
|
+
)}
|
|
60
|
+
{!ordersGroup.loading &&
|
|
61
|
+
ordersGroup?.pagination?.totalPages &&
|
|
62
|
+
ordersGroup?.pagination?.currentPage < ordersGroup?.pagination?.totalPages &&
|
|
63
|
+
(
|
|
64
|
+
<View>
|
|
65
|
+
<OButton
|
|
66
|
+
text={t('LOAD_MORE_ORDERS', 'Load more orders')}
|
|
67
|
+
imgRightSrc={null}
|
|
68
|
+
textStyle={{ color: theme.colors.white }}
|
|
69
|
+
style={{ borderRadius: 8, shadowOpacity: 0, marginTop: 20 }}
|
|
70
|
+
onClick={loadMoreOrders}
|
|
71
|
+
/>
|
|
72
|
+
</View>
|
|
73
|
+
)}
|
|
74
|
+
</>
|
|
75
|
+
)}
|
|
76
|
+
|
|
77
|
+
{ordersGroup.loading && (
|
|
78
|
+
<View style={{ marginTop: 20 }}>
|
|
79
|
+
{[...Array(6)].map((_, i) => (
|
|
80
|
+
<Placeholder key={i} Animation={Fade}>
|
|
81
|
+
<View style={{ width: '100%', flexDirection: 'row' }}>
|
|
82
|
+
<PlaceholderLine width={20} height={70} style={{ marginRight: 20, marginBottom: 20 }} />
|
|
83
|
+
<Placeholder>
|
|
84
|
+
<PlaceholderLine width={30} style={{ marginTop: 5 }} />
|
|
85
|
+
<PlaceholderLine width={50} />
|
|
86
|
+
<PlaceholderLine width={20} />
|
|
87
|
+
</Placeholder>
|
|
88
|
+
</View>
|
|
89
|
+
</Placeholder>
|
|
90
|
+
))}
|
|
91
|
+
</View>
|
|
92
|
+
)}
|
|
93
|
+
|
|
94
|
+
{!ordersGroup.loading && ordersGroup.all?.orders?.length === 0 && (
|
|
95
|
+
<View style={{ height: height * 0.7, justifyContent: 'center' }}>
|
|
96
|
+
<NotFoundSource
|
|
97
|
+
content={t('NO_RESULTS_FOUND', 'Sorry, no results found')}
|
|
98
|
+
image={imageFails}
|
|
99
|
+
/>
|
|
100
|
+
</View>
|
|
101
|
+
)}
|
|
102
|
+
</>
|
|
103
|
+
)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export const OrdersListing = (props: any) => {
|
|
107
|
+
const ordersProps = {
|
|
108
|
+
...props,
|
|
109
|
+
UIComponent: OrdersListingUI,
|
|
110
|
+
}
|
|
111
|
+
return <OrderVerticalList {...ordersProps} />
|
|
112
|
+
}
|