ordering-ui-external 14.0.5 → 14.0.7
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/_bundles/{7.ordering-ui.e5571322319c3152e419.js → 7.ordering-ui.b2be153972548d48278f.js} +1 -1
- package/_bundles/{ordering-ui.e5571322319c3152e419.js → ordering-ui.b2be153972548d48278f.js} +2 -2
- package/_modules/themes/five/src/components/OrderDetails/OrderBillSection.js +5 -4
- package/_modules/themes/five/src/components/OrderDetails/index.js +32 -8
- package/_modules/themes/five/src/components/OrderDetails/layouts/Starbucks/HeaderContent.js +157 -0
- package/_modules/themes/five/src/components/OrderDetails/layouts/Starbucks/index.js +12 -0
- package/_modules/themes/five/src/components/OrderDetails/layouts/Starbucks/styles.js +37 -0
- package/_modules/themes/five/src/components/ReviewDriver/layouts/Simple/index.js +240 -0
- package/_modules/themes/five/src/components/ReviewDriver/layouts/Simple/styles.js +58 -0
- package/_modules/themes/five/src/components/ReviewOrder/layouts/Simple/index.js +247 -0
- package/_modules/themes/five/src/components/ReviewOrder/layouts/Simple/styles.js +59 -0
- package/index-template.js +11 -1
- package/package.json +2 -2
- package/src/themes/five/src/components/OrderDetails/OrderBillSection.js +190 -185
- package/src/themes/five/src/components/OrderDetails/index.js +257 -216
- package/src/themes/five/src/components/OrderDetails/layouts/Starbucks/HeaderContent.js +168 -0
- package/src/themes/five/src/components/OrderDetails/layouts/Starbucks/index.js +7 -0
- package/src/themes/five/src/components/OrderDetails/layouts/Starbucks/styles.js +148 -0
- package/src/themes/five/src/components/ReviewDriver/layouts/Simple/index.js +205 -0
- package/src/themes/five/src/components/ReviewDriver/layouts/Simple/styles.js +163 -0
- package/src/themes/five/src/components/ReviewOrder/layouts/Simple/index.js +211 -0
- package/src/themes/five/src/components/ReviewOrder/layouts/Simple/styles.js +173 -0
- package/template/assets/icons/delivered.png +0 -0
- package/template/assets/icons/driver.png +0 -0
- package/template/assets/icons/home.png +0 -0
- package/template/assets/icons/store.png +0 -0
- /package/_bundles/{0.ordering-ui.e5571322319c3152e419.js → 0.ordering-ui.b2be153972548d48278f.js} +0 -0
- /package/_bundles/{1.ordering-ui.e5571322319c3152e419.js → 1.ordering-ui.b2be153972548d48278f.js} +0 -0
- /package/_bundles/{2.ordering-ui.e5571322319c3152e419.js → 2.ordering-ui.b2be153972548d48278f.js} +0 -0
- /package/_bundles/{4.ordering-ui.e5571322319c3152e419.js → 4.ordering-ui.b2be153972548d48278f.js} +0 -0
- /package/_bundles/{5.ordering-ui.e5571322319c3152e419.js → 5.ordering-ui.b2be153972548d48278f.js} +0 -0
- /package/_bundles/{6.ordering-ui.e5571322319c3152e419.js → 6.ordering-ui.b2be153972548d48278f.js} +0 -0
- /package/_bundles/{7.ordering-ui.e5571322319c3152e419.js.LICENSE.txt → 7.ordering-ui.b2be153972548d48278f.js.LICENSE.txt} +0 -0
- /package/_bundles/{8.ordering-ui.e5571322319c3152e419.js → 8.ordering-ui.b2be153972548d48278f.js} +0 -0
- /package/_bundles/{9.ordering-ui.e5571322319c3152e419.js → 9.ordering-ui.b2be153972548d48278f.js} +0 -0
- /package/_bundles/{ordering-ui.e5571322319c3152e419.js.LICENSE.txt → ordering-ui.b2be153972548d48278f.js.LICENSE.txt} +0 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react'
|
|
2
|
+
import { useLanguage, useUtils } from 'ordering-components-external'
|
|
3
|
+
import { useTheme } from 'styled-components'
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
Container,
|
|
7
|
+
StatusBarContainer,
|
|
8
|
+
Icon,
|
|
9
|
+
OrderTitle,
|
|
10
|
+
DelayedTime,
|
|
11
|
+
ReviewedText,
|
|
12
|
+
MapWrapper,
|
|
13
|
+
Map
|
|
14
|
+
} from './styles'
|
|
15
|
+
import { PoweredByOrdering } from '../../styles'
|
|
16
|
+
import moment from 'moment'
|
|
17
|
+
import { ReviewOrder } from '../../../ReviewOrder/layouts/Simple'
|
|
18
|
+
import { ReviewDriver } from '../../../ReviewDriver/layouts/Simple'
|
|
19
|
+
|
|
20
|
+
export const HeaderContent = (props) => {
|
|
21
|
+
const {
|
|
22
|
+
order,
|
|
23
|
+
hashKey,
|
|
24
|
+
orderId,
|
|
25
|
+
showReview,
|
|
26
|
+
changeIdToExternalId,
|
|
27
|
+
enabledPoweredByOrdering,
|
|
28
|
+
orderStatus,
|
|
29
|
+
percentage,
|
|
30
|
+
googleMapsUrl
|
|
31
|
+
} = props
|
|
32
|
+
|
|
33
|
+
const theme = useTheme()
|
|
34
|
+
const [, t] = useLanguage()
|
|
35
|
+
const [{ parseDate }] = useUtils()
|
|
36
|
+
|
|
37
|
+
const [reviewState, setReviewState] = useState({ order: false, driver: false })
|
|
38
|
+
|
|
39
|
+
const getDelayMinutes = (order) => {
|
|
40
|
+
const defaultDate = order?.fechaHoraAmasTardar ?? order?.delivery_datetime
|
|
41
|
+
const offset = 300
|
|
42
|
+
const cdtToutc = moment(defaultDate).add(offset, 'minutes').format('YYYY-MM-DD HH:mm:ss')
|
|
43
|
+
const _delivery = order?.delivery_datetime_utc && !order?.fechaHoraAmasTardar
|
|
44
|
+
? parseDate(order?.delivery_datetime_utc, { outputFormat: 'YYYY-MM-DD HH:mm:ss' })
|
|
45
|
+
: parseDate(cdtToutc, { outputFormat: 'YYYY-MM-DD HH:mm:ss' })
|
|
46
|
+
const _eta = order?.eta_time
|
|
47
|
+
const diffTimeAsSeconds = moment(_delivery).add(_eta, 'minutes').diff(moment().utc(), 'seconds')
|
|
48
|
+
return Math.ceil(diffTimeAsSeconds / 60)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const displayDelayedTime = (order) => {
|
|
52
|
+
let tagetedMin = getDelayMinutes(order)
|
|
53
|
+
// get day, hour and minutes
|
|
54
|
+
const sign = tagetedMin >= 0 ? '' : '- '
|
|
55
|
+
tagetedMin = Math.abs(tagetedMin)
|
|
56
|
+
let day = Math.floor(tagetedMin / 1440)
|
|
57
|
+
const restMinOfTargetedMin = tagetedMin - 1440 * day
|
|
58
|
+
let restHours = Math.floor(restMinOfTargetedMin / 60)
|
|
59
|
+
let restMins = restMinOfTargetedMin - 60 * restHours
|
|
60
|
+
// make standard time format
|
|
61
|
+
day = day === 0 ? '' : `${day + ' ' + t('DAY', 'day') + ' '}`
|
|
62
|
+
restHours = restHours < 10 ? '0' + restHours : restHours
|
|
63
|
+
restMins = restMins < 10 ? '0' + restMins : restMins
|
|
64
|
+
|
|
65
|
+
const finalTaget = sign + day + restHours + ':' + restMins
|
|
66
|
+
return finalTaget
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
setReviewState({
|
|
71
|
+
order: !!order?.review,
|
|
72
|
+
driver: !!(order?.driver && order?.user_review)
|
|
73
|
+
})
|
|
74
|
+
}, [order])
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<Container>
|
|
78
|
+
<OrderTitle>
|
|
79
|
+
<div className='left'>
|
|
80
|
+
<h1>
|
|
81
|
+
{t('ORDER', theme?.defaultLanguages?.ORDER || 'Order')}
|
|
82
|
+
{(changeIdToExternalId && orderId.external_id) || `#${orderId.id}`}
|
|
83
|
+
</h1>
|
|
84
|
+
{enabledPoweredByOrdering && (
|
|
85
|
+
<PoweredByOrdering>
|
|
86
|
+
{t('POWERED_BY', 'Powered by')}
|
|
87
|
+
<a href='https://www.ordering.co'>
|
|
88
|
+
{t('ORDERING_CO', 'Ordering.co')}
|
|
89
|
+
</a>
|
|
90
|
+
</PoweredByOrdering>
|
|
91
|
+
)}
|
|
92
|
+
</div>
|
|
93
|
+
<DelayedTime className='center'>
|
|
94
|
+
<div className='ring1'>
|
|
95
|
+
<div className='ring2'>
|
|
96
|
+
<div className='time'>
|
|
97
|
+
<p>{t('DELAYED_TIME_MESSAGE', 'Arriving in')}</p>
|
|
98
|
+
<span>{displayDelayedTime(order)}</span>
|
|
99
|
+
</div>
|
|
100
|
+
</div>
|
|
101
|
+
</div>
|
|
102
|
+
</DelayedTime>
|
|
103
|
+
</OrderTitle>
|
|
104
|
+
<p className='order-status'>{orderStatus}</p>
|
|
105
|
+
<StatusBarContainer percentage={percentage}>
|
|
106
|
+
<Icon
|
|
107
|
+
position={0}
|
|
108
|
+
bgColor={percentage >= 0 && theme.colors.primary}
|
|
109
|
+
>
|
|
110
|
+
<img src={theme.images.icons.store} />
|
|
111
|
+
</Icon>
|
|
112
|
+
<Icon
|
|
113
|
+
position={33.33}
|
|
114
|
+
bgColor={percentage >= 33.33 && theme.colors.primary}
|
|
115
|
+
>
|
|
116
|
+
<img src={theme.images.icons.driver} />
|
|
117
|
+
</Icon>
|
|
118
|
+
<Icon
|
|
119
|
+
position={66.66}
|
|
120
|
+
bgColor={percentage >= 66.66 && theme.colors.primary}
|
|
121
|
+
>
|
|
122
|
+
<img src={theme.images.icons.home} />
|
|
123
|
+
</Icon>
|
|
124
|
+
<Icon
|
|
125
|
+
position={100}
|
|
126
|
+
bgColor={percentage === 100 && theme.colors.primary}
|
|
127
|
+
>
|
|
128
|
+
<img src={theme.images.icons.delivered} />
|
|
129
|
+
</Icon>
|
|
130
|
+
</StatusBarContainer>
|
|
131
|
+
{showReview && !reviewState.order && !order?.review && (
|
|
132
|
+
<ReviewOrder
|
|
133
|
+
order={order}
|
|
134
|
+
hashKey={hashKey}
|
|
135
|
+
defaultStar={5}
|
|
136
|
+
setIsReviewed={() => setReviewState({ ...reviewState, order: true })}
|
|
137
|
+
/>
|
|
138
|
+
)}
|
|
139
|
+
{reviewState.order && !reviewState.driver && order?.driver && !order?.user_review && (
|
|
140
|
+
<ReviewDriver
|
|
141
|
+
order={order}
|
|
142
|
+
hashKey={hashKey}
|
|
143
|
+
defaultStar={5}
|
|
144
|
+
setIsReviewed={() => setReviewState({ ...reviewState, driver: true })}
|
|
145
|
+
/>
|
|
146
|
+
)}
|
|
147
|
+
{(order?.review || reviewState.order) && ((order?.driver && (order?.user_review || reviewState.driver)) || !order?.driver) && (
|
|
148
|
+
<ReviewedText>
|
|
149
|
+
<p>{t('ORDER_ALREADY_REVIEWED_MESSAGE', 'This order has already been attended to, thank you for your preference.')}</p>
|
|
150
|
+
</ReviewedText>
|
|
151
|
+
)}
|
|
152
|
+
{googleMapsUrl && (
|
|
153
|
+
<MapWrapper>
|
|
154
|
+
<Map style={{ width: '100%' }}>
|
|
155
|
+
<img
|
|
156
|
+
src={googleMapsUrl}
|
|
157
|
+
id='google-maps-image'
|
|
158
|
+
alt='google-maps-location'
|
|
159
|
+
width='100%'
|
|
160
|
+
height='100%'
|
|
161
|
+
loading='lazy'
|
|
162
|
+
/>
|
|
163
|
+
</Map>
|
|
164
|
+
</MapWrapper>
|
|
165
|
+
)}
|
|
166
|
+
</Container>
|
|
167
|
+
)
|
|
168
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import styled, { css } from 'styled-components'
|
|
2
|
+
|
|
3
|
+
export const Container = styled.div`
|
|
4
|
+
margin-bottom: 40px;
|
|
5
|
+
|
|
6
|
+
p.order-status {
|
|
7
|
+
text-align: center;
|
|
8
|
+
color: ${props => props.theme.colors.primary || 'black'};
|
|
9
|
+
font-size: 1.3rem;
|
|
10
|
+
margin: 0;
|
|
11
|
+
padding: 0;
|
|
12
|
+
}
|
|
13
|
+
`
|
|
14
|
+
|
|
15
|
+
export const OrderTitle = styled.div`
|
|
16
|
+
display: grid;
|
|
17
|
+
grid-template-columns: 1fr 1fr 1fr;
|
|
18
|
+
|
|
19
|
+
div.left {
|
|
20
|
+
grid-column: 1;
|
|
21
|
+
}
|
|
22
|
+
div.center {
|
|
23
|
+
grid-column: 2;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
h1 {
|
|
27
|
+
font-size: 1.2rem;
|
|
28
|
+
font-weight: normal;
|
|
29
|
+
padding: 0;
|
|
30
|
+
margin: 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
p {
|
|
34
|
+
justify-content: left;
|
|
35
|
+
|
|
36
|
+
a {
|
|
37
|
+
text-decoration: underline !important;
|
|
38
|
+
color: #0000EE !important;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
`
|
|
42
|
+
|
|
43
|
+
export const StatusBarContainer = styled.div`
|
|
44
|
+
position: relative;
|
|
45
|
+
height: 12px;
|
|
46
|
+
margin: 18px 0px 8px;
|
|
47
|
+
background: ${props => `linear-gradient(to right, ${props.theme.colors.primary} ${props.percentage}%, ${props.theme.colors.disabled} ${props.percentage}%)`};
|
|
48
|
+
${props => props.theme?.rtl && css`
|
|
49
|
+
background: linear-gradient(to left, ${props.theme.colors.primary} ${props.percentage}%, ${props.theme.colors.disabled} ${props.percentage}%);
|
|
50
|
+
`}
|
|
51
|
+
`
|
|
52
|
+
|
|
53
|
+
export const Icon = styled.span`
|
|
54
|
+
position: absolute;
|
|
55
|
+
top: 50%;
|
|
56
|
+
font-size: 35px;
|
|
57
|
+
transform: translateY(-50%);
|
|
58
|
+
color: #FFFFFF;
|
|
59
|
+
left: calc(${props => props.position}% - 25px);
|
|
60
|
+
|
|
61
|
+
img {
|
|
62
|
+
width: 50px;
|
|
63
|
+
height: 50px;
|
|
64
|
+
object-fit: contain;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
width: 50px;
|
|
68
|
+
height: 50px;
|
|
69
|
+
background-color: ${props => props.bgColor || props.theme.colors.disabled};
|
|
70
|
+
border-radius: 50%;
|
|
71
|
+
display: flex;
|
|
72
|
+
justify-content: center;
|
|
73
|
+
align-items: center;
|
|
74
|
+
`
|
|
75
|
+
|
|
76
|
+
export const DelayedTime = styled.div`
|
|
77
|
+
display: flex;
|
|
78
|
+
justify-content: center;
|
|
79
|
+
align-items: center;
|
|
80
|
+
border-radius: 50%;
|
|
81
|
+
|
|
82
|
+
div.ring1 {
|
|
83
|
+
border: 6px solid ${props => props.theme.colors.primary};
|
|
84
|
+
padding: 5px;
|
|
85
|
+
border-radius: 50%;
|
|
86
|
+
}
|
|
87
|
+
div.ring2 {
|
|
88
|
+
border: 9px solid ${props => props.theme.colors.primary};
|
|
89
|
+
padding: 5px;
|
|
90
|
+
border-radius: 50%;
|
|
91
|
+
}
|
|
92
|
+
div.time {
|
|
93
|
+
display: flex;
|
|
94
|
+
flex-direction: column;
|
|
95
|
+
justify-content: center;
|
|
96
|
+
align-items: center;
|
|
97
|
+
background-color: ${props => props.theme.colors.primary};
|
|
98
|
+
padding: 10px;
|
|
99
|
+
border-radius: 50%;
|
|
100
|
+
width: 100px;
|
|
101
|
+
height: 100px;
|
|
102
|
+
color: #FFF;
|
|
103
|
+
text-align: center;
|
|
104
|
+
|
|
105
|
+
p {
|
|
106
|
+
margin: 0;
|
|
107
|
+
padding: 0;
|
|
108
|
+
font-size: 14px;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
span {
|
|
112
|
+
font-size: 18px;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
`
|
|
116
|
+
|
|
117
|
+
export const ReviewedText = styled.div`
|
|
118
|
+
display: flex;
|
|
119
|
+
flex-direction: column;
|
|
120
|
+
border-radius: 7.6px;
|
|
121
|
+
padding: 20px;
|
|
122
|
+
box-shadow: 0px 4px 10px 0px #0000001F;
|
|
123
|
+
margin: 55px 0 30px;
|
|
124
|
+
|
|
125
|
+
p {
|
|
126
|
+
font-weight: bold;
|
|
127
|
+
text-align: center;
|
|
128
|
+
}
|
|
129
|
+
`
|
|
130
|
+
|
|
131
|
+
export const MapWrapper = styled.div`
|
|
132
|
+
width: 100%;
|
|
133
|
+
margin-top: 30px;
|
|
134
|
+
`
|
|
135
|
+
|
|
136
|
+
export const Map = styled.div`
|
|
137
|
+
margin-bottom: 10px;
|
|
138
|
+
width: 100%;
|
|
139
|
+
> div {
|
|
140
|
+
position: relative !important;
|
|
141
|
+
width: 100% !important;
|
|
142
|
+
height: 100% !important;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
img {
|
|
146
|
+
object-fit: cover;
|
|
147
|
+
}
|
|
148
|
+
`
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react'
|
|
2
|
+
import { useForm } from 'react-hook-form'
|
|
3
|
+
import { useLanguage, ReviewDriver as ReviewDriverController } from 'ordering-components-external'
|
|
4
|
+
import MdClose from '@meronex/icons/md/MdClose'
|
|
5
|
+
import IfillStar from '@meronex/icons/ai/AiFillStar'
|
|
6
|
+
import IUnfillStar from '@meronex/icons/ai/AiOutlineStar'
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
Container,
|
|
10
|
+
ReviewDriverContainer,
|
|
11
|
+
Comments,
|
|
12
|
+
ReviewsProgressWrapper,
|
|
13
|
+
ReviewsProgressContent,
|
|
14
|
+
LogoAndReviewWrapper,
|
|
15
|
+
CommentsList,
|
|
16
|
+
CommentButton,
|
|
17
|
+
Send
|
|
18
|
+
} from './styles'
|
|
19
|
+
|
|
20
|
+
import { reviewCommentList } from '../../../../../../../utils'
|
|
21
|
+
import { Alert } from '../../../Confirm'
|
|
22
|
+
import { TextArea } from '../../../../styles/Inputs'
|
|
23
|
+
import { Button } from '../../../../styles/Buttons'
|
|
24
|
+
|
|
25
|
+
const ReviewDriverUI = (props) => {
|
|
26
|
+
const {
|
|
27
|
+
dirverReviews,
|
|
28
|
+
formState,
|
|
29
|
+
setDriverReviews,
|
|
30
|
+
setIsReviewed,
|
|
31
|
+
handleSendDriverReview
|
|
32
|
+
} = props
|
|
33
|
+
|
|
34
|
+
const [, t] = useLanguage()
|
|
35
|
+
const { handleSubmit, errors } = useForm()
|
|
36
|
+
const [comments, setComments] = useState([])
|
|
37
|
+
const [extraComment, setExtraComment] = useState('')
|
|
38
|
+
const [alertState, setAlertState] = useState({ open: false, content: [], success: false })
|
|
39
|
+
|
|
40
|
+
const commentsList = reviewCommentList('driver')
|
|
41
|
+
|
|
42
|
+
const qualificationList = [
|
|
43
|
+
{ key: 1, text: t('TERRIBLE', 'Terrible'), middleNode: false, left: 0, right: 'initial' },
|
|
44
|
+
{ key: 2, text: t('BAD', 'Bad'), middleNode: true, left: '25%', right: '75%' },
|
|
45
|
+
{ key: 3, text: t('OKAY', 'Okay'), middleNode: true, left: '50%', right: '50%' },
|
|
46
|
+
{ key: 4, text: t('GOOD', 'Good'), middleNode: true, left: '75%', right: '25%' },
|
|
47
|
+
{ key: 5, text: t('GREAT', 'Great'), middleNode: false, left: 'initial', right: 0 }
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
const handleChangeReviews = (index) => {
|
|
51
|
+
if (index) setDriverReviews({ ...dirverReviews, qualification: index, comment: '' })
|
|
52
|
+
setComments([])
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const handleChangeComment = (commentItem) => {
|
|
56
|
+
const found = comments.find((comment) => comment?.key === commentItem.key)
|
|
57
|
+
if (found) {
|
|
58
|
+
const _comments = comments.filter((comment) => comment?.key !== commentItem.key)
|
|
59
|
+
setComments(_comments)
|
|
60
|
+
} else {
|
|
61
|
+
setComments([...comments, commentItem])
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const isSelectedComment = (commentKey) => {
|
|
66
|
+
const found = comments.find((comment) => comment?.key === commentKey)
|
|
67
|
+
return found
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
if (!formState.loading && formState.result?.error) {
|
|
72
|
+
setAlertState({
|
|
73
|
+
open: true,
|
|
74
|
+
success: false,
|
|
75
|
+
content: formState.result?.result || [t('ERROR', 'Error')]
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
if (!formState.loading && !formState.result?.error && alertState.success) {
|
|
79
|
+
setIsReviewed && setIsReviewed()
|
|
80
|
+
}
|
|
81
|
+
}, [formState])
|
|
82
|
+
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
if (Object.keys(errors).length > 0) {
|
|
85
|
+
setAlertState({
|
|
86
|
+
open: true,
|
|
87
|
+
success: false,
|
|
88
|
+
content: Object.values(errors).map(error => error.message)
|
|
89
|
+
})
|
|
90
|
+
}
|
|
91
|
+
}, [errors])
|
|
92
|
+
|
|
93
|
+
const onSubmit = values => {
|
|
94
|
+
if (dirverReviews?.qualification === 0) {
|
|
95
|
+
setAlertState({
|
|
96
|
+
open: true,
|
|
97
|
+
content: [`${t('REVIEW_QUALIFICATION_REQUIRED', 'Review qualification is required')}`]
|
|
98
|
+
})
|
|
99
|
+
return
|
|
100
|
+
}
|
|
101
|
+
setAlertState({ ...alertState, success: true })
|
|
102
|
+
handleSendDriverReview()
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const closeAlert = () => {
|
|
106
|
+
setAlertState({
|
|
107
|
+
open: false,
|
|
108
|
+
content: []
|
|
109
|
+
})
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
useEffect(() => {
|
|
113
|
+
let _comments = ''
|
|
114
|
+
if (comments.length > 0) {
|
|
115
|
+
comments.map(comment => (_comments += comment.content + '. '))
|
|
116
|
+
}
|
|
117
|
+
const _comment = _comments + extraComment
|
|
118
|
+
setDriverReviews({ ...dirverReviews, comment: _comment })
|
|
119
|
+
}, [comments, extraComment])
|
|
120
|
+
|
|
121
|
+
return (
|
|
122
|
+
<Container>
|
|
123
|
+
<LogoAndReviewWrapper>
|
|
124
|
+
<ReviewsProgressWrapper>
|
|
125
|
+
<p style={{ fontWeight: 'bold' }}>{t('HOW_WAS_YOUR_DRIVER', 'How was your driver?')}</p>
|
|
126
|
+
<ReviewsProgressContent>
|
|
127
|
+
{
|
|
128
|
+
qualificationList?.map(qualification => (
|
|
129
|
+
<div
|
|
130
|
+
key={qualification?.key}
|
|
131
|
+
>
|
|
132
|
+
{qualification?.key <= dirverReviews?.qualification
|
|
133
|
+
? <IfillStar onClick={() => handleChangeReviews(qualification?.key)} />
|
|
134
|
+
: <IUnfillStar onClick={() => handleChangeReviews(qualification?.key)} />}
|
|
135
|
+
</div>
|
|
136
|
+
))
|
|
137
|
+
}
|
|
138
|
+
</ReviewsProgressContent>
|
|
139
|
+
</ReviewsProgressWrapper>
|
|
140
|
+
{dirverReviews?.qualification <= 3 && (
|
|
141
|
+
<CommentsList>
|
|
142
|
+
<p>{commentsList[dirverReviews?.qualification || 1]?.title}</p>
|
|
143
|
+
{
|
|
144
|
+
commentsList[dirverReviews?.qualification || 1]?.list?.map((commentItem, i) => (
|
|
145
|
+
<CommentButton
|
|
146
|
+
key={i}
|
|
147
|
+
active={isSelectedComment(commentItem.key)}
|
|
148
|
+
onClick={() => handleChangeComment(commentItem)}
|
|
149
|
+
initialIcon
|
|
150
|
+
>
|
|
151
|
+
{commentItem.content}
|
|
152
|
+
{isSelectedComment(commentItem.key) && <MdClose />}
|
|
153
|
+
</CommentButton>
|
|
154
|
+
))
|
|
155
|
+
}
|
|
156
|
+
</CommentsList>
|
|
157
|
+
)}
|
|
158
|
+
</LogoAndReviewWrapper>
|
|
159
|
+
<ReviewDriverContainer onSubmit={handleSubmit(onSubmit)}>
|
|
160
|
+
<Comments>
|
|
161
|
+
<p>{t('DO_YOU_WANT_TO_ADD_SOMETHING', 'Do you want to add something?')}</p>
|
|
162
|
+
<TextArea
|
|
163
|
+
name='comment'
|
|
164
|
+
value={extraComment}
|
|
165
|
+
onChange={(e) => setExtraComment(e.target.value)}
|
|
166
|
+
autoComplete='off'
|
|
167
|
+
/>
|
|
168
|
+
</Comments>
|
|
169
|
+
<Send>
|
|
170
|
+
<Button
|
|
171
|
+
color={!formState.loading ? 'primary' : 'secondary'}
|
|
172
|
+
type='submit'
|
|
173
|
+
disabled={formState.loading}
|
|
174
|
+
className='review-sent'
|
|
175
|
+
>
|
|
176
|
+
{!formState.loading ? (
|
|
177
|
+
t('SEND_REVIEW', 'Send review')
|
|
178
|
+
) : t('LOADING', 'Loading')}
|
|
179
|
+
</Button>
|
|
180
|
+
</Send>
|
|
181
|
+
<Alert
|
|
182
|
+
title={t('DRIVER_REVIEW', 'Driver Review')}
|
|
183
|
+
content={alertState.content}
|
|
184
|
+
acceptText={t('ACCEPT', 'Accept')}
|
|
185
|
+
open={alertState.open}
|
|
186
|
+
onClose={() => closeAlert()}
|
|
187
|
+
onAccept={() => closeAlert()}
|
|
188
|
+
closeOnBackdrop={false}
|
|
189
|
+
/>
|
|
190
|
+
</ReviewDriverContainer>
|
|
191
|
+
</Container>
|
|
192
|
+
)
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export const ReviewDriver = (props) => {
|
|
196
|
+
const reviewDriverProps = {
|
|
197
|
+
...props,
|
|
198
|
+
UIComponent: ReviewDriverUI,
|
|
199
|
+
isToast: true
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return <ReviewDriverController {...reviewDriverProps} />
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export default ReviewDriver
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import styled, { css } from 'styled-components'
|
|
2
|
+
import { Button } from '../../../../styles/Buttons'
|
|
3
|
+
|
|
4
|
+
export const Container = styled.div`
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
border-radius: 7.6px;
|
|
8
|
+
padding: 20px;
|
|
9
|
+
box-shadow: 0px 4px 10px 0px #0000001F;
|
|
10
|
+
margin: 55px 0 30px;
|
|
11
|
+
`
|
|
12
|
+
|
|
13
|
+
export const ReviewDriverContainer = styled.form`
|
|
14
|
+
display: flex;
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
align-items: center;
|
|
17
|
+
width: 100%;
|
|
18
|
+
`
|
|
19
|
+
|
|
20
|
+
export const Comments = styled.div`
|
|
21
|
+
display: flex;
|
|
22
|
+
width: 100%;
|
|
23
|
+
flex-direction: column;
|
|
24
|
+
margin-top: 10px;
|
|
25
|
+
|
|
26
|
+
p {
|
|
27
|
+
margin-top: 0;
|
|
28
|
+
margin-bottom: 10px;
|
|
29
|
+
font-size: 15px;
|
|
30
|
+
color: ${props => props.theme?.colors.darkTextColor};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
textarea {
|
|
34
|
+
min-height: 104px;
|
|
35
|
+
}
|
|
36
|
+
`
|
|
37
|
+
|
|
38
|
+
export const ReviewsProgressWrapper = styled.div`
|
|
39
|
+
width: 100%;
|
|
40
|
+
margin-bottom: 20px;
|
|
41
|
+
|
|
42
|
+
p {
|
|
43
|
+
margin-top: 0;
|
|
44
|
+
margin-bottom: 17px;
|
|
45
|
+
font-size: 15px;
|
|
46
|
+
color: ${props => props.theme?.colors.darkTextColor};
|
|
47
|
+
text-align: center;
|
|
48
|
+
}
|
|
49
|
+
`
|
|
50
|
+
|
|
51
|
+
export const ReviewsProgressContent = styled.div`
|
|
52
|
+
display: flex;
|
|
53
|
+
flex-direction: row;
|
|
54
|
+
justify-content: center;
|
|
55
|
+
|
|
56
|
+
svg {
|
|
57
|
+
font-size: 4rem;
|
|
58
|
+
color: ${props => props.theme?.colors.primary};
|
|
59
|
+
cursor: pointer;
|
|
60
|
+
}
|
|
61
|
+
`
|
|
62
|
+
|
|
63
|
+
export const LogoAndReviewWrapper = styled.div`
|
|
64
|
+
width: 100%;
|
|
65
|
+
display: flex;
|
|
66
|
+
flex-direction: column;
|
|
67
|
+
`
|
|
68
|
+
|
|
69
|
+
export const CommentsList = styled.div`
|
|
70
|
+
p {
|
|
71
|
+
margin-top: 0;
|
|
72
|
+
margin-bottom: 10px;
|
|
73
|
+
font-size: 15px;
|
|
74
|
+
color: ${props => props.theme?.colors.darkTextColor};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
button {
|
|
78
|
+
border-radius: 7.6px;
|
|
79
|
+
margin-bottom: 18px;
|
|
80
|
+
margin-right: 40px;
|
|
81
|
+
|
|
82
|
+
${props => props.theme?.rtl && css`
|
|
83
|
+
margin-left: 40px;
|
|
84
|
+
margin-right: 0;
|
|
85
|
+
`}
|
|
86
|
+
|
|
87
|
+
svg {
|
|
88
|
+
vertical-align: middle;
|
|
89
|
+
margin-left: 5px;
|
|
90
|
+
|
|
91
|
+
${props => props.theme?.rtl && css`
|
|
92
|
+
margin-right: 5px;
|
|
93
|
+
margin-left: 0;
|
|
94
|
+
`}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
`
|
|
98
|
+
|
|
99
|
+
export const CommentButton = styled(Button)`
|
|
100
|
+
border-radius: 7.6px;
|
|
101
|
+
margin-bottom: 18px;
|
|
102
|
+
margin-right: 18px;
|
|
103
|
+
font-size: 13px;
|
|
104
|
+
color: #414954;
|
|
105
|
+
background: #E9ECEF;
|
|
106
|
+
border: 1px solid #E9ECEF;
|
|
107
|
+
transition: all 0.3s linear;
|
|
108
|
+
|
|
109
|
+
${props => props.theme?.rtl && css`
|
|
110
|
+
margin-left: 18px;
|
|
111
|
+
margin-right: 0;
|
|
112
|
+
`}
|
|
113
|
+
|
|
114
|
+
svg {
|
|
115
|
+
vertical-align: middle;
|
|
116
|
+
margin-left: 5px;
|
|
117
|
+
|
|
118
|
+
${props => props.theme?.rtl && css`
|
|
119
|
+
margin-right: 5px;
|
|
120
|
+
margin-left: 0;
|
|
121
|
+
`}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
${({ active }) => active && css`
|
|
125
|
+
background: ${props => props.theme?.colors.primary};
|
|
126
|
+
border: 1px solid ${props => props.theme?.colors.primary};
|
|
127
|
+
color: white;
|
|
128
|
+
`}
|
|
129
|
+
`
|
|
130
|
+
|
|
131
|
+
export const Send = styled.div`
|
|
132
|
+
display: flex;
|
|
133
|
+
align-items: center;
|
|
134
|
+
justify-content: flex-end;
|
|
135
|
+
margin-top: 30px;
|
|
136
|
+
width: 100%;
|
|
137
|
+
|
|
138
|
+
span {
|
|
139
|
+
cursor: pointer;
|
|
140
|
+
font-weight: 600;
|
|
141
|
+
font-size: 16px;
|
|
142
|
+
user-select: none;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
button {
|
|
146
|
+
font-size: 14px;
|
|
147
|
+
padding: 6px 20px;
|
|
148
|
+
width: 300px;
|
|
149
|
+
height: 45px;
|
|
150
|
+
line-height: 0;
|
|
151
|
+
svg {
|
|
152
|
+
color: white;
|
|
153
|
+
font-size: 21px;
|
|
154
|
+
vertical-align: middle;
|
|
155
|
+
margin-left: 8px;
|
|
156
|
+
${props => props.theme?.rtl && css`
|
|
157
|
+
margin-left: 0;
|
|
158
|
+
margin-right: 8px;
|
|
159
|
+
transform: rotateZ(180deg);
|
|
160
|
+
`}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
`
|