ordering-ui-react-native 0.16.53 → 0.16.56
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/DriverSchedule/index.tsx +36 -19
- package/themes/business/src/components/PreviousOrders/index.tsx +2 -2
- package/themes/business/src/components/ScheduleBlocked/index.tsx +2 -2
- package/themes/original/index.tsx +0 -6
- package/themes/original/src/components/AddressForm/index.tsx +6 -5
- package/themes/original/src/components/BusinessController/index.tsx +116 -78
- package/themes/original/src/components/BusinessListingSearch/index.tsx +9 -3
- package/themes/original/src/components/BusinessProductsListing/index.tsx +9 -6
- package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +26 -28
- package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +13 -11
- package/themes/original/src/components/BusinessesListing/index.tsx +35 -62
- package/themes/original/src/components/Checkout/index.tsx +1 -1
- package/themes/original/src/components/OrderDetails/index.tsx +50 -37
- package/themes/original/src/components/ProductForm/index.tsx +1 -1
- package/themes/original/src/components/ProductForm/styles.tsx +1 -1
- package/themes/original/src/components/ReviewOrder/index.tsx +79 -99
- package/themes/original/src/components/ReviewOrder/styles.tsx +0 -9
- package/themes/original/src/components/ReviewTrigger/index.tsx +118 -0
- package/themes/original/src/components/{Reviews/ReviewOrder → ReviewTrigger}/styles.tsx +2 -21
- package/themes/original/src/components/SingleProductCard/index.tsx +132 -110
- package/themes/original/src/components/shared/OBottomPopup.tsx +5 -2
- package/themes/original/src/types/index.tsx +2 -5
- package/themes/original/src/components/Reviews/ReviewDriver/index.tsx +0 -301
- package/themes/original/src/components/Reviews/ReviewDriver/styles.tsx +0 -39
- package/themes/original/src/components/Reviews/ReviewOrder/index.tsx +0 -326
- package/themes/original/src/components/Reviews/ReviewProducts/index.tsx +0 -101
- package/themes/original/src/components/Reviews/ReviewProducts/styles.tsx +0 -17
- package/themes/original/src/components/Reviews/index.tsx +0 -9
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
2
|
import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
|
|
3
3
|
import Geolocation from '@react-native-community/geolocation'
|
|
4
|
+
import { IOScrollView } from 'react-native-intersection-observer'
|
|
4
5
|
import { getTrackingStatus, requestTrackingPermission } from 'react-native-tracking-transparency'
|
|
5
6
|
import {
|
|
6
7
|
View,
|
|
@@ -201,7 +202,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
|
|
|
201
202
|
}
|
|
202
203
|
|
|
203
204
|
const resetInactivityTimeout = () => {
|
|
204
|
-
if(!logosLayout){
|
|
205
|
+
if (!logosLayout) {
|
|
205
206
|
clearTimeout(timerId.current)
|
|
206
207
|
timerId.current = setInterval(() => {
|
|
207
208
|
getBusinesses(true)
|
|
@@ -247,7 +248,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
|
|
|
247
248
|
}
|
|
248
249
|
|
|
249
250
|
useEffect(() => {
|
|
250
|
-
if(!logosLayout){
|
|
251
|
+
if (!logosLayout) {
|
|
251
252
|
checkUserLocation()
|
|
252
253
|
}
|
|
253
254
|
}, [orderState?.options?.address?.location])
|
|
@@ -284,11 +285,11 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
|
|
|
284
285
|
return (
|
|
285
286
|
<BusinessLogosContainer horizontal>
|
|
286
287
|
{businessesList?.loading ? (
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
288
|
+
<Placeholder Animation={Fade}>
|
|
289
|
+
{[...Array(10).keys()].map(item => (
|
|
290
|
+
<PlaceholderLine key={item} width={56} height={56} />
|
|
291
|
+
))}
|
|
292
|
+
</Placeholder>
|
|
292
293
|
) : (
|
|
293
294
|
<>
|
|
294
295
|
{businessesList.businesses
|
|
@@ -315,7 +316,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
|
|
|
315
316
|
}
|
|
316
317
|
|
|
317
318
|
return (
|
|
318
|
-
<
|
|
319
|
+
<IOScrollView style={styles.container} onScroll={(e) => handleScroll(e)} showsVerticalScrollIndicator={false}
|
|
319
320
|
refreshControl={
|
|
320
321
|
<RefreshControl
|
|
321
322
|
refreshing={refreshing}
|
|
@@ -478,7 +479,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
|
|
|
478
479
|
<View style={{ marginTop: 10 }}>
|
|
479
480
|
<OButton
|
|
480
481
|
onClick={() => setIsOpenCities(true)}
|
|
481
|
-
text={citiesState?.cities?.find((city
|
|
482
|
+
text={citiesState?.cities?.find((city: any) => city?.id === orderState?.options?.city_id)?.name || t('FILTER_BY_CITY', 'Filter by city')}
|
|
482
483
|
style={styles?.buttonCityStyle}
|
|
483
484
|
textStyle={{ color: theme.colors.backgroundGray, fontWeight: 'bold', fontSize: 18 }}
|
|
484
485
|
/>
|
|
@@ -556,6 +557,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
|
|
|
556
557
|
(business: any, i: number) => (
|
|
557
558
|
<BusinessController
|
|
558
559
|
key={`${business.id}_` + i}
|
|
560
|
+
enableIntersection
|
|
559
561
|
business={business}
|
|
560
562
|
isBusinessOpen={business.open}
|
|
561
563
|
handleCustomClick={handleBusinessClick}
|
|
@@ -633,7 +635,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
|
|
|
633
635
|
title={t('SELECT_A_CITY', 'Select a city')}
|
|
634
636
|
>
|
|
635
637
|
<View style={{ padding: 40, width: '100%' }}>
|
|
636
|
-
{citiesState?.cities?.map((city
|
|
638
|
+
{citiesState?.cities?.map((city: any) => (
|
|
637
639
|
<TouchableOpacity
|
|
638
640
|
key={city?.id}
|
|
639
641
|
style={{
|
|
@@ -652,7 +654,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
|
|
|
652
654
|
))}
|
|
653
655
|
</View>
|
|
654
656
|
</OModal>
|
|
655
|
-
</
|
|
657
|
+
</IOScrollView>
|
|
656
658
|
);
|
|
657
659
|
};
|
|
658
660
|
|
|
@@ -6,84 +6,68 @@ import { useTheme } from 'styled-components/native'
|
|
|
6
6
|
import { BusinessesListing as OriginalBusinessListing } from './Layout/Original'
|
|
7
7
|
import { BusinessesListing as AppointmentBusinessListing } from './Layout/Appointment'
|
|
8
8
|
import { OBottomPopup } from '../shared';
|
|
9
|
-
import {
|
|
9
|
+
import { ReviewTrigger } from '../ReviewTrigger';
|
|
10
10
|
|
|
11
11
|
export const BusinessesListing = (props: any) => {
|
|
12
12
|
const theme = useTheme()
|
|
13
|
-
|
|
13
|
+
const layout = theme?.layouts?.business_listing_view?.components?.layout?.type || 'original'
|
|
14
14
|
const [, t] = useLanguage();
|
|
15
15
|
const [{ auth }] = useSession()
|
|
16
16
|
const [, { getLastOrderHasNoReview }] = useOrder();
|
|
17
17
|
|
|
18
|
+
const [, setIsReviewed] = useState()
|
|
19
|
+
const defaultOrder = {
|
|
20
|
+
id: 0,
|
|
21
|
+
business_id: 0,
|
|
22
|
+
business_name: '',
|
|
23
|
+
logo: '',
|
|
24
|
+
driver: {},
|
|
25
|
+
products: [],
|
|
26
|
+
review: {},
|
|
27
|
+
user_review: {},
|
|
28
|
+
delivery_datetime: ''
|
|
29
|
+
}
|
|
18
30
|
const [lastOrderReview, setLastOrderReview] = useState({
|
|
19
31
|
isReviewOpen: false,
|
|
20
|
-
order:
|
|
21
|
-
|
|
22
|
-
business_id: 0,
|
|
23
|
-
business_name: '',
|
|
24
|
-
delivery_datetime: '',
|
|
25
|
-
logo: '',
|
|
26
|
-
driver: null,
|
|
27
|
-
products: [],
|
|
28
|
-
review: null,
|
|
29
|
-
user_review: null
|
|
30
|
-
},
|
|
31
|
-
reviewStatus: { order: false, product: false, driver: false },
|
|
32
|
-
reviewed: { isOrderReviewed: false, isProductReviewed: false, isDriverReviewed: false }
|
|
32
|
+
order: defaultOrder,
|
|
33
|
+
defaultStar: 5,
|
|
33
34
|
})
|
|
34
35
|
|
|
35
36
|
const _getLastOrderHasNoReview = async () => {
|
|
36
37
|
const lastOrderHasNoReview = await getLastOrderHasNoReview()
|
|
37
|
-
lastOrderHasNoReview &&
|
|
38
|
+
lastOrderHasNoReview && OrderReviewRequired(lastOrderHasNoReview)
|
|
38
39
|
}
|
|
39
40
|
|
|
40
|
-
const
|
|
41
|
+
const OrderReviewRequired = (order: any) => {
|
|
41
42
|
setLastOrderReview({
|
|
42
43
|
isReviewOpen: true,
|
|
43
44
|
order: {
|
|
44
45
|
id: order?.id,
|
|
45
46
|
business_id: order?.business_id,
|
|
46
47
|
business_name: order?.business?.name,
|
|
47
|
-
delivery_datetime: order?.delivery_datetime,
|
|
48
48
|
logo: order.business?.logo,
|
|
49
49
|
driver: order?.driver,
|
|
50
50
|
products: order?.products,
|
|
51
51
|
review: order?.review,
|
|
52
|
-
user_review: order?.user_review
|
|
52
|
+
user_review: order?.user_review,
|
|
53
|
+
delivery_datetime: order?.delivery_datetime_utc
|
|
53
54
|
},
|
|
54
|
-
|
|
55
|
-
reviewed: { isOrderReviewed: false, isProductReviewed: false, isDriverReviewed: false }
|
|
56
|
-
})
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const handleCloseReivew = () => {
|
|
60
|
-
setLastOrderReview({
|
|
61
|
-
...lastOrderReview,
|
|
62
|
-
isReviewOpen: false,
|
|
63
|
-
reviewStatus: { order: false, product: false, driver: false }
|
|
55
|
+
defaultStar: 5
|
|
64
56
|
})
|
|
65
57
|
}
|
|
66
58
|
|
|
67
|
-
const
|
|
68
|
-
const _reviewStatus = { ...lastOrderReview?.reviewed }
|
|
59
|
+
const handleOpenOrderReview = (star: number) => {
|
|
69
60
|
setLastOrderReview({
|
|
70
|
-
...lastOrderReview,
|
|
71
|
-
reviewed: { ..._reviewStatus, [reviewType]: true }
|
|
61
|
+
...lastOrderReview, isReviewOpen: false, order: defaultOrder
|
|
72
62
|
})
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const closeReviewProduct = () => {
|
|
82
|
-
if (lastOrderReview?.order?.driver && !lastOrderReview?.order?.user_review && !lastOrderReview?.reviewed?.isDriverReviewed) setLastOrderReview({ ...lastOrderReview, reviewStatus: { order: false, product: false, driver: true } })
|
|
83
|
-
else {
|
|
84
|
-
setIsReviewed('isDriverReviewed')
|
|
85
|
-
handleCloseReivew()
|
|
86
|
-
}
|
|
63
|
+
props?.navigation && props.navigation.navigate(
|
|
64
|
+
'ReviewOrder',
|
|
65
|
+
{
|
|
66
|
+
order: lastOrderReview.order,
|
|
67
|
+
defaultStar: star || 5,
|
|
68
|
+
setIsReviewed
|
|
69
|
+
}
|
|
70
|
+
)
|
|
87
71
|
}
|
|
88
72
|
|
|
89
73
|
useEffect(() => {
|
|
@@ -98,25 +82,14 @@ export const BusinessesListing = (props: any) => {
|
|
|
98
82
|
{lastOrderReview?.isReviewOpen && (
|
|
99
83
|
<OBottomPopup
|
|
100
84
|
open={lastOrderReview?.isReviewOpen}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
? t('HEY', 'Hey! ') + t('HOW_WAS_YOUR_ORDER', 'How was your order?')
|
|
105
|
-
: (lastOrderReview?.reviewStatus?.product
|
|
106
|
-
? t('REVIEW_PRODUCT', 'Review Product')
|
|
107
|
-
: t('REVIEW_DRIVER', 'Review Driver')))
|
|
108
|
-
: t('LOADING', 'Loading...')}
|
|
85
|
+
transparent={true}
|
|
86
|
+
onClose={() => setLastOrderReview({ ...lastOrderReview, isReviewOpen: false, order: defaultOrder })}
|
|
87
|
+
title={t('HEY', 'Hey! ') + t('HOW_WAS_YOUR_ORDER', 'How was your order?')}
|
|
109
88
|
bottomContainerStyle={{ height: 'auto' }}
|
|
110
89
|
titleStyle={{ textAlign: 'center' }}
|
|
111
90
|
closeIcon={theme.images.general.close}
|
|
112
91
|
>
|
|
113
|
-
{
|
|
114
|
-
lastOrderReview?.reviewStatus?.order
|
|
115
|
-
? <ReviewOrderModal order={lastOrderReview?.order} closeReviewOrder={closeReviewOrder} skipReview={handleCloseReivew} setIsReviewed={() => setIsReviewed('isOrderReviewed')} />
|
|
116
|
-
: (lastOrderReview?.reviewStatus?.product
|
|
117
|
-
? <ReviewProductsModal order={lastOrderReview?.order} closeReviewProduct={closeReviewProduct} setIsProductReviewed={() => setIsReviewed('isProductReviewed')} />
|
|
118
|
-
: <ReviewDriverModal order={lastOrderReview?.order} closeReviewDriver={handleCloseReivew} setIsDriverReviewed={() => setIsReviewed('isDriverReviewed')} />)
|
|
119
|
-
}
|
|
92
|
+
{lastOrderReview?.order && <ReviewTrigger order={lastOrderReview?.order} handleOpenOrderReview={handleOpenOrderReview} />}
|
|
120
93
|
|
|
121
94
|
</OBottomPopup>
|
|
122
95
|
)}
|
|
@@ -217,7 +217,7 @@ const CheckoutUI = (props: any) => {
|
|
|
217
217
|
const _requiredFields: any = []
|
|
218
218
|
|
|
219
219
|
Object.values(validationFields?.fields?.checkout).map((field: any) => {
|
|
220
|
-
if (field?.required && !notFields.includes(field.code)) {
|
|
220
|
+
if (field?.required && !notFields.includes(field.code) && field?.enabled) {
|
|
221
221
|
if (!user[field?.code]) {
|
|
222
222
|
_requiredFields.push(field?.code)
|
|
223
223
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useState, useEffect } from 'react';
|
|
2
|
-
import { View, StyleSheet, BackHandler, Platform, Linking } from 'react-native';
|
|
2
|
+
import { View, StyleSheet, BackHandler, Platform, Linking, RefreshControl } from 'react-native';
|
|
3
3
|
import LinearGradient from 'react-native-linear-gradient';
|
|
4
4
|
import { _setStoreData } from '../../providers/StoreUtil';
|
|
5
5
|
import {
|
|
@@ -54,7 +54,8 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
54
54
|
driverLocation,
|
|
55
55
|
onNavigationRedirect,
|
|
56
56
|
reorderState,
|
|
57
|
-
handleReorder
|
|
57
|
+
handleReorder,
|
|
58
|
+
getOrder
|
|
58
59
|
} = props;
|
|
59
60
|
|
|
60
61
|
const theme = useTheme();
|
|
@@ -101,6 +102,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
101
102
|
const [isReviewed, setIsReviewed] = useState(false)
|
|
102
103
|
const [isOrderHistory, setIsOrderHistory] = useState(false)
|
|
103
104
|
const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, tax: null, type: '' })
|
|
105
|
+
const [refreshing] = useState(false);
|
|
104
106
|
const { order, businessData } = props.order;
|
|
105
107
|
const mapValidStatuses = [9, 19, 23]
|
|
106
108
|
|
|
@@ -361,8 +363,6 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
361
363
|
id: order?.id,
|
|
362
364
|
business_id: order?.business_id,
|
|
363
365
|
logo: order.business?.logo,
|
|
364
|
-
business_name: order?.business?.name,
|
|
365
|
-
delivery_datetime: order?.delivery_datetime,
|
|
366
366
|
driver: order?.driver,
|
|
367
367
|
products: order?.products,
|
|
368
368
|
review: order?.review,
|
|
@@ -382,6 +382,11 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
382
382
|
) && !order.review && !isReviewed && handleClickOrderReview(order)
|
|
383
383
|
}
|
|
384
384
|
|
|
385
|
+
|
|
386
|
+
const resfreshOrder = () => {
|
|
387
|
+
getOrder()
|
|
388
|
+
}
|
|
389
|
+
|
|
385
390
|
useEffect(() => {
|
|
386
391
|
const _businessId = 'businessId:' + businessData?.id
|
|
387
392
|
if (reorderState?.error) {
|
|
@@ -449,7 +454,15 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
449
454
|
}, [driverLocation]);
|
|
450
455
|
|
|
451
456
|
return (
|
|
452
|
-
<OrderDetailsContainer
|
|
457
|
+
<OrderDetailsContainer
|
|
458
|
+
keyboardShouldPersistTaps="handled"
|
|
459
|
+
refreshControl={
|
|
460
|
+
<RefreshControl
|
|
461
|
+
refreshing={refreshing}
|
|
462
|
+
onRefresh={() => resfreshOrder()}
|
|
463
|
+
/>
|
|
464
|
+
}
|
|
465
|
+
>
|
|
453
466
|
{(!order || Object.keys(order).length === 0) && (
|
|
454
467
|
<Placeholder style={{ marginTop: 30 }}>
|
|
455
468
|
<Header>
|
|
@@ -524,41 +537,41 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
524
537
|
<OrderData>
|
|
525
538
|
<View style={styles.linkWrapper}>
|
|
526
539
|
{
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
>
|
|
537
|
-
<OText
|
|
538
|
-
size={10}
|
|
539
|
-
lineHeight={15}
|
|
540
|
-
color={theme.colors.primary}
|
|
541
|
-
style={{ textDecorationLine: 'underline' }}
|
|
540
|
+
(
|
|
541
|
+
parseInt(order?.status) === 1 ||
|
|
542
|
+
parseInt(order?.status) === 11 ||
|
|
543
|
+
parseInt(order?.status) === 15
|
|
544
|
+
) && !order.review && !isReviewed && (
|
|
545
|
+
<TouchableOpacity
|
|
546
|
+
activeOpacity={0.7}
|
|
547
|
+
style={{ marginTop: 6, marginRight: 10 }}
|
|
548
|
+
onPress={() => handleClickOrderReview(order)}
|
|
542
549
|
>
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
550
|
+
<OText
|
|
551
|
+
size={10}
|
|
552
|
+
lineHeight={15}
|
|
553
|
+
color={theme.colors.primary}
|
|
554
|
+
style={{ textDecorationLine: 'underline' }}
|
|
555
|
+
>
|
|
556
|
+
{t('REVIEW_YOUR_ORDER', 'Review your order')}
|
|
557
|
+
</OText>
|
|
558
|
+
</TouchableOpacity>
|
|
559
|
+
)}
|
|
560
|
+
<TouchableOpacity
|
|
561
|
+
activeOpacity={0.7}
|
|
562
|
+
style={{ marginTop: 6 }}
|
|
563
|
+
onPress={() => setIsOrderHistory(true)}
|
|
551
564
|
|
|
565
|
+
>
|
|
566
|
+
<OText
|
|
567
|
+
size={10}
|
|
568
|
+
lineHeight={15}
|
|
569
|
+
color={theme.colors.primary}
|
|
570
|
+
style={{ textDecorationLine: 'underline', textTransform: 'capitalize' }}
|
|
552
571
|
>
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
color={theme.colors.primary}
|
|
557
|
-
style={{ textDecorationLine: 'underline', textTransform: 'capitalize' }}
|
|
558
|
-
>
|
|
559
|
-
{t('VIEW_DETAILS', 'View Details')}
|
|
560
|
-
</OText>
|
|
561
|
-
</TouchableOpacity>
|
|
572
|
+
{t('VIEW_DETAILS', 'View Details')}
|
|
573
|
+
</OText>
|
|
574
|
+
</TouchableOpacity>
|
|
562
575
|
</View>
|
|
563
576
|
|
|
564
577
|
<StaturBar>
|
|
@@ -598,7 +598,7 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
598
598
|
horizontal
|
|
599
599
|
showsHorizontalScrollIndicator={false}
|
|
600
600
|
style={{ marginBottom: 20 }}
|
|
601
|
-
contentContainerStyle={{
|
|
601
|
+
contentContainerStyle={{ paddingHorizontal: 33, backgroundColor: theme.colors.white }}
|
|
602
602
|
>
|
|
603
603
|
<TouchableOpacity
|
|
604
604
|
key={`eopt_all_0`}
|
|
@@ -84,7 +84,7 @@ export const ProductActions = styled.View`
|
|
|
84
84
|
border-top-color: ${(props: any) => props.theme.colors.border};
|
|
85
85
|
`
|
|
86
86
|
export const ExtraOptionWrap = styled.ScrollView`
|
|
87
|
-
margin-horizontal:
|
|
87
|
+
margin-horizontal: 30px;
|
|
88
88
|
`;
|
|
89
89
|
|
|
90
90
|
export const WeightUnitSwitch = styled.View`
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, { useState, useEffect } from 'react'
|
|
2
|
-
import
|
|
3
|
-
import { OrderReview as ReviewOrderController, useLanguage, useToast, ToastType, useUtils } from 'ordering-components/native'
|
|
2
|
+
import { OrderReview as ReviewOrderController, useLanguage, useToast, ToastType } from 'ordering-components/native'
|
|
4
3
|
import { useForm, Controller } from 'react-hook-form'
|
|
5
4
|
import LinearGradient from 'react-native-linear-gradient'
|
|
6
5
|
|
|
@@ -12,9 +11,7 @@ import {
|
|
|
12
11
|
ActionContainer,
|
|
13
12
|
SkipButton,
|
|
14
13
|
RatingBarContainer,
|
|
15
|
-
RatingTextContainer
|
|
16
|
-
RatingStarContainer,
|
|
17
|
-
PlacedDate
|
|
14
|
+
RatingTextContainer
|
|
18
15
|
} from './styles'
|
|
19
16
|
import { OButton, OIcon, OInput, OText } from '../shared'
|
|
20
17
|
import { TouchableOpacity, StyleSheet, View, I18nManager } from 'react-native';
|
|
@@ -91,11 +88,10 @@ export const ReviewOrderUI = (props: ReviewOrderParams) => {
|
|
|
91
88
|
const [, t] = useLanguage()
|
|
92
89
|
const [, { showToast }] = useToast()
|
|
93
90
|
const { handleSubmit, control, errors } = useForm()
|
|
94
|
-
|
|
91
|
+
|
|
95
92
|
const [alertState, setAlertState] = useState<{ open: boolean, content: Array<any>, success?: boolean }>({ open: false, content: [], success: false })
|
|
96
93
|
const [comments, setComments] = useState<Array<any>>([])
|
|
97
94
|
const [extraComment, setExtraComment] = useState('')
|
|
98
|
-
const placedOnDate = parseDate(order?.delivery_datetime, { outputFormat: 'dddd MMMM DD, YYYY' })
|
|
99
95
|
|
|
100
96
|
const onSubmit = () => {
|
|
101
97
|
if (Object.values(stars).some((value: any) => value === 0)) {
|
|
@@ -195,15 +191,14 @@ export const ReviewOrderUI = (props: ReviewOrderParams) => {
|
|
|
195
191
|
<>
|
|
196
192
|
<ReviewOrderContainer>
|
|
197
193
|
<NavBar
|
|
198
|
-
title={t('
|
|
194
|
+
title={t('REVIEW_ORDER', 'Review your Order')}
|
|
199
195
|
titleAlign={'center'}
|
|
200
|
-
leftImg={theme.images.general.close}
|
|
201
196
|
onActionLeft={() => navigation?.canGoBack() && navigation.goBack()}
|
|
202
197
|
showCall={false}
|
|
203
198
|
btnStyle={{ paddingLeft: 0 }}
|
|
204
|
-
style={{ flexDirection: 'column', alignItems: 'flex-start'
|
|
205
|
-
titleWrapStyle={{ paddingHorizontal: 0
|
|
206
|
-
titleStyle={{
|
|
199
|
+
style={{ flexDirection: 'column', alignItems: 'flex-start' }}
|
|
200
|
+
titleWrapStyle={{ paddingHorizontal: 0 }}
|
|
201
|
+
titleStyle={{ marginRight: 0, marginLeft: 0 }}
|
|
207
202
|
/>
|
|
208
203
|
<BusinessLogo>
|
|
209
204
|
<View style={styles.logoWrapper}>
|
|
@@ -214,7 +209,6 @@ export const ReviewOrderUI = (props: ReviewOrderParams) => {
|
|
|
214
209
|
/>
|
|
215
210
|
</View>
|
|
216
211
|
</BusinessLogo>
|
|
217
|
-
{!!order?.business_name && <OText style={{ textAlign: 'center', marginTop: 15 }} color={theme.colors.textNormal}>{order?.business_name}</OText>}
|
|
218
212
|
{order?.review ? (
|
|
219
213
|
<View style={styles.reviewedStyle}>
|
|
220
214
|
<OText color={theme.colors.primary}>{t('ORDER_REVIEWED', 'This order has been already reviewed')}</OText>
|
|
@@ -222,92 +216,78 @@ export const ReviewOrderUI = (props: ReviewOrderParams) => {
|
|
|
222
216
|
) : (
|
|
223
217
|
<View style={{ flex: 1, justifyContent: 'flex-end' }}>
|
|
224
218
|
<FormReviews>
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
<
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
219
|
+
<OText mBottom={13} color={theme.colors.textNormal}>{t('HOW_WAS_YOUR_ORDER', 'How was your order?')}</OText>
|
|
220
|
+
<RatingBarContainer>
|
|
221
|
+
<LinearGradient
|
|
222
|
+
start={{ x: 0.0, y: 0.0 }}
|
|
223
|
+
end={{ x: qualificationList[stars.quality - 1]?.percent || 0, y: 0 }}
|
|
224
|
+
locations={[.9999, .9999]}
|
|
225
|
+
colors={[theme.colors.primary, theme.colors.backgroundGray200]}
|
|
226
|
+
style={styles.statusBar}
|
|
227
|
+
/>
|
|
228
|
+
<RatingTextContainer>
|
|
229
|
+
{qualificationList.map((qualification: any) => (
|
|
230
|
+
<View
|
|
231
|
+
key={qualification.key}
|
|
232
|
+
style={{ ...qualification.parentStyle, ...styles.ratingItemContainer }}
|
|
233
|
+
>
|
|
234
|
+
<TouchableOpacity
|
|
235
|
+
style={qualification.isInnerStyle && styles.ratingItem}
|
|
236
|
+
onPress={() => handleChangeStars(qualification.key)}
|
|
240
237
|
>
|
|
241
|
-
<
|
|
242
|
-
style={
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
238
|
+
<View
|
|
239
|
+
style={{
|
|
240
|
+
...styles.ratingLineStyle,
|
|
241
|
+
backgroundColor: (qualification.pointerColor && !(stars.quality >= qualification.key)) ? theme.colors.dusk : 'transparent'
|
|
242
|
+
}}
|
|
243
|
+
/>
|
|
244
|
+
<OText size={12} color={stars.quality === qualification.key ? theme.colors.black : theme.colors.backgroundGray200}>{qualification.text}</OText>
|
|
245
|
+
</TouchableOpacity>
|
|
246
|
+
</View>
|
|
247
|
+
))}
|
|
248
|
+
</RatingTextContainer>
|
|
249
|
+
</RatingBarContainer>
|
|
250
|
+
|
|
251
|
+
<OText style={{ marginTop: 30 }} color={theme.colors.textNormal}>
|
|
252
|
+
{commentsList[stars?.quality || 1]?.title}
|
|
253
|
+
</OText>
|
|
254
|
+
<CommentsButtonGroup>
|
|
255
|
+
{commentsList[stars?.quality || 1]?.list?.map(commentItem => (
|
|
256
|
+
<OButton
|
|
257
|
+
key={commentItem.key}
|
|
258
|
+
text={commentItem.content}
|
|
259
|
+
bgColor={isSelectedComment(commentItem.key) ? theme.colors.primary : theme.colors.backgroundGray200}
|
|
260
|
+
borderColor={isSelectedComment(commentItem.key) ? theme.colors.primary : theme.colors.backgroundGray200}
|
|
261
|
+
textStyle={{
|
|
262
|
+
color: isSelectedComment(commentItem.key) ? theme.colors.white : theme.colors.black,
|
|
263
|
+
fontSize: 13,
|
|
264
|
+
paddingRight: isSelectedComment(commentItem.key) ? 15 : 0
|
|
265
|
+
}}
|
|
266
|
+
style={{ height: 35, paddingLeft: 5, paddingRight: 5, marginHorizontal: 3, marginVertical: 10 }}
|
|
267
|
+
imgRightSrc={isSelectedComment(commentItem.key) ? theme.images.general.close : null}
|
|
268
|
+
imgRightStyle={{ tintColor: theme.colors.white, right: 5, margin: 5 }}
|
|
269
|
+
onClick={() => handleChangeComment(commentItem)}
|
|
270
|
+
/>
|
|
271
|
+
))}
|
|
272
|
+
</CommentsButtonGroup>
|
|
273
|
+
|
|
274
|
+
<OText style={{ marginTop: 30 }} color={theme.colors.textNormal}>{t('REVIEW_COMMENT_QUESTION', 'Do you want to add something?')}</OText>
|
|
275
|
+
<Controller
|
|
276
|
+
control={control}
|
|
277
|
+
defaultValue=''
|
|
278
|
+
name='comments'
|
|
279
|
+
render={({ onChange }: any) => (
|
|
280
|
+
<OInput
|
|
281
|
+
name='comments'
|
|
282
|
+
onChange={(val: any) => {
|
|
283
|
+
onChange(val)
|
|
284
|
+
setExtraComment(val.target.value)
|
|
285
|
+
}}
|
|
286
|
+
style={styles.inputTextArea}
|
|
287
|
+
multiline
|
|
288
|
+
/>
|
|
260
289
|
)}
|
|
261
|
-
|
|
262
|
-
<PlacedDate>
|
|
263
|
-
<OText color={theme.colors.textNormal}>{t('DONOT_FORGET_RATE_YOUR_ORDER', 'Do not forget to rate your order placed on ')}</OText>
|
|
264
|
-
<OText color={theme.colors.textNormal} style={{ fontWeight: "bold" }}>{placedOnDate}</OText>
|
|
265
|
-
</PlacedDate>
|
|
266
|
-
{false && (
|
|
267
|
-
<>
|
|
268
|
-
<OText style={{ marginTop: 30 }} color={theme.colors.textNormal}>
|
|
269
|
-
{commentsList[stars?.quality || 1]?.title}
|
|
270
|
-
</OText>
|
|
271
|
-
<CommentsButtonGroup>
|
|
272
|
-
{commentsList[stars?.quality || 1]?.list?.map((commentItem: any) => (
|
|
273
|
-
<OButton
|
|
274
|
-
key={commentItem.key}
|
|
275
|
-
text={commentItem.content}
|
|
276
|
-
bgColor={isSelectedComment(commentItem.key) ? theme.colors.primary : theme.colors.backgroundGray200}
|
|
277
|
-
borderColor={isSelectedComment(commentItem.key) ? theme.colors.primary : theme.colors.backgroundGray200}
|
|
278
|
-
textStyle={{
|
|
279
|
-
color: isSelectedComment(commentItem.key) ? theme.colors.white : theme.colors.black,
|
|
280
|
-
fontSize: 13,
|
|
281
|
-
paddingRight: isSelectedComment(commentItem.key) ? 15 : 0
|
|
282
|
-
}}
|
|
283
|
-
style={{ height: 35, paddingLeft: 5, paddingRight: 5, marginHorizontal: 3, marginVertical: 10 }}
|
|
284
|
-
imgRightSrc={isSelectedComment(commentItem.key) ? theme.images.general.close : null}
|
|
285
|
-
imgRightStyle={{ tintColor: theme.colors.white, right: 5, margin: 5 }}
|
|
286
|
-
onClick={() => handleChangeComment(commentItem)}
|
|
287
|
-
/>
|
|
288
|
-
))}
|
|
289
|
-
</CommentsButtonGroup>
|
|
290
|
-
</>
|
|
291
|
-
)}
|
|
292
|
-
{/* <OText style={{ marginTop: 30 }} color={theme.colors.textNormal}>{t('REVIEW_COMMENT_QUESTION', 'Do you want to add something?')}</OText> */}
|
|
293
|
-
{false && (
|
|
294
|
-
<Controller
|
|
295
|
-
control={control}
|
|
296
|
-
defaultValue=''
|
|
297
|
-
name='comments'
|
|
298
|
-
render={({ onChange }: any) => (
|
|
299
|
-
<OInput
|
|
300
|
-
name='comments'
|
|
301
|
-
onChange={(val: any) => {
|
|
302
|
-
onChange(val)
|
|
303
|
-
setExtraComment(val.target.value)
|
|
304
|
-
}}
|
|
305
|
-
style={styles.inputTextArea}
|
|
306
|
-
multiline
|
|
307
|
-
/>
|
|
308
|
-
)}
|
|
309
|
-
/>
|
|
310
|
-
)}
|
|
290
|
+
/>
|
|
311
291
|
</FormReviews>
|
|
312
292
|
</View>
|
|
313
293
|
)}
|
|
@@ -322,7 +302,7 @@ export const ReviewOrderUI = (props: ReviewOrderParams) => {
|
|
|
322
302
|
</SkipButton>
|
|
323
303
|
<OButton
|
|
324
304
|
textStyle={{ color: theme.colors.white, paddingRight: 10 }}
|
|
325
|
-
text={t('
|
|
305
|
+
text={t('CONTINUE', 'Continue')}
|
|
326
306
|
style={{ borderRadius: 8 }}
|
|
327
307
|
imgRightSrc={theme.images.general.arrow_right}
|
|
328
308
|
imgRightStyle={{ tintColor: theme.colors.white, right: 5, margin: 5 }}
|
|
@@ -338,7 +318,7 @@ export const ReviewOrder = (props: ReviewOrderParams) => {
|
|
|
338
318
|
const reviewOrderProps = {
|
|
339
319
|
...props,
|
|
340
320
|
UIComponent: ReviewOrderUI,
|
|
341
|
-
defaultStar: 5
|
|
321
|
+
defaultStar: props?.defaultStar || 5
|
|
342
322
|
}
|
|
343
323
|
return <ReviewOrderController {...reviewOrderProps} />
|
|
344
324
|
}
|
|
@@ -42,12 +42,3 @@ export const RatingTextContainer = styled.View`
|
|
|
42
42
|
justify-content: space-between;
|
|
43
43
|
margin-top: 10px;
|
|
44
44
|
`
|
|
45
|
-
export const RatingStarContainer = styled.View`
|
|
46
|
-
flex-direction: row;
|
|
47
|
-
align-items: center;
|
|
48
|
-
justify-content: space-between;
|
|
49
|
-
margin-top: 10px;
|
|
50
|
-
`
|
|
51
|
-
export const PlacedDate = styled.View`
|
|
52
|
-
margin-top: 30px;
|
|
53
|
-
`
|