ordering-ui-react-native 0.16.50 → 0.16.53
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/ReviewProducts/index.tsx +11 -0
- package/src/components/SingleProductReview/index.tsx +1 -1
- package/themes/original/index.tsx +6 -0
- package/themes/original/src/components/BusinessBasicInformation/index.tsx +197 -142
- package/themes/original/src/components/BusinessBasicInformation/styles.tsx +2 -2
- package/themes/original/src/components/BusinessProductsListing/index.tsx +34 -8
- package/themes/original/src/components/BusinessProductsListing/styles.tsx +5 -0
- package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +9 -1
- package/themes/original/src/components/BusinessesListing/Layout/Appointment/styles.tsx +3 -2
- package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +238 -94
- package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +46 -2
- package/themes/original/src/components/BusinessesListing/index.tsx +98 -23
- package/themes/original/src/components/GoogleMap/index.tsx +10 -11
- package/themes/original/src/components/Reviews/ReviewDriver/index.tsx +301 -0
- package/themes/original/src/components/Reviews/ReviewDriver/styles.tsx +39 -0
- package/themes/original/src/components/Reviews/ReviewOrder/index.tsx +326 -0
- package/themes/original/src/components/Reviews/ReviewOrder/styles.tsx +53 -0
- package/themes/original/src/components/Reviews/ReviewProducts/index.tsx +101 -0
- package/themes/original/src/components/Reviews/ReviewProducts/styles.tsx +17 -0
- package/themes/original/src/components/Reviews/index.tsx +9 -0
- package/themes/original/src/components/ServiceForm/index.tsx +15 -5
- package/themes/original/src/components/SignupForm/index.tsx +26 -24
- package/themes/original/src/components/SingleProductCard/index.tsx +113 -103
- package/themes/original/src/components/SingleProductCard/styles.tsx +2 -2
- package/themes/original/src/components/shared/OBottomPopup.tsx +26 -7
- package/themes/original/src/components/shared/OButton.tsx +2 -0
- package/themes/original/src/types/index.tsx +19 -15
|
@@ -1,42 +1,91 @@
|
|
|
1
1
|
|
|
2
2
|
import React, { useState, useEffect } from 'react'
|
|
3
|
-
import { useOrder, useSession } from 'ordering-components/native';
|
|
3
|
+
import { useOrder, useSession, useLanguage } from 'ordering-components/native';
|
|
4
4
|
|
|
5
5
|
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
|
+
import { OBottomPopup } from '../shared';
|
|
9
|
+
import { ReviewOrderModal, ReviewProductsModal, ReviewDriverModal } from '../Reviews'
|
|
8
10
|
|
|
9
11
|
export const BusinessesListing = (props: any) => {
|
|
10
12
|
const theme = useTheme()
|
|
11
|
-
|
|
13
|
+
const layout = theme?.layouts?.business_listing_view?.components?.layout?.type || 'original'
|
|
14
|
+
const [, t] = useLanguage();
|
|
12
15
|
const [{ auth }] = useSession()
|
|
13
16
|
const [, { getLastOrderHasNoReview }] = useOrder();
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
)
|
|
33
|
-
}
|
|
17
|
+
|
|
18
|
+
const [lastOrderReview, setLastOrderReview] = useState({
|
|
19
|
+
isReviewOpen: false,
|
|
20
|
+
order: {
|
|
21
|
+
id: 0,
|
|
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 }
|
|
33
|
+
})
|
|
34
34
|
|
|
35
35
|
const _getLastOrderHasNoReview = async () => {
|
|
36
36
|
const lastOrderHasNoReview = await getLastOrderHasNoReview()
|
|
37
37
|
lastOrderHasNoReview && handleOrderReview(lastOrderHasNoReview)
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
const handleOrderReview = (order: any) => {
|
|
41
|
+
setLastOrderReview({
|
|
42
|
+
isReviewOpen: true,
|
|
43
|
+
order: {
|
|
44
|
+
id: order?.id,
|
|
45
|
+
business_id: order?.business_id,
|
|
46
|
+
business_name: order?.business?.name,
|
|
47
|
+
delivery_datetime: order?.delivery_datetime,
|
|
48
|
+
logo: order.business?.logo,
|
|
49
|
+
driver: order?.driver,
|
|
50
|
+
products: order?.products,
|
|
51
|
+
review: order?.review,
|
|
52
|
+
user_review: order?.user_review
|
|
53
|
+
},
|
|
54
|
+
reviewStatus: { order: true, product: false, driver: false },
|
|
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 }
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const setIsReviewed = (reviewType: string) => {
|
|
68
|
+
const _reviewStatus = { ...lastOrderReview?.reviewed }
|
|
69
|
+
setLastOrderReview({
|
|
70
|
+
...lastOrderReview,
|
|
71
|
+
reviewed: { ..._reviewStatus, [reviewType]: true }
|
|
72
|
+
})
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const closeReviewOrder = () => {
|
|
76
|
+
if (!lastOrderReview?.reviewed?.isProductReviewed) setLastOrderReview({ ...lastOrderReview, reviewStatus: { order: false, product: true, driver: false } })
|
|
77
|
+
else if (lastOrderReview?.order?.driver && !lastOrderReview?.order?.user_review && !lastOrderReview?.reviewed?.isDriverReviewed) setLastOrderReview({ ...lastOrderReview, reviewStatus: { order: false, product: false, driver: true } })
|
|
78
|
+
else handleCloseReivew()
|
|
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
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
40
89
|
useEffect(() => {
|
|
41
90
|
auth && _getLastOrderHasNoReview()
|
|
42
91
|
}, [auth])
|
|
@@ -45,6 +94,32 @@ export const BusinessesListing = (props: any) => {
|
|
|
45
94
|
<>
|
|
46
95
|
{(layout === 'original') && <OriginalBusinessListing {...props} />}
|
|
47
96
|
{(layout === 'appointment') && <AppointmentBusinessListing {...props} />}
|
|
97
|
+
|
|
98
|
+
{lastOrderReview?.isReviewOpen && (
|
|
99
|
+
<OBottomPopup
|
|
100
|
+
open={lastOrderReview?.isReviewOpen}
|
|
101
|
+
onClose={handleCloseReivew}
|
|
102
|
+
title={lastOrderReview?.order
|
|
103
|
+
? (lastOrderReview?.reviewStatus?.order
|
|
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...')}
|
|
109
|
+
bottomContainerStyle={{ height: 'auto' }}
|
|
110
|
+
titleStyle={{ textAlign: 'center' }}
|
|
111
|
+
closeIcon={theme.images.general.close}
|
|
112
|
+
>
|
|
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
|
+
}
|
|
120
|
+
|
|
121
|
+
</OBottomPopup>
|
|
122
|
+
)}
|
|
48
123
|
</>
|
|
49
124
|
)
|
|
50
|
-
}
|
|
125
|
+
}
|
|
@@ -32,6 +32,7 @@ export const GoogleMap = (props: GoogleMapsParams) => {
|
|
|
32
32
|
latitudeDelta: 0.0010,
|
|
33
33
|
longitudeDelta: 0.0010 * ASPECT_RATIO
|
|
34
34
|
})
|
|
35
|
+
const [MARKERS, SETMARKERS] = useState(locations)
|
|
35
36
|
let mapRef = useRef<any>(null)
|
|
36
37
|
const googleMapsApiKey = configState?.configs?.google_maps_api_key?.value
|
|
37
38
|
|
|
@@ -41,12 +42,7 @@ export const GoogleMap = (props: GoogleMapsParams) => {
|
|
|
41
42
|
ERROR_NOT_FOUND_ADDRESS: 'Sorry, we couldn\'t find an address',
|
|
42
43
|
ERROR_MAX_LIMIT_LOCATION: `Sorry, You can only set the position to ${maxLimitLocation}m`
|
|
43
44
|
}
|
|
44
|
-
|
|
45
|
-
return {
|
|
46
|
-
latitude: location.lat,
|
|
47
|
-
longitude: location.lng
|
|
48
|
-
}
|
|
49
|
-
})
|
|
45
|
+
|
|
50
46
|
const geocodePosition = (pos: { latitude: number, longitude: number }) => {
|
|
51
47
|
Geocoder.from({
|
|
52
48
|
latitude: pos.latitude,
|
|
@@ -147,7 +143,7 @@ export const GoogleMap = (props: GoogleMapsParams) => {
|
|
|
147
143
|
}
|
|
148
144
|
|
|
149
145
|
const fitAllMarkers = () => {
|
|
150
|
-
mapRef.current.fitToCoordinates(MARKERS, {
|
|
146
|
+
mapRef.current.fitToCoordinates(MARKERS?.map(location => ({ latitude: location.lat, longitude: location.lng })), {
|
|
151
147
|
edgePadding: { top: 80, right: 80, bottom: 80, left: 80 },
|
|
152
148
|
animated: true,
|
|
153
149
|
});
|
|
@@ -170,6 +166,9 @@ export const GoogleMap = (props: GoogleMapsParams) => {
|
|
|
170
166
|
fitAllMarkers()
|
|
171
167
|
}
|
|
172
168
|
}, 1000)
|
|
169
|
+
if (locations) {
|
|
170
|
+
SETMARKERS(locations)
|
|
171
|
+
}
|
|
173
172
|
return () => clearInterval(interval)
|
|
174
173
|
}, [locations])
|
|
175
174
|
|
|
@@ -189,16 +188,16 @@ export const GoogleMap = (props: GoogleMapsParams) => {
|
|
|
189
188
|
>
|
|
190
189
|
{locations ? (
|
|
191
190
|
<>
|
|
192
|
-
{MARKERS && MARKERS.map((location: {
|
|
191
|
+
{MARKERS && MARKERS.map((location: { lat: number, lng: number }, i: number) => (
|
|
193
192
|
<React.Fragment key={i}>
|
|
194
193
|
{
|
|
195
194
|
<Marker
|
|
196
195
|
zIndex={i}
|
|
197
|
-
coordinate={location}
|
|
198
|
-
title={
|
|
196
|
+
coordinate={{ latitude: location.lat ?? 0, longitude: location.lng ?? 0 }}
|
|
197
|
+
title={MARKERS[i]?.title}
|
|
199
198
|
>
|
|
200
199
|
<View>
|
|
201
|
-
<OIcon url={
|
|
200
|
+
<OIcon url={MARKERS[i].icon} width={50} height={50} />
|
|
202
201
|
</View>
|
|
203
202
|
</Marker>
|
|
204
203
|
}
|
|
@@ -0,0 +1,301 @@
|
|
|
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 LinearGradient from 'react-native-linear-gradient'
|
|
9
|
+
import { FloatingBottomContainer } from '../../../layouts/FloatingBottomContainer'
|
|
10
|
+
import Spinner from 'react-native-loading-spinner-overlay'
|
|
11
|
+
|
|
12
|
+
import { reviewCommentList } from '../../../../../../src/utils'
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
ReviewDriverContainer,
|
|
16
|
+
DriverPhotoContainer,
|
|
17
|
+
FormReviews,
|
|
18
|
+
RatingBarContainer,
|
|
19
|
+
RatingTextContainer,
|
|
20
|
+
CommentsButtonGroup,
|
|
21
|
+
ActionContainer,
|
|
22
|
+
} from './styles'
|
|
23
|
+
|
|
24
|
+
const ReviewDriverUI = (props: ReviewDriverParams) => {
|
|
25
|
+
const {
|
|
26
|
+
order,
|
|
27
|
+
navigation,
|
|
28
|
+
formState,
|
|
29
|
+
dirverReviews,
|
|
30
|
+
setDriverReviews,
|
|
31
|
+
handleSendDriverReview,
|
|
32
|
+
closeReviewDriver
|
|
33
|
+
} = props
|
|
34
|
+
|
|
35
|
+
const [, t] = useLanguage()
|
|
36
|
+
const theme = useTheme()
|
|
37
|
+
const { handleSubmit, control, errors } = useForm()
|
|
38
|
+
const [, { showToast }] = useToast()
|
|
39
|
+
|
|
40
|
+
const [isDriverReviewed, setIsDriverReviewed] = useState(false)
|
|
41
|
+
|
|
42
|
+
const styles = StyleSheet.create({
|
|
43
|
+
photoWrapper: {
|
|
44
|
+
shadowColor: theme.colors.black,
|
|
45
|
+
shadowRadius: 3,
|
|
46
|
+
shadowOffset: { width: 1, height: 4 },
|
|
47
|
+
elevation: 3,
|
|
48
|
+
borderRadius: 8,
|
|
49
|
+
shadowOpacity: 0.1,
|
|
50
|
+
overflow: 'hidden'
|
|
51
|
+
},
|
|
52
|
+
inputTextArea: {
|
|
53
|
+
borderColor: theme.colors.lightGray,
|
|
54
|
+
borderRadius: 8,
|
|
55
|
+
marginTop: 10,
|
|
56
|
+
marginBottom: 40,
|
|
57
|
+
height: 100,
|
|
58
|
+
alignItems: 'flex-start'
|
|
59
|
+
},
|
|
60
|
+
statusBar: {
|
|
61
|
+
transform: [{ scaleX: I18nManager.isRTL ? -1 : 1 }],
|
|
62
|
+
height: 10,
|
|
63
|
+
borderRadius: 5,
|
|
64
|
+
marginTop: 5
|
|
65
|
+
},
|
|
66
|
+
ratingItemContainer: {
|
|
67
|
+
position: 'absolute',
|
|
68
|
+
top: -20
|
|
69
|
+
},
|
|
70
|
+
ratingItem: {
|
|
71
|
+
left: '-50%',
|
|
72
|
+
flexDirection: 'column',
|
|
73
|
+
alignItems: 'center'
|
|
74
|
+
},
|
|
75
|
+
ratingLineStyle: {
|
|
76
|
+
height: 10,
|
|
77
|
+
width: 1,
|
|
78
|
+
marginBottom: 10,
|
|
79
|
+
backgroundColor: theme.colors.dusk
|
|
80
|
+
}
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
const [comments, setComments] = useState<Array<any>>([])
|
|
84
|
+
const [extraComment, setExtraComment] = useState('')
|
|
85
|
+
const [alertState, setAlertState] = useState<{ open: boolean, content: Array<any>, success?: boolean }>({ open: false, content: [], success: false })
|
|
86
|
+
|
|
87
|
+
const qualificationList = [
|
|
88
|
+
{ key: 1, text: t('TERRIBLE', 'Terrible'), percent: 0, parentStyle: { left: '0%' }, isInnerStyle: false, pointerColor: false },
|
|
89
|
+
{ key: 2, text: t('BAD', 'Bad'), percent: 0.25, parentStyle: { left: '25%' }, isInnerStyle: true, pointerColor: true },
|
|
90
|
+
{ key: 3, text: t('OKAY', 'Okay'), percent: 0.5, parentStyle: { left: '50%' }, isInnerStyle: true, pointerColor: true },
|
|
91
|
+
{ key: 4, text: t('GOOD', 'Good'), percent: 0.75, parentStyle: { left: '75%' }, isInnerStyle: true, pointerColor: true },
|
|
92
|
+
{ key: 5, text: t('GREAT', 'Great'), percent: 1, parentStyle: { right: '0%' }, isInnerStyle: false, pointerColor: false }
|
|
93
|
+
]
|
|
94
|
+
|
|
95
|
+
const commentsList = reviewCommentList('driver')
|
|
96
|
+
|
|
97
|
+
const onSubmit = () => {
|
|
98
|
+
if (dirverReviews?.qualification === 0) {
|
|
99
|
+
setAlertState({
|
|
100
|
+
open: true,
|
|
101
|
+
content: dirverReviews?.qualification === 0 ? [`${t('REVIEW_QUALIFICATION_REQUIRED', 'Review qualification is required')}`] : []
|
|
102
|
+
})
|
|
103
|
+
return
|
|
104
|
+
}
|
|
105
|
+
handleSendDriverReview()
|
|
106
|
+
setAlertState({ ...alertState, success: true })
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const isSelectedComment = (commentKey: number) => {
|
|
110
|
+
const found = comments.find((comment: any) => comment?.key === commentKey)
|
|
111
|
+
return found
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const handleChangeComment = (commentItem: any) => {
|
|
115
|
+
const found = comments.find((comment: any) => comment?.key === commentItem.key)
|
|
116
|
+
if (found) {
|
|
117
|
+
const _comments = comments.filter((comment: any) => comment?.key !== commentItem.key)
|
|
118
|
+
setComments(_comments)
|
|
119
|
+
} else {
|
|
120
|
+
setComments([...comments, commentItem])
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const handleChangeQualification = (qualification: number) => {
|
|
125
|
+
if (qualification) setDriverReviews({ ...dirverReviews, qualification: qualification, comment: '' })
|
|
126
|
+
setComments([])
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const handleSendReviewClick = () => {
|
|
130
|
+
(!order?.user_review && !isDriverReviewed) && onSubmit()
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
useEffect(() => {
|
|
134
|
+
if (!formState.loading && formState.result?.error) {
|
|
135
|
+
setAlertState({
|
|
136
|
+
open: true,
|
|
137
|
+
success: false,
|
|
138
|
+
content: formState.result?.result || [t('ERROR', 'Error')]
|
|
139
|
+
})
|
|
140
|
+
}
|
|
141
|
+
if (!formState.loading && !formState.result?.error && alertState.success) {
|
|
142
|
+
setIsDriverReviewed && setIsDriverReviewed(true)
|
|
143
|
+
closeReviewDriver && closeReviewDriver()
|
|
144
|
+
}
|
|
145
|
+
}, [formState])
|
|
146
|
+
|
|
147
|
+
useEffect(() => {
|
|
148
|
+
if (Object.keys(errors).length > 0) {
|
|
149
|
+
// Convert all errors in one string to show in toast provider
|
|
150
|
+
const list = Object.values(errors);
|
|
151
|
+
let stringError = '';
|
|
152
|
+
list.map((item: any, i: number) => {
|
|
153
|
+
stringError +=
|
|
154
|
+
i + 1 === list.length ? `- ${item.message}` : `- ${item.message}\n`;
|
|
155
|
+
});
|
|
156
|
+
showToast(ToastType.Error, stringError);
|
|
157
|
+
}
|
|
158
|
+
}, [errors])
|
|
159
|
+
|
|
160
|
+
useEffect(() => {
|
|
161
|
+
if (alertState.open) {
|
|
162
|
+
alertState.content && showToast(
|
|
163
|
+
ToastType.Error,
|
|
164
|
+
alertState.content
|
|
165
|
+
)
|
|
166
|
+
}
|
|
167
|
+
}, [alertState.content])
|
|
168
|
+
|
|
169
|
+
useEffect(() => {
|
|
170
|
+
let _comments = ''
|
|
171
|
+
if (comments.length > 0) {
|
|
172
|
+
comments.map((comment: any) => (_comments += comment.content + '. '))
|
|
173
|
+
}
|
|
174
|
+
const _comment = _comments + extraComment
|
|
175
|
+
setDriverReviews({ ...dirverReviews, comment: _comment })
|
|
176
|
+
}, [comments, extraComment])
|
|
177
|
+
|
|
178
|
+
return (
|
|
179
|
+
<>
|
|
180
|
+
<ReviewDriverContainer>
|
|
181
|
+
<DriverPhotoContainer>
|
|
182
|
+
<View
|
|
183
|
+
style={{
|
|
184
|
+
...styles.photoWrapper,
|
|
185
|
+
backgroundColor: theme.colors.white,
|
|
186
|
+
padding: !order?.driver?.photo ? 5 : 0
|
|
187
|
+
}}
|
|
188
|
+
>
|
|
189
|
+
<OIcon
|
|
190
|
+
url={order?.driver?.photo}
|
|
191
|
+
src={!order?.driver?.photo && theme.images.general.user}
|
|
192
|
+
cover={order?.driver?.photo ? true : false}
|
|
193
|
+
width={80}
|
|
194
|
+
height={80}
|
|
195
|
+
/>
|
|
196
|
+
</View>
|
|
197
|
+
<OText weight={500} style={{ marginVertical: 10 }} color={theme.colors.textNormal}>{order?.driver?.name} {order?.driver?.lastname}</OText>
|
|
198
|
+
</DriverPhotoContainer>
|
|
199
|
+
|
|
200
|
+
<View style={{ flex: 1, justifyContent: 'flex-end' }}>
|
|
201
|
+
<FormReviews>
|
|
202
|
+
<OText mBottom={13} color={theme.colors.textNormal}>{t('HOW_WAS_YOUR_DRIVER', 'How was your driver?')}</OText>
|
|
203
|
+
<RatingBarContainer>
|
|
204
|
+
<LinearGradient
|
|
205
|
+
start={{ x: 0.0, y: 0.0 }}
|
|
206
|
+
end={{ x: qualificationList[dirverReviews?.qualification - 1]?.percent || 0, y: 0 }}
|
|
207
|
+
locations={[.9999, .9999]}
|
|
208
|
+
colors={[theme.colors.primary, theme.colors.backgroundGray200]}
|
|
209
|
+
style={styles.statusBar}
|
|
210
|
+
/>
|
|
211
|
+
<RatingTextContainer>
|
|
212
|
+
{qualificationList.map((qualification: any) => (
|
|
213
|
+
<View
|
|
214
|
+
key={qualification.key}
|
|
215
|
+
style={{ ...qualification.parentStyle, ...styles.ratingItemContainer }}
|
|
216
|
+
>
|
|
217
|
+
<TouchableOpacity
|
|
218
|
+
style={qualification.isInnerStyle && styles.ratingItem}
|
|
219
|
+
onPress={() => handleChangeQualification(qualification.key)}
|
|
220
|
+
>
|
|
221
|
+
<View
|
|
222
|
+
style={{
|
|
223
|
+
...styles.ratingLineStyle,
|
|
224
|
+
backgroundColor: (qualification.pointerColor && !(dirverReviews?.qualification >= qualification.key)) ? theme.colors.dusk : 'transparent'
|
|
225
|
+
}}
|
|
226
|
+
/>
|
|
227
|
+
<OText size={12} color={dirverReviews?.qualification === qualification.key ? theme.colors.black : theme.colors.lightGray}>{qualification.text}</OText>
|
|
228
|
+
</TouchableOpacity>
|
|
229
|
+
</View>
|
|
230
|
+
))}
|
|
231
|
+
</RatingTextContainer>
|
|
232
|
+
</RatingBarContainer>
|
|
233
|
+
|
|
234
|
+
<OText style={{ marginTop: 30 }} color={theme.colors.textNormal}>
|
|
235
|
+
{commentsList[dirverReviews?.qualification || 1]?.title}
|
|
236
|
+
</OText>
|
|
237
|
+
<CommentsButtonGroup>
|
|
238
|
+
{commentsList[dirverReviews?.qualification || 1]?.list?.map(commentItem => (
|
|
239
|
+
<OButton
|
|
240
|
+
key={commentItem.key}
|
|
241
|
+
text={commentItem.content}
|
|
242
|
+
bgColor={isSelectedComment(commentItem.key) ? theme.colors.primary : theme.colors.backgroundGray200}
|
|
243
|
+
borderColor={isSelectedComment(commentItem.key) ? theme.colors.primary : theme.colors.backgroundGray200}
|
|
244
|
+
textStyle={{
|
|
245
|
+
color: isSelectedComment(commentItem.key) ? theme.colors.white : theme.colors.textNormal,
|
|
246
|
+
fontSize: 13,
|
|
247
|
+
paddingRight: isSelectedComment(commentItem.key) ? 15 : 0
|
|
248
|
+
}}
|
|
249
|
+
style={{ height: 35, paddingLeft: 5, paddingRight: 5, marginHorizontal: 3, marginVertical: 10 }}
|
|
250
|
+
imgRightSrc={isSelectedComment(commentItem.key) ? theme.images.general.close : null}
|
|
251
|
+
imgRightStyle={{ tintColor: theme.colors.white, right: 5, margin: 5 }}
|
|
252
|
+
onClick={() => handleChangeComment(commentItem)}
|
|
253
|
+
/>
|
|
254
|
+
))}
|
|
255
|
+
</CommentsButtonGroup>
|
|
256
|
+
|
|
257
|
+
<OText style={{ marginTop: 30 }} color={theme.colors.textNormal}>{t('REVIEW_COMMENT_QUESTION', 'Do you want to add something?')}</OText>
|
|
258
|
+
<Controller
|
|
259
|
+
control={control}
|
|
260
|
+
defaultValue=''
|
|
261
|
+
name='comments'
|
|
262
|
+
render={({ onChange }: any) => (
|
|
263
|
+
<OInput
|
|
264
|
+
name='comments'
|
|
265
|
+
onChange={(val: any) => {
|
|
266
|
+
onChange(val)
|
|
267
|
+
setExtraComment(val.target.value)
|
|
268
|
+
}}
|
|
269
|
+
style={styles.inputTextArea}
|
|
270
|
+
multiline
|
|
271
|
+
/>
|
|
272
|
+
)}
|
|
273
|
+
/>
|
|
274
|
+
</FormReviews>
|
|
275
|
+
</View>
|
|
276
|
+
</ReviewDriverContainer>
|
|
277
|
+
<Spinner visible={formState.loading} />
|
|
278
|
+
<FloatingBottomContainer>
|
|
279
|
+
<ActionContainer>
|
|
280
|
+
<OButton
|
|
281
|
+
textStyle={{ color: theme.colors.white, paddingRight: 10 }}
|
|
282
|
+
text={t('SEND_REVIEW', 'Send Review')}
|
|
283
|
+
style={{ borderRadius: 8 }}
|
|
284
|
+
imgRightStyle={{ tintColor: theme.colors.white, right: 5, margin: 5 }}
|
|
285
|
+
isDisabled={dirverReviews?.qualification < 1 || dirverReviews?.comment.length < 1}
|
|
286
|
+
onClick={handleSubmit(handleSendReviewClick)}
|
|
287
|
+
/>
|
|
288
|
+
</ActionContainer>
|
|
289
|
+
</FloatingBottomContainer>
|
|
290
|
+
</>
|
|
291
|
+
)
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
export const ReviewDriver = (props: any) => {
|
|
295
|
+
const reviewDriverProps = {
|
|
296
|
+
...props,
|
|
297
|
+
UIComponent: ReviewDriverUI,
|
|
298
|
+
isToast: true
|
|
299
|
+
}
|
|
300
|
+
return <ReviewDriverController {...reviewDriverProps} />
|
|
301
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import styled from 'styled-components/native'
|
|
2
|
+
|
|
3
|
+
export const ReviewDriverContainer = styled.ScrollView`
|
|
4
|
+
padding: 20px 40px;
|
|
5
|
+
margin-bottom: 100px;
|
|
6
|
+
max-height: 400px;
|
|
7
|
+
`
|
|
8
|
+
|
|
9
|
+
export const DriverPhotoContainer = styled.View`
|
|
10
|
+
margin-vertical: 5px;
|
|
11
|
+
flex-direction: column;
|
|
12
|
+
align-items: center;
|
|
13
|
+
`
|
|
14
|
+
|
|
15
|
+
export const FormReviews = styled.View`
|
|
16
|
+
flex: 1;
|
|
17
|
+
height: 100%;
|
|
18
|
+
margin-top: 30px;
|
|
19
|
+
`
|
|
20
|
+
|
|
21
|
+
export const RatingBarContainer = styled.View`
|
|
22
|
+
margin-top: 10px;
|
|
23
|
+
margin-bottom: 25px;
|
|
24
|
+
`
|
|
25
|
+
|
|
26
|
+
export const RatingTextContainer = styled.View`
|
|
27
|
+
flex-direction: row;
|
|
28
|
+
align-items: center;
|
|
29
|
+
justify-content: space-between;
|
|
30
|
+
margin-top: 10px;
|
|
31
|
+
`
|
|
32
|
+
export const CommentsButtonGroup = styled.View`
|
|
33
|
+
flex-direction: row;
|
|
34
|
+
flex-wrap: wrap;
|
|
35
|
+
`
|
|
36
|
+
|
|
37
|
+
export const ActionContainer = styled.View`
|
|
38
|
+
padding: 3px 30px;
|
|
39
|
+
`
|