ordering-ui-react-native 0.14.86 → 0.14.89
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/utils/index.tsx +194 -0
- package/themes/business/src/components/OrdersOption/index.tsx +400 -58
- package/themes/business/src/components/OrdersOption/styles.tsx +98 -7
- package/themes/business/src/components/PreviousOrders/index.tsx +34 -38
- package/themes/business/src/components/PreviousOrders/styles.tsx +5 -10
- package/themes/business/src/components/ReviewCustomer/index.tsx +6 -7
- package/themes/original/index.tsx +4 -0
- package/themes/original/src/components/ReviewDriver/index.tsx +314 -0
- package/themes/original/src/components/ReviewDriver/styles.tsx +38 -0
- package/themes/original/src/components/ReviewOrder/index.tsx +322 -186
- package/themes/original/src/components/ReviewOrder/styles.tsx +24 -13
- package/themes/original/src/components/ReviewProducts/index.tsx +116 -0
- package/themes/original/src/components/ReviewProducts/styles.tsx +16 -0
- package/themes/original/src/components/SingleProductReview/index.tsx +162 -0
- package/themes/original/src/components/SingleProductReview/styles.tsx +27 -0
- package/themes/original/src/layouts/FloatingBottomContainer.tsx +26 -0
- package/themes/original/src/types/index.tsx +29 -2
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import styled from 'styled-components/native';
|
|
1
|
+
import styled, { css } from 'styled-components/native';
|
|
2
2
|
|
|
3
3
|
export const FiltersTab = styled.View`
|
|
4
4
|
margin-bottom: 20px;
|
|
5
5
|
min-height: 30px;
|
|
6
6
|
max-height: 35px;
|
|
7
7
|
flex: 1;
|
|
8
|
-
|
|
8
|
+
width: 100%;
|
|
9
|
+
`
|
|
9
10
|
|
|
10
11
|
export const TabsContainer = styled.View`
|
|
11
12
|
display: flex;
|
|
@@ -13,8 +14,9 @@ export const TabsContainer = styled.View`
|
|
|
13
14
|
justify-content: space-between;
|
|
14
15
|
border-bottom-width: 1px;
|
|
15
16
|
flex: 1;
|
|
17
|
+
width: 100%;
|
|
16
18
|
border-bottom-color: ${(props: any) => props.theme.colors.tabBar};
|
|
17
|
-
|
|
19
|
+
`
|
|
18
20
|
|
|
19
21
|
export const Tag = styled.Pressable`
|
|
20
22
|
background-color: ${({ isSelected }: { isSelected: string }) => isSelected};
|
|
@@ -24,24 +26,24 @@ export const Tag = styled.Pressable`
|
|
|
24
26
|
padding: 4px 10px;
|
|
25
27
|
border-radius: 50px;
|
|
26
28
|
margin-right: 15px;
|
|
27
|
-
|
|
29
|
+
`
|
|
28
30
|
|
|
29
31
|
export const IconWrapper = styled.View`
|
|
30
32
|
flex-direction: row;
|
|
31
33
|
align-items: center;
|
|
34
|
+
background: #fff;
|
|
32
35
|
`
|
|
33
36
|
|
|
34
37
|
export const ModalContainer = styled.ScrollView`
|
|
35
|
-
padding:
|
|
38
|
+
padding: 0px 30px;
|
|
36
39
|
`
|
|
37
40
|
|
|
38
41
|
export const ModalTitle = styled.Text`
|
|
39
42
|
font-family: Poppins;
|
|
40
43
|
font-style: normal;
|
|
41
|
-
font-weight:
|
|
44
|
+
font-weight: bold;
|
|
42
45
|
font-size: 20px;
|
|
43
46
|
color: ${(props: any) => props.theme.colors.textGray};
|
|
44
|
-
text-transform: capitalize;
|
|
45
47
|
margin-bottom: 24px;
|
|
46
48
|
`
|
|
47
49
|
|
|
@@ -61,4 +63,93 @@ export const TabPressable = styled.Pressable`
|
|
|
61
63
|
border-color: ${(props: any) => props.theme.colors.textGray};
|
|
62
64
|
border-bottom-width: ${(props: any) => props.isSelected ? '1px' : '0px'};
|
|
63
65
|
padding-horizontal: 10px;
|
|
66
|
+
`
|
|
67
|
+
export const OrderStatus = styled.View`
|
|
68
|
+
margin-right: 5px;
|
|
69
|
+
width: 3px;
|
|
70
|
+
height: 90%;
|
|
71
|
+
border-radius: 6px;
|
|
72
|
+
|
|
73
|
+
${(props: any) => props.timeState === 'in_time' && css`
|
|
74
|
+
background-color: #00D27A;
|
|
75
|
+
`}
|
|
76
|
+
|
|
77
|
+
${(props: any) => props.timeState === 'at_risk' && css`
|
|
78
|
+
background-color: #FFC700;
|
|
79
|
+
`}
|
|
80
|
+
|
|
81
|
+
${(props: any) => props.timeState === 'delayed' && css`
|
|
82
|
+
background-color: #E63757;
|
|
83
|
+
`}
|
|
84
|
+
`
|
|
85
|
+
|
|
86
|
+
export const SlaOption = styled.View`
|
|
87
|
+
flex-direction: row;
|
|
88
|
+
align-items: center;
|
|
89
|
+
`
|
|
90
|
+
|
|
91
|
+
export const SearchModalContent = styled.View`
|
|
92
|
+
|
|
93
|
+
`
|
|
94
|
+
|
|
95
|
+
export const SlaSettingModalContent = styled.View`
|
|
96
|
+
|
|
97
|
+
`
|
|
98
|
+
|
|
99
|
+
export const DeliveryStatusWrapper = styled.View`
|
|
100
|
+
position: relative;
|
|
101
|
+
`
|
|
102
|
+
export const VerticalLine = styled.View`
|
|
103
|
+
position: absolute;
|
|
104
|
+
background: #E9ECEF;
|
|
105
|
+
position: absolute;
|
|
106
|
+
width: 1px;
|
|
107
|
+
height: 100%;
|
|
108
|
+
top: 7px;
|
|
109
|
+
left: 7px;
|
|
110
|
+
`
|
|
111
|
+
export const StatusItems = styled.View`
|
|
112
|
+
position: relative;
|
|
113
|
+
margin-bottom: 20px;
|
|
114
|
+
z-index: 2;
|
|
115
|
+
`
|
|
116
|
+
export const ItemHeader = styled.View`
|
|
117
|
+
flex-direction: row;
|
|
118
|
+
margin-bottom: 5px;
|
|
119
|
+
`
|
|
120
|
+
export const ItemStatus = styled.View`
|
|
121
|
+
width: 4px;
|
|
122
|
+
height: 22px;
|
|
123
|
+
margin: 0 15px;
|
|
124
|
+
border-radius: 4px;
|
|
125
|
+
background: ${(props: any) => props.backColor};
|
|
126
|
+
`
|
|
127
|
+
export const ItemContent = styled.View`
|
|
128
|
+
display: flex;
|
|
129
|
+
padding: 0 30px;
|
|
130
|
+
`
|
|
131
|
+
|
|
132
|
+
export const TimerInputWrapper = styled.View`
|
|
133
|
+
border-width: 1px;
|
|
134
|
+
border-radius: 7.6px;
|
|
135
|
+
color: ${(props: any) => props.theme.colors.disabled};
|
|
136
|
+
border-color: ${(props: any) => props.theme.colors.disabled};
|
|
137
|
+
margin-left: 30px;
|
|
138
|
+
margin-right: 30px;
|
|
139
|
+
flex-direction: row;
|
|
140
|
+
align-items: center;
|
|
141
|
+
width: 80px;
|
|
142
|
+
`
|
|
143
|
+
export const OverLine = styled.View`
|
|
144
|
+
position: absolute;
|
|
145
|
+
height: 100%;
|
|
146
|
+
width: 15px;
|
|
147
|
+
top: 20px;
|
|
148
|
+
left: 0;
|
|
149
|
+
/* border-width: 1px; */
|
|
150
|
+
background-color: #fff;
|
|
151
|
+
z-index: 2;
|
|
152
|
+
`
|
|
153
|
+
export const Actions = styled.View`
|
|
154
|
+
|
|
64
155
|
`
|
|
@@ -16,7 +16,8 @@ export const PreviousOrders = (props: any) => {
|
|
|
16
16
|
getOrderStatus,
|
|
17
17
|
handleClickOrder,
|
|
18
18
|
isLogisticOrder,
|
|
19
|
-
handleClickLogisticOrder
|
|
19
|
+
handleClickLogisticOrder,
|
|
20
|
+
slaSettingTime
|
|
20
21
|
} = props;
|
|
21
22
|
const [, t] = useLanguage();
|
|
22
23
|
const [{ parseDate, optimizeImage }] = useUtils();
|
|
@@ -39,19 +40,14 @@ export const PreviousOrders = (props: any) => {
|
|
|
39
40
|
},
|
|
40
41
|
icon: {
|
|
41
42
|
borderRadius: 7.6,
|
|
42
|
-
width:
|
|
43
|
-
height:
|
|
43
|
+
width: 60,
|
|
44
|
+
height: 60
|
|
44
45
|
},
|
|
45
46
|
logo: {
|
|
46
47
|
borderRadius: 10,
|
|
47
|
-
shadowColor: "#
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
height: 1,
|
|
51
|
-
},
|
|
52
|
-
shadowOpacity: 0.20,
|
|
53
|
-
shadowRadius: 1.41,
|
|
54
|
-
elevation: 2,
|
|
48
|
+
shadowColor: "#0000006e",
|
|
49
|
+
shadowRadius: 10,
|
|
50
|
+
elevation: 15,
|
|
55
51
|
justifyContent: 'center',
|
|
56
52
|
alignItems: 'center',
|
|
57
53
|
marginLeft: 3,
|
|
@@ -99,9 +95,9 @@ export const PreviousOrders = (props: any) => {
|
|
|
99
95
|
|
|
100
96
|
useEffect(() => {
|
|
101
97
|
const interval = setInterval(() => {
|
|
102
|
-
const date:any = Date.now()
|
|
98
|
+
const date: any = Date.now()
|
|
103
99
|
setCurrentTime(date)
|
|
104
|
-
},
|
|
100
|
+
}, slaSettingTime)
|
|
105
101
|
|
|
106
102
|
return () => clearInterval(interval)
|
|
107
103
|
}, [])
|
|
@@ -130,7 +126,7 @@ export const PreviousOrders = (props: any) => {
|
|
|
130
126
|
activeOpacity={1}
|
|
131
127
|
>
|
|
132
128
|
<Card key={order.id}>
|
|
133
|
-
<Timestatus style={{backgroundColor: order?.time_status === 'in_time' ? '#00D27A' : order?.time_status === 'at_risk' ? '#FFC700' : order?.time_status === 'delayed' ? '#E63757' : '' }}/>
|
|
129
|
+
<Timestatus style={{ backgroundColor: order?.time_status === 'in_time' ? '#00D27A' : order?.time_status === 'at_risk' ? '#FFC700' : order?.time_status === 'delayed' ? '#E63757' : '' }} />
|
|
134
130
|
{
|
|
135
131
|
order.business?.logo && (
|
|
136
132
|
<Logo style={styles.logo}>
|
|
@@ -163,7 +159,7 @@ export const PreviousOrders = (props: any) => {
|
|
|
163
159
|
/>
|
|
164
160
|
</NotificationIcon>
|
|
165
161
|
)}
|
|
166
|
-
<View style={{flexDirection: 'row'}}>
|
|
162
|
+
<View style={{ flexDirection: 'row' }}>
|
|
167
163
|
<OText
|
|
168
164
|
style={styles.date}
|
|
169
165
|
color={theme.colors.unselectText}
|
|
@@ -175,7 +171,7 @@ export const PreviousOrders = (props: any) => {
|
|
|
175
171
|
? parseDate(order?.delivery_datetime_utc, { outputFormat: 'MM/DD/YY · HH:mm a' })
|
|
176
172
|
: parseDate(order?.delivery_datetime, { utc: false })}{' · '}
|
|
177
173
|
</OText>
|
|
178
|
-
<OText style={styles.date} color={order?.time_status === 'in_time' ? '#00D27A' : order?.time_status === 'at_risk' ? '#FFC700' : order?.time_status === 'delayed' ? '#E63757' : ''
|
|
174
|
+
<OText style={styles.date} color={order?.time_status === 'in_time' ? '#00D27A' : order?.time_status === 'at_risk' ? '#FFC700' : order?.time_status === 'delayed' ? '#E63757' : ''} >{getDelayTime(order)}</OText>
|
|
179
175
|
</View>
|
|
180
176
|
{!isLogisticOrder && (
|
|
181
177
|
<MyOrderOptions>
|
|
@@ -215,28 +211,28 @@ export const PreviousOrders = (props: any) => {
|
|
|
215
211
|
textStyle={{ color: theme.colors.primary }}
|
|
216
212
|
/>
|
|
217
213
|
) : (
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
214
|
+
<>
|
|
215
|
+
<OButton
|
|
216
|
+
text={t('REJECT', 'Reject')}
|
|
217
|
+
onClick={() => handleClickLogisticOrder(2, _order?.id)}
|
|
218
|
+
bgColor={theme.colors.danger}
|
|
219
|
+
borderColor={theme.colors.danger}
|
|
220
|
+
imgRightSrc={null}
|
|
221
|
+
style={{ borderRadius: 7, height: 40 }}
|
|
222
|
+
parentStyle={{ width: '45%' }}
|
|
223
|
+
textStyle={{ color: theme.colors.dangerText }}
|
|
224
|
+
/>
|
|
225
|
+
<OButton
|
|
226
|
+
text={t('ACCEPT', 'Accept')}
|
|
227
|
+
onClick={() => handleClickLogisticOrder(1, _order?.id)}
|
|
228
|
+
bgColor={theme.colors.successOrder}
|
|
229
|
+
borderColor={theme.colors.successOrder}
|
|
230
|
+
imgRightSrc={null}
|
|
231
|
+
style={{ borderRadius: 7, height: 40 }}
|
|
232
|
+
parentStyle={{ width: '45%' }}
|
|
233
|
+
textStyle={{ color: theme.colors.successText }}
|
|
234
|
+
/>
|
|
235
|
+
</>
|
|
240
236
|
)}
|
|
241
237
|
</AcceptOrRejectOrder>
|
|
242
238
|
)}
|
|
@@ -8,16 +8,16 @@ export const Card = styled.View`
|
|
|
8
8
|
`;
|
|
9
9
|
|
|
10
10
|
export const Logo = styled.View`
|
|
11
|
-
height:
|
|
12
|
-
width:
|
|
11
|
+
height: 65px;
|
|
12
|
+
width: 65px;
|
|
13
13
|
`;
|
|
14
14
|
|
|
15
15
|
export const Information = styled.View`
|
|
16
16
|
position: relative;
|
|
17
17
|
justify-content: flex-start;
|
|
18
|
-
margin-horizontal:
|
|
18
|
+
margin-horizontal: 5px;
|
|
19
19
|
flex: 1;
|
|
20
|
-
max-height:
|
|
20
|
+
max-height: 60px;
|
|
21
21
|
`;
|
|
22
22
|
|
|
23
23
|
export const MyOrderOptions = styled.View`
|
|
@@ -39,12 +39,7 @@ export const AcceptOrRejectOrder = styled.View`
|
|
|
39
39
|
export const Timestatus = styled.View`
|
|
40
40
|
position: relative;;
|
|
41
41
|
width: 4px;
|
|
42
|
-
height:
|
|
42
|
+
height: 55px;
|
|
43
43
|
border-radius: 20px;
|
|
44
44
|
top: 5px;
|
|
45
|
-
margin-right: 5px;
|
|
46
|
-
${(props: any) => props.theme?.rtl && css`
|
|
47
|
-
left: unset;
|
|
48
|
-
right: -5px;
|
|
49
|
-
`}
|
|
50
45
|
`
|
|
@@ -20,6 +20,8 @@ import { FloatingButton } from '../FloatingButton'
|
|
|
20
20
|
import LinearGradient from 'react-native-linear-gradient'
|
|
21
21
|
import Alert from '../../providers/AlertProvider'
|
|
22
22
|
|
|
23
|
+
import { reviewCommentList } from '../../../../../src/utils'
|
|
24
|
+
|
|
23
25
|
import {
|
|
24
26
|
Content,
|
|
25
27
|
ActionButtonWrapper,
|
|
@@ -101,11 +103,8 @@ const ReviewCustomerUI = (props: ReviewCustomerParams) => {
|
|
|
101
103
|
{ key: 5, text: t('GREAT', 'Great'), percent: 1, parentStyle: { right: '0%' }, isInnerStyle: false, pointerColor: false }
|
|
102
104
|
]
|
|
103
105
|
|
|
104
|
-
const commentsList =
|
|
105
|
-
|
|
106
|
-
{ key: 1, content: t('EXCELLENT_COMMUNICATION', "Excellent communication") },
|
|
107
|
-
{ key: 2, content: t('CORDIAL_SERVICE', 'Cordial service') }
|
|
108
|
-
]
|
|
106
|
+
const commentsList = reviewCommentList('customer')
|
|
107
|
+
|
|
109
108
|
const isSelectedComment = (commentKey: number) => {
|
|
110
109
|
const found = comments.find((comment: any) => comment?.key === commentKey)
|
|
111
110
|
return found
|
|
@@ -251,10 +250,10 @@ const ReviewCustomerUI = (props: ReviewCustomerParams) => {
|
|
|
251
250
|
size={12}
|
|
252
251
|
style={{ marginTop: 30 }}
|
|
253
252
|
>
|
|
254
|
-
{
|
|
253
|
+
{commentsList[reviewState?.qualification || 1]?.title}
|
|
255
254
|
</OText>
|
|
256
255
|
<CommentsButtonGroup>
|
|
257
|
-
{commentsList
|
|
256
|
+
{commentsList[reviewState?.qualification || 1]?.list?.map(commentItem => (
|
|
258
257
|
<OButton
|
|
259
258
|
key={commentItem.key}
|
|
260
259
|
text={commentItem.content}
|
|
@@ -20,6 +20,8 @@ import { BusinessPreorder } from './src/components/BusinessPreorder';
|
|
|
20
20
|
import { BusinessMenuList } from './src/components/BusinessMenuList';
|
|
21
21
|
import { UserProfileForm } from './src/components/UserProfileForm';
|
|
22
22
|
import { ReviewOrder } from './src/components/ReviewOrder';
|
|
23
|
+
import { ReviewProducts } from './src/components/ReviewProducts';
|
|
24
|
+
import { ReviewDriver } from './src/components/ReviewDriver';
|
|
23
25
|
import { UserProfile } from './src/components/UserProfile';
|
|
24
26
|
import { MessageListing } from './src/components/MessageListing';
|
|
25
27
|
import { Help } from './src/components/Help';
|
|
@@ -82,6 +84,8 @@ export {
|
|
|
82
84
|
BusinessPreorder,
|
|
83
85
|
UserProfileForm,
|
|
84
86
|
ReviewOrder,
|
|
87
|
+
ReviewProducts,
|
|
88
|
+
ReviewDriver,
|
|
85
89
|
BusinessMenuList,
|
|
86
90
|
UserProfile,
|
|
87
91
|
MessageListing,
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react'
|
|
2
|
+
import { useLanguage, useToast, ToastType, ReviewDriver as ReviewDriverController } from 'ordering-components/native'
|
|
3
|
+
import { StyleSheet, View, I18nManager, TouchableOpacity } from 'react-native'
|
|
4
|
+
import { ReviewDriverParams } from '../../types'
|
|
5
|
+
import { useTheme } from 'styled-components/native'
|
|
6
|
+
import { useForm, Controller } from 'react-hook-form'
|
|
7
|
+
import { OText, OIcon, OButton, OInput } from '../shared'
|
|
8
|
+
import NavBar from '../NavBar'
|
|
9
|
+
import LinearGradient from 'react-native-linear-gradient'
|
|
10
|
+
import { FloatingBottomContainer } from '../../layouts/FloatingBottomContainer'
|
|
11
|
+
import Spinner from 'react-native-loading-spinner-overlay'
|
|
12
|
+
|
|
13
|
+
import { reviewCommentList } from '../../../../../src/utils'
|
|
14
|
+
|
|
15
|
+
import {
|
|
16
|
+
ReviewDriverContainer,
|
|
17
|
+
DriverPhotoContainer,
|
|
18
|
+
FormReviews,
|
|
19
|
+
RatingBarContainer,
|
|
20
|
+
RatingTextContainer,
|
|
21
|
+
CommentsButtonGroup,
|
|
22
|
+
ActionContainer,
|
|
23
|
+
} from './styles'
|
|
24
|
+
|
|
25
|
+
const ReviewDriverUI = (props: ReviewDriverParams) => {
|
|
26
|
+
const {
|
|
27
|
+
order,
|
|
28
|
+
navigation,
|
|
29
|
+
formState,
|
|
30
|
+
dirverReviews,
|
|
31
|
+
setDriverReviews,
|
|
32
|
+
handleSendDriverReview,
|
|
33
|
+
onNavigationRedirect
|
|
34
|
+
} = props
|
|
35
|
+
|
|
36
|
+
const [, t] = useLanguage()
|
|
37
|
+
const theme = useTheme()
|
|
38
|
+
const { handleSubmit, control, errors } = useForm()
|
|
39
|
+
const [, { showToast }] = useToast()
|
|
40
|
+
|
|
41
|
+
const [isDriverReviewed, setIsDriverReviewed] = useState(false)
|
|
42
|
+
|
|
43
|
+
const styles = StyleSheet.create({
|
|
44
|
+
photoWrapper: {
|
|
45
|
+
shadowColor: theme.colors.black,
|
|
46
|
+
shadowRadius: 3,
|
|
47
|
+
shadowOffset: {width: 1, height: 4},
|
|
48
|
+
elevation: 3,
|
|
49
|
+
borderRadius: 8,
|
|
50
|
+
shadowOpacity: 0.1,
|
|
51
|
+
overflow: 'hidden'
|
|
52
|
+
},
|
|
53
|
+
inputTextArea: {
|
|
54
|
+
borderColor: theme.colors.lightGray,
|
|
55
|
+
borderRadius: 8,
|
|
56
|
+
marginTop: 10,
|
|
57
|
+
marginBottom: 40,
|
|
58
|
+
height: 100,
|
|
59
|
+
alignItems: 'flex-start'
|
|
60
|
+
},
|
|
61
|
+
statusBar: {
|
|
62
|
+
transform: [{ scaleX: I18nManager.isRTL ? -1 : 1 }],
|
|
63
|
+
height: 10,
|
|
64
|
+
borderRadius: 5,
|
|
65
|
+
marginTop: 5
|
|
66
|
+
},
|
|
67
|
+
ratingItemContainer: {
|
|
68
|
+
position: 'absolute',
|
|
69
|
+
top: -20
|
|
70
|
+
},
|
|
71
|
+
ratingItem: {
|
|
72
|
+
left: '-50%',
|
|
73
|
+
flexDirection: 'column',
|
|
74
|
+
alignItems: 'center'
|
|
75
|
+
},
|
|
76
|
+
ratingLineStyle: {
|
|
77
|
+
height: 10,
|
|
78
|
+
width: 1,
|
|
79
|
+
marginBottom: 10,
|
|
80
|
+
backgroundColor: theme.colors.dusk
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
const [comments, setComments] = useState<Array<any>>([])
|
|
85
|
+
const [extraComment, setExtraComment] = useState('')
|
|
86
|
+
const [alertState, setAlertState] = useState<{ open: boolean, content: Array<any>, success?: boolean }>({ open: false, content: [], success: false })
|
|
87
|
+
|
|
88
|
+
const qualificationList = [
|
|
89
|
+
{ key: 1, text: t('TERRIBLE', 'Terrible'), percent: 0, parentStyle: { left: '0%' }, isInnerStyle: false, pointerColor: false },
|
|
90
|
+
{ key: 2, text: t('BAD', 'Bad'), percent: 0.25, parentStyle: { left: '25%' }, isInnerStyle: true, pointerColor: true },
|
|
91
|
+
{ key: 3, text: t('OKAY', 'Okay'), percent: 0.5, parentStyle: { left: '50%' }, isInnerStyle: true, pointerColor: true },
|
|
92
|
+
{ key: 4, text: t('GOOD', 'Good'), percent: 0.75, parentStyle: { left: '75%' }, isInnerStyle: true, pointerColor: true },
|
|
93
|
+
{ key: 5, text: t('GREAT', 'Great'), percent: 1, parentStyle: { right: '0%' }, isInnerStyle: false, pointerColor: false }
|
|
94
|
+
]
|
|
95
|
+
|
|
96
|
+
const commentsList = reviewCommentList('driver')
|
|
97
|
+
|
|
98
|
+
const onSubmit = () => {
|
|
99
|
+
if (dirverReviews?.qualification === 0) {
|
|
100
|
+
setAlertState({
|
|
101
|
+
open: true,
|
|
102
|
+
content: dirverReviews?.qualification === 0 ? [`${t('REVIEW_QUALIFICATION_REQUIRED', 'Review qualification is required')}`] : []
|
|
103
|
+
})
|
|
104
|
+
return
|
|
105
|
+
}
|
|
106
|
+
handleSendDriverReview()
|
|
107
|
+
setAlertState({ ...alertState, success: true })
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const isSelectedComment = (commentKey: number) => {
|
|
111
|
+
const found = comments.find((comment: any) => comment?.key === commentKey)
|
|
112
|
+
return found
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const handleChangeComment = (commentItem: any) => {
|
|
116
|
+
const found = comments.find((comment: any) => comment?.key === commentItem.key)
|
|
117
|
+
if (found) {
|
|
118
|
+
const _comments = comments.filter((comment: any) => comment?.key !== commentItem.key)
|
|
119
|
+
setComments(_comments)
|
|
120
|
+
} else {
|
|
121
|
+
setComments([...comments, commentItem])
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const handleChangeQualification = (qualification: number) => {
|
|
126
|
+
if (qualification) setDriverReviews({ ...dirverReviews, qualification: qualification })
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const handleSendReviewClick = () => {
|
|
130
|
+
if (!order?.user_review && !isDriverReviewed) {
|
|
131
|
+
onSubmit()
|
|
132
|
+
} else {
|
|
133
|
+
onNavigationRedirect && onNavigationRedirect('MyOrders')
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
useEffect(() => {
|
|
138
|
+
if (!formState.loading && formState.result?.error) {
|
|
139
|
+
setAlertState({
|
|
140
|
+
open: true,
|
|
141
|
+
success: false,
|
|
142
|
+
content: formState.result?.result || [t('ERROR', 'Error')]
|
|
143
|
+
})
|
|
144
|
+
}
|
|
145
|
+
if (!formState.loading && !formState.result?.error && alertState.success) {
|
|
146
|
+
setIsDriverReviewed && setIsDriverReviewed(true)
|
|
147
|
+
onNavigationRedirect('MyOrders')
|
|
148
|
+
}
|
|
149
|
+
}, [formState])
|
|
150
|
+
|
|
151
|
+
useEffect(() => {
|
|
152
|
+
if (Object.keys(errors).length > 0) {
|
|
153
|
+
// Convert all errors in one string to show in toast provider
|
|
154
|
+
const list = Object.values(errors);
|
|
155
|
+
let stringError = '';
|
|
156
|
+
list.map((item: any, i: number) => {
|
|
157
|
+
stringError +=
|
|
158
|
+
i + 1 === list.length ? `- ${item.message}` : `- ${item.message}\n`;
|
|
159
|
+
});
|
|
160
|
+
showToast(ToastType.Error, stringError);
|
|
161
|
+
}
|
|
162
|
+
}, [errors])
|
|
163
|
+
|
|
164
|
+
useEffect(() => {
|
|
165
|
+
if (alertState.open) {
|
|
166
|
+
alertState.content && showToast(
|
|
167
|
+
ToastType.Error,
|
|
168
|
+
alertState.content
|
|
169
|
+
)
|
|
170
|
+
}
|
|
171
|
+
}, [alertState.content])
|
|
172
|
+
|
|
173
|
+
useEffect(() => {
|
|
174
|
+
let _comments = ''
|
|
175
|
+
if (comments.length > 0) {
|
|
176
|
+
comments.map((comment: any) => (_comments += comment.content + '. '))
|
|
177
|
+
}
|
|
178
|
+
const _comment = _comments + extraComment
|
|
179
|
+
setDriverReviews({ ...dirverReviews, comment: _comment })
|
|
180
|
+
}, [comments, extraComment])
|
|
181
|
+
|
|
182
|
+
return (
|
|
183
|
+
<>
|
|
184
|
+
<ReviewDriverContainer>
|
|
185
|
+
<NavBar
|
|
186
|
+
title={t('REVIEW_DRIVER', 'Review driver')}
|
|
187
|
+
titleAlign={'center'}
|
|
188
|
+
onActionLeft={() => navigation?.canGoBack() && navigation.goBack()}
|
|
189
|
+
showCall={false}
|
|
190
|
+
btnStyle={{ paddingLeft: 0 }}
|
|
191
|
+
style={{ flexDirection: 'column', alignItems: 'flex-start' }}
|
|
192
|
+
titleWrapStyle={{ paddingHorizontal: 0 }}
|
|
193
|
+
titleStyle={{ marginRight: 0, marginLeft: 0 }}
|
|
194
|
+
/>
|
|
195
|
+
<DriverPhotoContainer>
|
|
196
|
+
<View
|
|
197
|
+
style={{
|
|
198
|
+
...styles.photoWrapper,
|
|
199
|
+
backgroundColor: theme.colors.white,
|
|
200
|
+
padding: !order?.driver?.photo ? 5 : 0
|
|
201
|
+
}}
|
|
202
|
+
>
|
|
203
|
+
<OIcon
|
|
204
|
+
url={order?.driver?.photo}
|
|
205
|
+
src={!order?.driver?.photo && theme.images.general.user}
|
|
206
|
+
cover={order?.driver?.photo ? true: false}
|
|
207
|
+
width={80}
|
|
208
|
+
height={80}
|
|
209
|
+
/>
|
|
210
|
+
</View>
|
|
211
|
+
<OText weight={500} style={{ marginVertical: 10 }} color={theme.colors.textNormal}>{order?.driver?.name} {order?.driver?.lastname}</OText>
|
|
212
|
+
</DriverPhotoContainer>
|
|
213
|
+
|
|
214
|
+
<View style={{flex: 1, justifyContent: 'flex-end'}}>
|
|
215
|
+
<FormReviews>
|
|
216
|
+
<OText mBottom={13} color={theme.colors.textNormal}>{t('HOW_WAS_YOUR_DRIVER', 'How was your driver?')}</OText>
|
|
217
|
+
<RatingBarContainer>
|
|
218
|
+
<LinearGradient
|
|
219
|
+
start={{ x: 0.0, y: 0.0 }}
|
|
220
|
+
end={{ x: qualificationList[dirverReviews?.qualification - 1]?.percent || 0, y: 0 }}
|
|
221
|
+
locations={[.9999, .9999]}
|
|
222
|
+
colors={[theme.colors.primary, theme.colors.backgroundGray200]}
|
|
223
|
+
style={styles.statusBar}
|
|
224
|
+
/>
|
|
225
|
+
<RatingTextContainer>
|
|
226
|
+
{qualificationList.map((qualification: any) => (
|
|
227
|
+
<View
|
|
228
|
+
key={qualification.key}
|
|
229
|
+
style={{ ...qualification.parentStyle, ...styles.ratingItemContainer }}
|
|
230
|
+
>
|
|
231
|
+
<TouchableOpacity
|
|
232
|
+
style={qualification.isInnerStyle && styles.ratingItem}
|
|
233
|
+
onPress={() => handleChangeQualification(qualification.key)}
|
|
234
|
+
>
|
|
235
|
+
<View
|
|
236
|
+
style={{
|
|
237
|
+
...styles.ratingLineStyle,
|
|
238
|
+
backgroundColor: (qualification.pointerColor && !(dirverReviews?.qualification >= qualification.key)) ? theme.colors.dusk : 'transparent'
|
|
239
|
+
}}
|
|
240
|
+
/>
|
|
241
|
+
<OText size={12} color={dirverReviews?.qualification === qualification.key ? theme.colors.black : theme.colors.lightGray}>{qualification.text}</OText>
|
|
242
|
+
</TouchableOpacity>
|
|
243
|
+
</View>
|
|
244
|
+
))}
|
|
245
|
+
</RatingTextContainer>
|
|
246
|
+
</RatingBarContainer>
|
|
247
|
+
|
|
248
|
+
<OText style={{ marginTop: 30 }} color={theme.colors.textNormal}>
|
|
249
|
+
{commentsList[dirverReviews?.qualification || 1]?.title}
|
|
250
|
+
</OText>
|
|
251
|
+
<CommentsButtonGroup>
|
|
252
|
+
{commentsList[dirverReviews?.qualification || 1]?.list?.map(commentItem => (
|
|
253
|
+
<OButton
|
|
254
|
+
key={commentItem.key}
|
|
255
|
+
text={commentItem.content}
|
|
256
|
+
bgColor={isSelectedComment(commentItem.key) ? theme.colors.primary : theme.colors.backgroundGray200}
|
|
257
|
+
borderColor={isSelectedComment(commentItem.key) ? theme.colors.primary : theme.colors.backgroundGray200}
|
|
258
|
+
textStyle={{
|
|
259
|
+
color: isSelectedComment(commentItem.key) ? theme.colors.white : theme.colors.textNormal,
|
|
260
|
+
fontSize: 13,
|
|
261
|
+
paddingRight: isSelectedComment(commentItem.key) ? 15 : 0
|
|
262
|
+
}}
|
|
263
|
+
style={{ height: 35, paddingLeft: 5, paddingRight: 5, marginHorizontal: 3, marginVertical: 10 }}
|
|
264
|
+
imgRightSrc={isSelectedComment(commentItem.key) ? theme.images.general.close : null}
|
|
265
|
+
imgRightStyle={{ tintColor: theme.colors.white, right: 5, margin: 5 }}
|
|
266
|
+
onClick={() => handleChangeComment(commentItem) }
|
|
267
|
+
/>
|
|
268
|
+
))}
|
|
269
|
+
</CommentsButtonGroup>
|
|
270
|
+
|
|
271
|
+
<OText style={{ marginTop: 30 }} color={theme.colors.textNormal}>{t('REVIEW_COMMENT_QUESTION', 'Do you want to add something?')}</OText>
|
|
272
|
+
<Controller
|
|
273
|
+
control={control}
|
|
274
|
+
defaultValue=''
|
|
275
|
+
name='comments'
|
|
276
|
+
render={({ onChange }: any) => (
|
|
277
|
+
<OInput
|
|
278
|
+
name='comments'
|
|
279
|
+
onChange={(val: any) => {
|
|
280
|
+
onChange(val)
|
|
281
|
+
setExtraComment(val.target.value)
|
|
282
|
+
}}
|
|
283
|
+
style={styles.inputTextArea}
|
|
284
|
+
multiline
|
|
285
|
+
/>
|
|
286
|
+
)}
|
|
287
|
+
/>
|
|
288
|
+
</FormReviews>
|
|
289
|
+
</View>
|
|
290
|
+
</ReviewDriverContainer>
|
|
291
|
+
<Spinner visible={formState.loading} />
|
|
292
|
+
<FloatingBottomContainer>
|
|
293
|
+
<ActionContainer>
|
|
294
|
+
<OButton
|
|
295
|
+
textStyle={{ color: theme.colors.white, paddingRight: 10 }}
|
|
296
|
+
text={t('SEND_REVIEW', 'Send Review')}
|
|
297
|
+
style={{ borderRadius: 8 }}
|
|
298
|
+
imgRightStyle={{ tintColor: theme.colors.white, right: 5, margin: 5 }}
|
|
299
|
+
onClick={handleSubmit(handleSendReviewClick)}
|
|
300
|
+
/>
|
|
301
|
+
</ActionContainer>
|
|
302
|
+
</FloatingBottomContainer>
|
|
303
|
+
</>
|
|
304
|
+
)
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export const ReviewDriver = (props: any) => {
|
|
308
|
+
const reviewDriverProps = {
|
|
309
|
+
...props,
|
|
310
|
+
UIComponent: ReviewDriverUI,
|
|
311
|
+
isToast: true
|
|
312
|
+
}
|
|
313
|
+
return <ReviewDriverController {...reviewDriverProps} />
|
|
314
|
+
}
|