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
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react'
|
|
2
|
+
import { useLanguage, useToast, ToastType, ReviewProduct as ReviewProductController } from 'ordering-components/native'
|
|
3
|
+
import { OText, OButton } from '../shared'
|
|
4
|
+
import NavBar from '../NavBar'
|
|
5
|
+
import { ReviewProductParams } from '../../types'
|
|
6
|
+
import { FloatingBottomContainer } from '../../layouts/FloatingBottomContainer'
|
|
7
|
+
import { useTheme } from 'styled-components/native'
|
|
8
|
+
import { SingleProductReview } from '../SingleProductReview'
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
ReviewProductsContainer,
|
|
12
|
+
ActionContainer,
|
|
13
|
+
SkipButton
|
|
14
|
+
} from './styles'
|
|
15
|
+
|
|
16
|
+
const ReviewProductsUI = (props: ReviewProductParams) => {
|
|
17
|
+
const {
|
|
18
|
+
navigation,
|
|
19
|
+
order,
|
|
20
|
+
onNavigationRedirect,
|
|
21
|
+
formState,
|
|
22
|
+
handleChangeFormState,
|
|
23
|
+
handleSendProductReview
|
|
24
|
+
} = props
|
|
25
|
+
|
|
26
|
+
const [, t] = useLanguage()
|
|
27
|
+
const theme = useTheme()
|
|
28
|
+
const [, { showToast }] = useToast()
|
|
29
|
+
|
|
30
|
+
const [isProductReviewed, setIsProductReviewed] = useState(false)
|
|
31
|
+
const [alertState, setAlertState] = useState<{ open: boolean, content: Array<any>, success?: boolean }>({ open: false, content: [], success: false })
|
|
32
|
+
|
|
33
|
+
const handleContinueClick = () => {
|
|
34
|
+
setAlertState({ ...alertState, success: true })
|
|
35
|
+
handleSendProductReview()
|
|
36
|
+
}
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (alertState.open) {
|
|
39
|
+
alertState.content && showToast(
|
|
40
|
+
ToastType.Error,
|
|
41
|
+
alertState.content
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
}, [alertState.content])
|
|
45
|
+
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (!formState.loading && formState.result?.error) {
|
|
48
|
+
setAlertState({
|
|
49
|
+
open: true,
|
|
50
|
+
success: false,
|
|
51
|
+
content: formState.result?.result || [t('ERROR', 'Error')]
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
if (!formState.loading && !formState.result?.error && alertState.success) {
|
|
55
|
+
setIsProductReviewed && setIsProductReviewed(true)
|
|
56
|
+
if (order?.driver && !order?.user_review) {
|
|
57
|
+
onNavigationRedirect('ReviewDriver', { order: order })
|
|
58
|
+
} else {
|
|
59
|
+
onNavigationRedirect('MyOrders')
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}, [formState])
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<>
|
|
66
|
+
<ReviewProductsContainer>
|
|
67
|
+
<NavBar
|
|
68
|
+
title={t('REVIEW_PRODUCT', 'Review product')}
|
|
69
|
+
titleAlign={'center'}
|
|
70
|
+
onActionLeft={() => onNavigationRedirect('MyOrders')}
|
|
71
|
+
showCall={false}
|
|
72
|
+
btnStyle={{ paddingLeft: 0 }}
|
|
73
|
+
style={{ flexDirection: 'column', alignItems: 'flex-start' }}
|
|
74
|
+
titleWrapStyle={{ paddingHorizontal: 0 }}
|
|
75
|
+
titleStyle={{ marginRight: 0, marginLeft: 0 }}
|
|
76
|
+
/>
|
|
77
|
+
{order?.products.map((product: any) => (
|
|
78
|
+
<SingleProductReview
|
|
79
|
+
key={product.id}
|
|
80
|
+
product={product}
|
|
81
|
+
formState={formState}
|
|
82
|
+
handleChangeFormState={handleChangeFormState}
|
|
83
|
+
/>
|
|
84
|
+
))}
|
|
85
|
+
</ReviewProductsContainer>
|
|
86
|
+
|
|
87
|
+
<FloatingBottomContainer>
|
|
88
|
+
<ActionContainer>
|
|
89
|
+
<SkipButton
|
|
90
|
+
onPress={() => (order?.driver && !order?.user_review) ? onNavigationRedirect('ReviewDriver', { order: order }) : onNavigationRedirect('MyOrders')}
|
|
91
|
+
>
|
|
92
|
+
<OText weight={700} size={18} color={theme.colors.textNormal}>{t('FRONT_VISUALS_SKIP', 'Skip')}</OText>
|
|
93
|
+
</SkipButton>
|
|
94
|
+
<OButton
|
|
95
|
+
textStyle={{ color: theme.colors.white, paddingRight: 10 }}
|
|
96
|
+
text={order?.driver && !order?.user_review ? t('CONTINUE', 'Continue') : t('SEND_REVIEW', 'Send Review')}
|
|
97
|
+
style={{ borderRadius: 8 }}
|
|
98
|
+
imgRightSrc={theme.images.general.arrow_right}
|
|
99
|
+
imgRightStyle={{ tintColor: theme.colors.white, right: 5, margin: 5 }}
|
|
100
|
+
isDisabled={formState.loading || formState?.changes?.length === 0}
|
|
101
|
+
onClick={() => handleContinueClick()}
|
|
102
|
+
/>
|
|
103
|
+
</ActionContainer>
|
|
104
|
+
</FloatingBottomContainer>
|
|
105
|
+
</>
|
|
106
|
+
)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export const ReviewProducts = (props: any) => {
|
|
110
|
+
const reviewProductProps = {
|
|
111
|
+
...props,
|
|
112
|
+
UIComponent: ReviewProductsUI,
|
|
113
|
+
isToast: true
|
|
114
|
+
}
|
|
115
|
+
return <ReviewProductController {...reviewProductProps} />
|
|
116
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import styled from 'styled-components/native'
|
|
2
|
+
|
|
3
|
+
export const ReviewProductsContainer = styled.ScrollView`
|
|
4
|
+
padding: 20px 40px;
|
|
5
|
+
margin-bottom: 100px;
|
|
6
|
+
`
|
|
7
|
+
|
|
8
|
+
export const ActionContainer = styled.View`
|
|
9
|
+
flex-direction: row;
|
|
10
|
+
align-items: center;
|
|
11
|
+
justify-content: space-between;
|
|
12
|
+
padding: 3px 30px;
|
|
13
|
+
`
|
|
14
|
+
|
|
15
|
+
export const SkipButton = styled.TouchableOpacity`
|
|
16
|
+
`
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react'
|
|
2
|
+
import { useLanguage } from 'ordering-components/native'
|
|
3
|
+
import { OText, OButton, OInput } from '../shared'
|
|
4
|
+
import { StyleSheet, TouchableOpacity, View } from 'react-native'
|
|
5
|
+
import AntDesignIcons from 'react-native-vector-icons/AntDesign'
|
|
6
|
+
import { useTheme } from 'styled-components/native'
|
|
7
|
+
import { SingleProductReviewParams } from '../../types'
|
|
8
|
+
|
|
9
|
+
import { reviewCommentList } from '../../../../../src/utils'
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
ProductContainer,
|
|
13
|
+
ProductHeader,
|
|
14
|
+
LikeHandsActionContainer,
|
|
15
|
+
LikeHandsButton,
|
|
16
|
+
CommentsButtonGroup,
|
|
17
|
+
} from './styles'
|
|
18
|
+
|
|
19
|
+
export const SingleProductReview = (props: SingleProductReviewParams) => {
|
|
20
|
+
const {
|
|
21
|
+
product,
|
|
22
|
+
formState,
|
|
23
|
+
handleChangeFormState,
|
|
24
|
+
} = props
|
|
25
|
+
|
|
26
|
+
const [, t] = useLanguage()
|
|
27
|
+
const theme = useTheme()
|
|
28
|
+
|
|
29
|
+
const styles = StyleSheet.create({
|
|
30
|
+
inputTextArea: {
|
|
31
|
+
borderColor: theme.colors.lightGray,
|
|
32
|
+
borderRadius: 8,
|
|
33
|
+
marginTop: 10,
|
|
34
|
+
marginBottom: 40,
|
|
35
|
+
height: 100,
|
|
36
|
+
alignItems: 'flex-start'
|
|
37
|
+
},
|
|
38
|
+
additionalCommentButton: {
|
|
39
|
+
flexDirection: 'row',
|
|
40
|
+
justifyContent: 'center',
|
|
41
|
+
marginVertical: 10,
|
|
42
|
+
},
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
const [comments, setComments] = useState<Array<any>>([])
|
|
46
|
+
const [extraComment, setExtraComment] = useState('')
|
|
47
|
+
const [isShowTextArea, setIsShowTextArea] = useState(false)
|
|
48
|
+
const [qualification, setQualification] = useState(5)
|
|
49
|
+
|
|
50
|
+
const commentsList = reviewCommentList('product')
|
|
51
|
+
|
|
52
|
+
const isSelectedComment = (commentKey: number) => {
|
|
53
|
+
const found = comments.find((comment: any) => comment?.key === commentKey)
|
|
54
|
+
return found
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const handleChangeComment = (commentItem: any) => {
|
|
58
|
+
const found = comments.find((comment: any) => comment?.key === commentItem.key)
|
|
59
|
+
if (found) {
|
|
60
|
+
const _comments = comments.filter((comment: any) => comment?.key !== commentItem.key)
|
|
61
|
+
setComments(_comments)
|
|
62
|
+
} else {
|
|
63
|
+
setComments([...comments, commentItem])
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
if (comments?.length === 0 && !extraComment && formState.changes?.length === 0 && qualification === 5) return
|
|
69
|
+
let _comments = ''
|
|
70
|
+
if (comments.length > 0) {
|
|
71
|
+
comments.map(comment => (_comments += comment.content + '. '))
|
|
72
|
+
}
|
|
73
|
+
const _comment = _comments + extraComment
|
|
74
|
+
let found = false
|
|
75
|
+
const _changes = formState.changes.map((item: any) => {
|
|
76
|
+
if (item?.product_id === product?.product_id) {
|
|
77
|
+
found = true
|
|
78
|
+
return {
|
|
79
|
+
product_id: product?.product_id,
|
|
80
|
+
comment: _comment,
|
|
81
|
+
qualification: qualification
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return item
|
|
85
|
+
})
|
|
86
|
+
if (!found) {
|
|
87
|
+
_changes.push({
|
|
88
|
+
product_id: product?.product_id,
|
|
89
|
+
comment: _comment,
|
|
90
|
+
qualification: qualification
|
|
91
|
+
})
|
|
92
|
+
}
|
|
93
|
+
handleChangeFormState && handleChangeFormState(_changes)
|
|
94
|
+
}, [comments, extraComment, qualification])
|
|
95
|
+
|
|
96
|
+
return (
|
|
97
|
+
<>
|
|
98
|
+
<ProductContainer>
|
|
99
|
+
<ProductHeader>
|
|
100
|
+
<OText numberOfLines={1} style={{ flex: 1 }} color={theme.colors.textNormal}>{product?.name}</OText>
|
|
101
|
+
<LikeHandsActionContainer>
|
|
102
|
+
<LikeHandsButton
|
|
103
|
+
isLike
|
|
104
|
+
onPress={() => setQualification(5)}
|
|
105
|
+
>
|
|
106
|
+
<AntDesignIcons name='like2' size={20} color={qualification === 5 ? theme.colors.primary : theme.colors.lightGray} />
|
|
107
|
+
</LikeHandsButton>
|
|
108
|
+
<LikeHandsButton onPress={() => setQualification(1)}>
|
|
109
|
+
<AntDesignIcons name='dislike2' size={20} color={qualification === 1 ? theme.colors.primary : theme.colors.lightGray} />
|
|
110
|
+
</LikeHandsButton>
|
|
111
|
+
</LikeHandsActionContainer>
|
|
112
|
+
</ProductHeader>
|
|
113
|
+
<CommentsButtonGroup>
|
|
114
|
+
{commentsList[qualification === 5 ? 'like' : 'dislike']?.map(commentItem => (
|
|
115
|
+
<OButton
|
|
116
|
+
key={commentItem.key}
|
|
117
|
+
text={commentItem.content}
|
|
118
|
+
bgColor={isSelectedComment(commentItem.key) ? theme.colors.primary : theme.colors.backgroundGray200}
|
|
119
|
+
borderColor={isSelectedComment(commentItem.key) ? theme.colors.primary : theme.colors.backgroundGray200}
|
|
120
|
+
textStyle={{
|
|
121
|
+
color: isSelectedComment(commentItem.key) ? theme.colors.white : theme.colors.textNormal,
|
|
122
|
+
fontSize: 13,
|
|
123
|
+
paddingRight: isSelectedComment(commentItem.key) ? 15 : 0
|
|
124
|
+
}}
|
|
125
|
+
style={{ height: 35, paddingLeft: 5, paddingRight: 5, marginHorizontal: 3, marginVertical: 10 }}
|
|
126
|
+
imgRightSrc={isSelectedComment(commentItem.key) ? theme.images.general.close : null}
|
|
127
|
+
imgRightStyle={{ tintColor: theme.colors.white, right: 5, margin: 5 }}
|
|
128
|
+
onClick={() => handleChangeComment(commentItem) }
|
|
129
|
+
/>
|
|
130
|
+
))}
|
|
131
|
+
</CommentsButtonGroup>
|
|
132
|
+
<TouchableOpacity
|
|
133
|
+
style={styles.additionalCommentButton}
|
|
134
|
+
onPress={() => setIsShowTextArea(!isShowTextArea)}
|
|
135
|
+
>
|
|
136
|
+
<OText
|
|
137
|
+
color={isShowTextArea ? theme.colors.primary : theme.colors.disabled}
|
|
138
|
+
style={{
|
|
139
|
+
borderBottomColor: isShowTextArea ? theme.colors.primary : theme.colors.disabled,
|
|
140
|
+
borderBottomWidth: 1
|
|
141
|
+
}}
|
|
142
|
+
>
|
|
143
|
+
{t('ADDITIONAL_COMMENTS', 'Additional comments')}
|
|
144
|
+
</OText>
|
|
145
|
+
</TouchableOpacity>
|
|
146
|
+
{isShowTextArea && (
|
|
147
|
+
<View>
|
|
148
|
+
<OText style={{ marginTop: 10 }} color={theme.colors.textNormal}>{t('REVIEW_COMMENT_QUESTION', 'Do you want to add something?')}</OText>
|
|
149
|
+
<OInput
|
|
150
|
+
name='comments'
|
|
151
|
+
onChange={(val: any) => {
|
|
152
|
+
setExtraComment(val.target.value)
|
|
153
|
+
}}
|
|
154
|
+
style={styles.inputTextArea}
|
|
155
|
+
multiline
|
|
156
|
+
/>
|
|
157
|
+
</View>
|
|
158
|
+
)}
|
|
159
|
+
</ProductContainer>
|
|
160
|
+
</>
|
|
161
|
+
)
|
|
162
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import styled, { css } from 'styled-components/native'
|
|
2
|
+
|
|
3
|
+
export const ProductContainer = styled.View`
|
|
4
|
+
margin-bottom: 15px;
|
|
5
|
+
`
|
|
6
|
+
|
|
7
|
+
export const ProductHeader = styled.View`
|
|
8
|
+
flex-direction: row;
|
|
9
|
+
align-items: center;
|
|
10
|
+
justify-content: space-between;
|
|
11
|
+
margin-bottom: 10px;
|
|
12
|
+
`
|
|
13
|
+
|
|
14
|
+
export const LikeHandsActionContainer = styled.View`
|
|
15
|
+
flex-direction: row;
|
|
16
|
+
`
|
|
17
|
+
|
|
18
|
+
export const LikeHandsButton = styled.TouchableOpacity`
|
|
19
|
+
${(props: any) => props.isLike && css`
|
|
20
|
+
margin-horizontal: 15px;
|
|
21
|
+
`}
|
|
22
|
+
`
|
|
23
|
+
|
|
24
|
+
export const CommentsButtonGroup = styled.View`
|
|
25
|
+
flex-direction: row;
|
|
26
|
+
flex-wrap: wrap;
|
|
27
|
+
`
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import styled from 'styled-components/native'
|
|
3
|
+
import { Platform, Dimensions } from 'react-native'
|
|
4
|
+
const windowWidth = Dimensions.get('window').width
|
|
5
|
+
|
|
6
|
+
export const Container = styled.View`
|
|
7
|
+
position: absolute;
|
|
8
|
+
flex: 1;
|
|
9
|
+
bottom: 0px;
|
|
10
|
+
left: 0;
|
|
11
|
+
right: 0;
|
|
12
|
+
padding: 10px;
|
|
13
|
+
border-top-width: 1px;
|
|
14
|
+
border-color: ${(props: any) => props.theme.colors.backgroundGray200};
|
|
15
|
+
z-index: 1000;
|
|
16
|
+
background-color: ${(props: any) => props.bgColor ? props.bgColor : '#FFF'};
|
|
17
|
+
padding-bottom: ${Platform.OS === 'ios' ? '20px' : '10px'};
|
|
18
|
+
`
|
|
19
|
+
|
|
20
|
+
export const FloatingBottomContainer = (props: any) => {
|
|
21
|
+
return (
|
|
22
|
+
<Container style={{ width: windowWidth }}>
|
|
23
|
+
{props.children}
|
|
24
|
+
</Container>
|
|
25
|
+
)
|
|
26
|
+
}
|
|
@@ -329,13 +329,40 @@ export interface ProductItemAccordionParams {
|
|
|
329
329
|
isFromCheckout?: any
|
|
330
330
|
}
|
|
331
331
|
export interface ReviewOrderParams {
|
|
332
|
-
order?: {
|
|
332
|
+
order?: { id: number, businessId: number, logo: string, driver: any, products: Array<any>, review: any, user_review: any },
|
|
333
333
|
stars?: any,
|
|
334
334
|
handleChangeInput?: any,
|
|
335
335
|
handleChangeRating?: any,
|
|
336
336
|
handleSendReview?: any,
|
|
337
337
|
formState?: any,
|
|
338
|
-
navigation?: any
|
|
338
|
+
navigation?: any,
|
|
339
|
+
setIsReviewed?: (isReviewed: boolean) => {},
|
|
340
|
+
handleReviewState?: any,
|
|
341
|
+
setStars?: any,
|
|
342
|
+
onNavigationRedirect?: any
|
|
343
|
+
}
|
|
344
|
+
export interface ReviewProductParams {
|
|
345
|
+
navigation?: any,
|
|
346
|
+
onNavigationRedirect?: any,
|
|
347
|
+
order?: { orderId: number, businessId: number, logo: string, driver: any, products: Array<any>, review: any, user_review: any },
|
|
348
|
+
formState?: any,
|
|
349
|
+
handleChangeFormState?: any,
|
|
350
|
+
handleSendProductReview?: any
|
|
351
|
+
}
|
|
352
|
+
export interface SingleProductReviewParams {
|
|
353
|
+
product: any,
|
|
354
|
+
formState?: any,
|
|
355
|
+
handleChangeFormState?: any,
|
|
356
|
+
}
|
|
357
|
+
export interface ReviewDriverParams {
|
|
358
|
+
navigation?: any,
|
|
359
|
+
onNavigationRedirect?: any,
|
|
360
|
+
order?: { orderId: number, businessId: number, logo: string, driver: any, products: Array<any>, review: any, user_review: any },
|
|
361
|
+
formState?: any,
|
|
362
|
+
setIsDriverReviewed?: (isReviewed: boolean) => {},
|
|
363
|
+
dirverReviews?: any,
|
|
364
|
+
setDriverReviews?: any,
|
|
365
|
+
handleSendDriverReview?: any
|
|
339
366
|
}
|
|
340
367
|
export interface MessagesParams {
|
|
341
368
|
type?: string,
|