ordering-ui-react-native 0.11.54 → 0.11.58
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/OrderCreating/index.tsx +8 -4
- package/src/config.json +1 -1
- package/themes/instacart/index.tsx +4 -0
- package/themes/instacart/src/components/BusinessItemAccordion/index.tsx +16 -41
- package/themes/instacart/src/components/BusinessItemAccordion/styles.tsx +4 -6
- package/themes/instacart/src/components/BusinessesListing/index.tsx +2 -2
- package/themes/instacart/src/components/Cart/index.tsx +8 -5
- package/themes/instacart/src/components/Cart/styles.tsx +11 -0
- package/themes/instacart/src/components/CartContent/index.tsx +2 -1
- package/themes/instacart/src/components/NavBar/index.tsx +4 -2
- package/themes/instacart/src/components/PreviousOrders/index.tsx +1 -1
- package/themes/instacart/src/components/ReviewDriver/index.tsx +221 -0
- package/themes/instacart/src/components/ReviewDriver/styles.tsx +46 -0
- package/themes/instacart/src/components/ReviewOrder/index.tsx +304 -185
- package/themes/instacart/src/components/ReviewOrder/styles.tsx +18 -3
- package/themes/instacart/src/components/ReviewProduct/index.tsx +275 -0
- package/themes/instacart/src/components/ReviewProduct/styles.tsx +53 -0
- package/themes/instacart/src/components/SingleProductCard/index.tsx +8 -8
- package/themes/instacart/src/components/SingleProductCard/styles.tsx +4 -5
- package/themes/instacart/src/components/TagSelector/index.tsx +94 -0
- package/themes/instacart/src/components/TagSelector/styles.ts +0 -0
- package/themes/instacart/src/components/shared/OBottomStickBar.tsx +62 -0
- package/themes/instacart/src/config/constants.tsx +25 -1
- package/themes/instacart/src/types/index.tsx +25 -2
- package/themes/original/src/components/AddressForm/index.tsx +6 -2
- package/themes/original/src/components/FloatingButton/index.tsx +3 -2
- package/themes/original/src/components/FloatingButton/styles.tsx +2 -2
- package/themes/original/src/components/LoginForm/index.tsx +7 -2
- package/themes/original/src/components/ProductForm/index.tsx +5 -1
- package/themes/original/src/components/ProductForm/styles.tsx +3 -1
- package/themes/original/src/components/SignupForm/index.tsx +7 -2
- package/themes/original/src/components/UserDetails/index.tsx +3 -2
- package/themes/original/src/components/UserFormDetails/styles.tsx +0 -1
- package/themes/original/src/components/shared/OInput.tsx +1 -0
- package/themes/original/src/layouts/Container.tsx +4 -1
- package/themes/single-business/src/components/Checkout/index.tsx +2 -2
- package/themes/single-business/src/components/ForgotPasswordForm/index.tsx +2 -2
- package/themes/single-business/src/components/LastOrder/index.tsx +1 -1
- package/themes/single-business/src/components/LoginForm/index.tsx +1 -1
- package/themes/single-business/src/components/ReviewOrder/index.tsx +1 -1
- package/themes/single-business/src/components/SignupForm/index.tsx +1 -1
- package/themes/single-business/src/components/StripeRedirectForm/index.tsx +1 -1
- package/themes/single-business/src/components/UserFormDetails/index.tsx +1 -1
- package/themes/single-business/src/components/UserProfile/index.tsx +1 -1
- package/themes/single-business/src/components/UserProfileForm/index.tsx +1 -1
- package/themes/single-business/src/components/shared/OToast.tsx +1 -1
package/package.json
CHANGED
|
@@ -67,13 +67,17 @@ export const OrderCreating = (props: any) => {
|
|
|
67
67
|
let hour = 0
|
|
68
68
|
let min = 0
|
|
69
69
|
if (orderState?.options?.type === 1 && cart) {
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
if (cart?.business?.delivery_time) {
|
|
71
|
+
hour = (cart?.business?.delivery_time).split(':')[0]
|
|
72
|
+
min = (cart?.business?.delivery_time).split(':')[1]
|
|
73
|
+
}
|
|
72
74
|
}
|
|
73
75
|
|
|
74
76
|
if (orderState?.options?.type === 2 && cart) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
+
if (cart?.business?.pickup_time) {
|
|
78
|
+
hour = (cart?.business?.pickup_time).split(':')[0]
|
|
79
|
+
min = (cart?.business?.pickup_time).split(':')[1]
|
|
80
|
+
}
|
|
77
81
|
}
|
|
78
82
|
return getHourMin(hour, min)
|
|
79
83
|
}
|
package/src/config.json
CHANGED
|
@@ -35,6 +35,8 @@ import {
|
|
|
35
35
|
OText,
|
|
36
36
|
OToast
|
|
37
37
|
} from './src/components/shared';
|
|
38
|
+
import { ReviewProduct } from './src/components/ReviewProduct';
|
|
39
|
+
import { ReviewDriver } from './src/components/ReviewDriver';
|
|
38
40
|
|
|
39
41
|
export {
|
|
40
42
|
Home as HomePage,
|
|
@@ -59,6 +61,8 @@ export {
|
|
|
59
61
|
OrdersOption,
|
|
60
62
|
UserProfileForm,
|
|
61
63
|
ReviewOrder,
|
|
64
|
+
ReviewProduct,
|
|
65
|
+
ReviewDriver,
|
|
62
66
|
|
|
63
67
|
// OComponents
|
|
64
68
|
OAlert,
|
|
@@ -46,6 +46,7 @@ export const BusinessItemAccordion = (props: any) => {
|
|
|
46
46
|
<BIContainer isClosed={isClosed}>
|
|
47
47
|
<BIHeader
|
|
48
48
|
isClosed={isClosed}
|
|
49
|
+
isExpanded={isActive}
|
|
49
50
|
onPress={() => isExpanded ? {} : !isClosed ? setActiveState(!isActive) : isClosed}
|
|
50
51
|
activeOpacity={1}
|
|
51
52
|
>
|
|
@@ -53,80 +54,54 @@ export const BusinessItemAccordion = (props: any) => {
|
|
|
53
54
|
{cart?.business?.logo && (
|
|
54
55
|
<OIcon
|
|
55
56
|
url={cart?.business?.logo}
|
|
56
|
-
width={
|
|
57
|
-
height={
|
|
58
|
-
style={{ borderRadius:
|
|
57
|
+
width={42}
|
|
58
|
+
height={42}
|
|
59
|
+
style={{ borderRadius: 22, borderColor: '#E9ECEF', borderWidth: 1 }}
|
|
59
60
|
/>
|
|
60
61
|
)}
|
|
61
62
|
<BIContentInfo>
|
|
62
|
-
<OText>{cart?.business?.name}</OText>
|
|
63
|
-
{orderState?.options?.type === 1 ? (
|
|
63
|
+
<OText style={{marginBottom: 2}}>{cart?.business?.name}</OText>
|
|
64
|
+
{/* {orderState?.options?.type === 1 ? (
|
|
64
65
|
<View style={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}>
|
|
65
66
|
<MaterialCommunityIcon
|
|
66
67
|
name='clock-outline'
|
|
67
|
-
size={
|
|
68
|
+
size={14}
|
|
69
|
+
color={'gray'}
|
|
70
|
+
style={{marginEnd: 4}}
|
|
68
71
|
/>
|
|
69
|
-
<OText>{convertHoursToMinutes(cart?.business?.delivery_time)}</OText>
|
|
72
|
+
<OText size={12}>{convertHoursToMinutes(cart?.business?.delivery_time)}</OText>
|
|
70
73
|
</View>
|
|
71
74
|
) : (
|
|
72
75
|
<View style={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}>
|
|
73
76
|
<MaterialCommunityIcon
|
|
74
77
|
name='clock-outline'
|
|
75
|
-
size={
|
|
78
|
+
size={14}
|
|
76
79
|
/>
|
|
77
80
|
<OText>{convertHoursToMinutes(cart?.business?.pickup_time)}</OText>
|
|
78
81
|
</View>
|
|
79
|
-
)}
|
|
82
|
+
)} */}
|
|
80
83
|
</BIContentInfo>
|
|
81
84
|
</BIInfo>
|
|
82
85
|
|
|
83
86
|
{!isClosed && !!isProducts && cart?.valid_products && cart?.total > 0 && (
|
|
84
87
|
<BITotal>
|
|
85
|
-
<OText color='#000'>{parsePrice(cart?.total)}</OText>
|
|
86
|
-
<
|
|
88
|
+
<OText weight={'bold'} color='#000'>{parsePrice(cart?.total)}</OText>
|
|
89
|
+
{/* {!isActive && <MaterialCommunityIcon name='chevron-down' size={20} />} */}
|
|
87
90
|
</BITotal>
|
|
88
91
|
)}
|
|
89
92
|
|
|
90
93
|
{isClosed && (
|
|
91
94
|
<BITotal>
|
|
92
|
-
<OText>{t('CLOSED', 'Closed')} {moment}</OText>
|
|
95
|
+
<OText size={12}>{t('CLOSED', 'Closed')} {moment}</OText>
|
|
93
96
|
</BITotal>
|
|
94
97
|
)}
|
|
95
98
|
|
|
96
99
|
{!isClosed && !isProducts && (
|
|
97
100
|
<BITotal>
|
|
98
|
-
<OText>{t('NO_PRODUCTS', 'No products')}</OText>
|
|
101
|
+
<OText size={12}>{t('NO_PRODUCTS', 'No products')}</OText>
|
|
99
102
|
</BITotal>
|
|
100
103
|
)}
|
|
101
104
|
|
|
102
|
-
<BIActions>
|
|
103
|
-
{props.onNavigationRedirect && !isClosed && (
|
|
104
|
-
<MaterialCommunityIcon
|
|
105
|
-
name='store'
|
|
106
|
-
size={26}
|
|
107
|
-
color='#CCC'
|
|
108
|
-
onPress={() => props.onNavigationRedirect('Business', { store: cart?.business?.slug })}
|
|
109
|
-
/>
|
|
110
|
-
)}
|
|
111
|
-
{!isClosed && !!isProducts && (
|
|
112
|
-
<>
|
|
113
|
-
{!isCartPending && (
|
|
114
|
-
<OAlert
|
|
115
|
-
title={t('DELETE_CART', 'Delete Cart')}
|
|
116
|
-
message={t('QUESTION_DELETE_CART', 'Are you sure to you wants delete the selected cart')}
|
|
117
|
-
onAccept={() => handleClearProducts()}
|
|
118
|
-
>
|
|
119
|
-
<MaterialCommunityIcon
|
|
120
|
-
name='trash-can-outline'
|
|
121
|
-
size={26}
|
|
122
|
-
color='#D81212'
|
|
123
|
-
/>
|
|
124
|
-
</OAlert>
|
|
125
|
-
)}
|
|
126
|
-
{!isExpanded && <MaterialCommunityIcon name='chevron-down' size={20} />}
|
|
127
|
-
</>
|
|
128
|
-
)}
|
|
129
|
-
</BIActions>
|
|
130
105
|
</BIHeader>
|
|
131
106
|
|
|
132
107
|
<BIContent style={{ display: isActive ? 'flex' : 'none' }}>
|
|
@@ -18,11 +18,10 @@ export const BIHeader = styled.TouchableOpacity`
|
|
|
18
18
|
align-items: center;
|
|
19
19
|
justify-content: space-between;
|
|
20
20
|
position: relative;
|
|
21
|
-
padding: 10px;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
background-color: rgba(0, 0, 0, 0.1);
|
|
21
|
+
padding: 10px 0;
|
|
22
|
+
${(props: any) => props.isExpanded && `
|
|
23
|
+
border-bottom-width: 1px;
|
|
24
|
+
border-bottom-color: #EFEFEF;
|
|
26
25
|
`}
|
|
27
26
|
`
|
|
28
27
|
|
|
@@ -46,7 +45,6 @@ export const BIContentInfo = styled.View`
|
|
|
46
45
|
`
|
|
47
46
|
|
|
48
47
|
export const BITotal = styled.View`
|
|
49
|
-
width: 25%;
|
|
50
48
|
display: flex;
|
|
51
49
|
flex-direction: column;
|
|
52
50
|
align-items: center;
|
|
@@ -141,12 +141,12 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
|
|
|
141
141
|
</View>
|
|
142
142
|
|
|
143
143
|
</OrderControlContainer>
|
|
144
|
-
|
|
144
|
+
<BusinessTypeFilter
|
|
145
145
|
images={props.images}
|
|
146
146
|
businessTypes={props.businessTypes}
|
|
147
147
|
defaultBusinessType={props.defaultBusinessType}
|
|
148
148
|
handleChangeBusinessType={handleChangeBusinessType}
|
|
149
|
-
/>
|
|
149
|
+
/>
|
|
150
150
|
|
|
151
151
|
{
|
|
152
152
|
!businessesList.loading && businessesList.businesses.length === 0 && (
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
useValidationFields,
|
|
9
9
|
} from 'ordering-components/native';
|
|
10
10
|
|
|
11
|
-
import { CContainer, CheckoutAction } from './styles';
|
|
11
|
+
import { CContainer, CheckoutAction, TotalCont } from './styles';
|
|
12
12
|
|
|
13
13
|
import { OSBill, OSTable, OSCoupon, OSTotal } from '../OrderSummary/styles';
|
|
14
14
|
|
|
@@ -32,7 +32,7 @@ const CartUI = (props: any) => {
|
|
|
32
32
|
removeProduct,
|
|
33
33
|
handleCartOpen,
|
|
34
34
|
setIsCartsLoading,
|
|
35
|
-
|
|
35
|
+
isExpanded
|
|
36
36
|
} = props
|
|
37
37
|
|
|
38
38
|
const theme = useTheme()
|
|
@@ -99,7 +99,7 @@ const CartUI = (props: any) => {
|
|
|
99
99
|
handleClearProducts={handleClearProducts}
|
|
100
100
|
handleCartOpen={handleCartOpen}
|
|
101
101
|
onNavigationRedirect={props.onNavigationRedirect}
|
|
102
|
-
|
|
102
|
+
isExpanded={isExpanded}
|
|
103
103
|
>
|
|
104
104
|
{cart?.products?.length > 0 && cart?.products.map((product: any) => (
|
|
105
105
|
<ProductItemAccordion
|
|
@@ -217,7 +217,7 @@ const CartUI = (props: any) => {
|
|
|
217
217
|
<CheckoutAction>
|
|
218
218
|
<OButton
|
|
219
219
|
text={(cart?.subtotal >= cart?.minimum || !cart?.minimum) && cart?.valid_address ? (
|
|
220
|
-
!openUpselling !== canOpenUpselling ? t('
|
|
220
|
+
!openUpselling !== canOpenUpselling ? t('GO_TO_CHECKOUT', 'Go to checkout') : t('LOADING', 'Loading')
|
|
221
221
|
) : !cart?.valid_address ? (
|
|
222
222
|
`${t('OUT_OF_COVERAGE', 'Out of Coverage')}`
|
|
223
223
|
) : (
|
|
@@ -229,8 +229,11 @@ const CartUI = (props: any) => {
|
|
|
229
229
|
imgRightSrc={null}
|
|
230
230
|
textStyle={{ color: 'white', textAlign: 'center', flex: 1 }}
|
|
231
231
|
onClick={() => setOpenUpselling(true)}
|
|
232
|
-
style={{ width: '100%', flexDirection: 'row', justifyContent: 'center' }}
|
|
232
|
+
style={{ width: '100%', flexDirection: 'row', justifyContent: 'center', borderRadius: 3 }}
|
|
233
233
|
/>
|
|
234
|
+
<TotalCont>
|
|
235
|
+
<OText color={'white'}>{cart?.total >= 1 && parsePrice(cart?.total)}</OText>
|
|
236
|
+
</TotalCont>
|
|
234
237
|
</CheckoutAction>
|
|
235
238
|
)}
|
|
236
239
|
</BusinessItemAccordion>
|
|
@@ -26,3 +26,14 @@ export const CheckoutAction = styled.View`
|
|
|
26
26
|
margin-top: 10px;
|
|
27
27
|
margin-bottom: 10px;
|
|
28
28
|
`
|
|
29
|
+
|
|
30
|
+
export const TotalCont = styled.View`
|
|
31
|
+
position: absolute;
|
|
32
|
+
end: 10px;
|
|
33
|
+
top: 10px;
|
|
34
|
+
background-color: rgba(0,0,0, 0.16);
|
|
35
|
+
align-items: center;
|
|
36
|
+
justify-content: center;
|
|
37
|
+
padding: 6px 7px;
|
|
38
|
+
border-radius: 4px;
|
|
39
|
+
`
|
|
@@ -21,7 +21,7 @@ export const CartContent = (props: any) => {
|
|
|
21
21
|
{isOrderStateCarts && carts?.length > 0 && (
|
|
22
22
|
<>
|
|
23
23
|
<OText style={{ fontSize: 28 }}>
|
|
24
|
-
{carts.length > 1 ? t('
|
|
24
|
+
{carts.length > 1 ? t('MY_CARTS', 'My carts') : t('CART', 'Cart')}
|
|
25
25
|
</OText>
|
|
26
26
|
{carts.map((cart: any) => (
|
|
27
27
|
<CCList key={cart.uuid}>
|
|
@@ -31,6 +31,7 @@ export const CartContent = (props: any) => {
|
|
|
31
31
|
onNavigationRedirect={props.onNavigationRedirect}
|
|
32
32
|
isCartsLoading={isCartsLoading}
|
|
33
33
|
setIsCartsLoading={setIsCartsLoading}
|
|
34
|
+
isExpanded={false}
|
|
34
35
|
/>
|
|
35
36
|
)}
|
|
36
37
|
</CCList>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react'
|
|
2
2
|
import styled, { useTheme } from 'styled-components/native'
|
|
3
3
|
import { OButton, OIcon, OText } from '../shared'
|
|
4
|
-
import { TextStyle } from 'react-native'
|
|
4
|
+
import { ImageStyle, TextStyle } from 'react-native'
|
|
5
5
|
|
|
6
6
|
const Wrapper = styled.View`
|
|
7
7
|
background-color: ${(props: any) => props.theme.colors.white};
|
|
@@ -50,6 +50,8 @@ interface Props {
|
|
|
50
50
|
btnStyle?: TextStyle,
|
|
51
51
|
style?: TextStyle,
|
|
52
52
|
paddingTop?: number,
|
|
53
|
+
isVertical?: boolean;
|
|
54
|
+
leftImageStyle?: ImageStyle;
|
|
53
55
|
}
|
|
54
56
|
|
|
55
57
|
const NavBar = (props: Props) => {
|
|
@@ -63,7 +65,7 @@ const NavBar = (props: Props) => {
|
|
|
63
65
|
<Wrapper style={{ paddingTop: props.paddingTop, ...props.style }}>
|
|
64
66
|
<OButton
|
|
65
67
|
imgLeftSrc={props.leftImg || theme.images.general.arrow_left}
|
|
66
|
-
imgLeftStyle={{tintColor: theme.colors.primary}}
|
|
68
|
+
imgLeftStyle={{tintColor: theme.colors.primary, ...props.leftImageStyle}}
|
|
67
69
|
imgRightSrc={null}
|
|
68
70
|
style={{ ...btnBackArrow, ...props.btnStyle }}
|
|
69
71
|
onClick={props.onActionLeft}
|
|
@@ -56,7 +56,7 @@ export const PreviousOrders = (props: PreviousOrdersParams) => {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
const handleClickOrderReview = (order: any) => {
|
|
59
|
-
onNavigationRedirect && onNavigationRedirect('ReviewOrder', { order: { id: order?.id, business_id: order?.business_id, logo: order.business?.logo } })
|
|
59
|
+
onNavigationRedirect && onNavigationRedirect('ReviewOrder', { order: { id: order?.id, business_id: order?.business_id, logo: order.business?.logo, products: order?.products } })
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
const handleReorderClick = (id: number) => {
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import React, { useState, useEffect, useCallback } from 'react'
|
|
2
|
+
import { ReviewDriver as ReviewDriverController, useLanguage, ToastType, useToast } from 'ordering-components/native'
|
|
3
|
+
import { useTheme } from 'styled-components/native';
|
|
4
|
+
import MaterialCommunityIcon from 'react-native-vector-icons/MaterialCommunityIcons'
|
|
5
|
+
import { useForm, Controller } from 'react-hook-form'
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
ReviewOrderContainer,
|
|
9
|
+
BusinessLogo,
|
|
10
|
+
FormReviews,
|
|
11
|
+
Category,
|
|
12
|
+
Stars,
|
|
13
|
+
BlockWrap,
|
|
14
|
+
CommentItem
|
|
15
|
+
} from './styles'
|
|
16
|
+
import { OButton, OIcon, OInput, OText } from '../shared'
|
|
17
|
+
import { TouchableOpacity, StyleSheet, View } from 'react-native';
|
|
18
|
+
import NavBar from '../NavBar'
|
|
19
|
+
import Spinner from 'react-native-loading-spinner-overlay'
|
|
20
|
+
|
|
21
|
+
import { ReviewDriverParams } from '../../types'
|
|
22
|
+
import { REVIEW_DRIVER_COMMENTS } from '../../config/constants';
|
|
23
|
+
import TagSelector from '../TagSelector';
|
|
24
|
+
import OBottomStickBar from '../shared/OBottomStickBar';
|
|
25
|
+
import { Container } from '../../..';
|
|
26
|
+
|
|
27
|
+
export const ReviewDriverUI = (props: ReviewDriverParams) => {
|
|
28
|
+
const {
|
|
29
|
+
dirverReviews,
|
|
30
|
+
order,
|
|
31
|
+
formState,
|
|
32
|
+
setDriverReviews,
|
|
33
|
+
closeReviewDriver,
|
|
34
|
+
setIsDriverReviewed,
|
|
35
|
+
handleSendDriverReview,
|
|
36
|
+
navigation
|
|
37
|
+
} = props
|
|
38
|
+
|
|
39
|
+
const theme = useTheme();
|
|
40
|
+
|
|
41
|
+
const styles = StyleSheet.create({
|
|
42
|
+
inputTextArea: {
|
|
43
|
+
borderColor: theme.colors.border,
|
|
44
|
+
borderRadius: 7.6,
|
|
45
|
+
marginVertical: 10,
|
|
46
|
+
height: 100,
|
|
47
|
+
alignItems: 'flex-start',
|
|
48
|
+
paddingVertical: 12,
|
|
49
|
+
fontSize: 10,
|
|
50
|
+
marginBottom: 30
|
|
51
|
+
},
|
|
52
|
+
progress: {
|
|
53
|
+
borderRadius: 5,
|
|
54
|
+
height: 4,
|
|
55
|
+
backgroundColor: theme.colors.backgroundGray200,
|
|
56
|
+
marginVertical: 9,
|
|
57
|
+
},
|
|
58
|
+
progressLabel: {
|
|
59
|
+
flexDirection: 'row',
|
|
60
|
+
justifyContent: 'space-between',
|
|
61
|
+
},
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
const [, t] = useLanguage()
|
|
65
|
+
const [, { showToast }] = useToast()
|
|
66
|
+
const { handleSubmit, control, errors } = useForm()
|
|
67
|
+
|
|
68
|
+
const [alertState, setAlertState] = useState<{ open: boolean, content: Array<any>, success?: boolean }>({ open: false, content: [], success: false })
|
|
69
|
+
|
|
70
|
+
const [curVal, setReviewVal] = useState(-1);
|
|
71
|
+
const [curSuggest] = useState(REVIEW_DRIVER_COMMENTS.map(({key, value}) => t(key, value)));
|
|
72
|
+
const [selectedSuggest, setSelectedSuggest] = useState([]);
|
|
73
|
+
const [comment, setComment] = useState('');
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
// const handleChangeReviews = (index) => {
|
|
77
|
+
// if (index) setDriverReviews({ ...dirverReviews, qualification: index })
|
|
78
|
+
// }
|
|
79
|
+
|
|
80
|
+
const onSubmit = () => {
|
|
81
|
+
if (dirverReviews?.qualification === 0) {
|
|
82
|
+
setAlertState({
|
|
83
|
+
open: true,
|
|
84
|
+
content: [`${t('REVIEW_QUALIFICATION_REQUIRED', 'Review qualification is required')}`]
|
|
85
|
+
})
|
|
86
|
+
return
|
|
87
|
+
}
|
|
88
|
+
setAlertState({ ...alertState, success: true })
|
|
89
|
+
handleSendDriverReview()
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const onSuggestUpdate = useCallback((items) => {
|
|
93
|
+
if (items.length > 0) {
|
|
94
|
+
let selected: Array<never> = [];
|
|
95
|
+
items.map(({label, checked}: never) => {
|
|
96
|
+
if (checked === true) {
|
|
97
|
+
selected.push(label);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
setSelectedSuggest(selected);
|
|
101
|
+
}
|
|
102
|
+
}, []);
|
|
103
|
+
|
|
104
|
+
const handleNext = (type: number) => {
|
|
105
|
+
if (type == 1) handleSubmit(onSubmit)
|
|
106
|
+
navigation?.navigate('BottomTab', { screen: 'MyOrders' });
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
useEffect(() => {
|
|
110
|
+
if (formState.error && !formState?.loading) {
|
|
111
|
+
showToast(ToastType.Error, formState.result)
|
|
112
|
+
}
|
|
113
|
+
if (!formState.loading && !formState.error && alertState.success) {
|
|
114
|
+
showToast(ToastType.Success, t('REVIEW_SUCCESS_CONTENT', 'Thank you, Review successfully submitted!'))
|
|
115
|
+
setIsDriverReviewed && setIsDriverReviewed(true)
|
|
116
|
+
handleNext(0);
|
|
117
|
+
}
|
|
118
|
+
}, [formState.result])
|
|
119
|
+
|
|
120
|
+
useEffect(() => {
|
|
121
|
+
if (Object.keys(errors).length > 0) {
|
|
122
|
+
// Convert all errors in one string to show in toast provider
|
|
123
|
+
const list = Object.values(errors);
|
|
124
|
+
let stringError = '';
|
|
125
|
+
list.map((item: any, i: number) => {
|
|
126
|
+
stringError +=
|
|
127
|
+
i + 1 === list.length ? `- ${item.message}` : `- ${item.message}\n`;
|
|
128
|
+
});
|
|
129
|
+
showToast(ToastType.Error, stringError);
|
|
130
|
+
}
|
|
131
|
+
}, [errors]);
|
|
132
|
+
|
|
133
|
+
useEffect(() => {
|
|
134
|
+
if (alertState.open) {
|
|
135
|
+
alertState.content && showToast(
|
|
136
|
+
ToastType.Error,
|
|
137
|
+
alertState.content
|
|
138
|
+
)
|
|
139
|
+
}
|
|
140
|
+
}, [alertState.content])
|
|
141
|
+
|
|
142
|
+
useEffect(() => {
|
|
143
|
+
let _comments = comment || '';
|
|
144
|
+
if (selectedSuggest.length > 0) {
|
|
145
|
+
_comments = _comments + ', ' + selectedSuggest.join(', ');
|
|
146
|
+
}
|
|
147
|
+
setDriverReviews({ ...dirverReviews, comment: _comments, qualification: 5 })
|
|
148
|
+
}, [comment, selectedSuggest])
|
|
149
|
+
|
|
150
|
+
return (
|
|
151
|
+
<>
|
|
152
|
+
<Container>
|
|
153
|
+
<ReviewOrderContainer>
|
|
154
|
+
<NavBar
|
|
155
|
+
title={t('REVIEW_ORDER', 'Review Order')}
|
|
156
|
+
titleAlign={'center'}
|
|
157
|
+
onActionLeft={() => navigation?.canGoBack() && navigation.goBack()}
|
|
158
|
+
showCall={false}
|
|
159
|
+
btnStyle={{ paddingLeft: 0 }}
|
|
160
|
+
paddingTop={0}
|
|
161
|
+
isVertical
|
|
162
|
+
leftImg={theme.images.general.close}
|
|
163
|
+
leftImageStyle={{width: 16}}
|
|
164
|
+
/>
|
|
165
|
+
<BusinessLogo>
|
|
166
|
+
<OIcon
|
|
167
|
+
url={order?.driver?.photo || theme.images.dummies.driverPhoto}
|
|
168
|
+
width={72} height={72}
|
|
169
|
+
style={{borderRadius: 7.6, backgroundColor: theme.colors.inputDisabled}}
|
|
170
|
+
/>
|
|
171
|
+
<OText size={14} lineHeight={21}>{order?.driver?.name}</OText>
|
|
172
|
+
</BusinessLogo>
|
|
173
|
+
<View style={{ paddingBottom: 0 }}>
|
|
174
|
+
<BlockWrap>
|
|
175
|
+
<OText mBottom={16}>{t('COMMENTS', 'Comments')}</OText>
|
|
176
|
+
<View style={{flexShrink: 1}}>
|
|
177
|
+
<TagSelector items={curSuggest} activeColor={theme.colors.primary} normalColor={'#E9ECEF'} onUpdated={onSuggestUpdate} />
|
|
178
|
+
</View>
|
|
179
|
+
</BlockWrap>
|
|
180
|
+
<FormReviews>
|
|
181
|
+
<OText mBottom={10}>{t('DO_YOU_WANT_TO_ADD_SOMETHING', 'Do you want to add something?')}</OText>
|
|
182
|
+
<Controller
|
|
183
|
+
control={control}
|
|
184
|
+
defaultValue=''
|
|
185
|
+
name='comments'
|
|
186
|
+
render={({ onChange }: any) => (
|
|
187
|
+
<OInput
|
|
188
|
+
name='comments'
|
|
189
|
+
placeholder={t('COMMENTS', 'Comments')}
|
|
190
|
+
onChange={(val: string) => {
|
|
191
|
+
onChange(val)
|
|
192
|
+
setComment(val)
|
|
193
|
+
}}
|
|
194
|
+
style={styles.inputTextArea}
|
|
195
|
+
multiline
|
|
196
|
+
inputStyle={{fontSize: 12}}
|
|
197
|
+
/>
|
|
198
|
+
)}
|
|
199
|
+
/>
|
|
200
|
+
</FormReviews>
|
|
201
|
+
</View>
|
|
202
|
+
<Spinner visible={formState.loading} />
|
|
203
|
+
</ReviewOrderContainer>
|
|
204
|
+
</Container>
|
|
205
|
+
<OBottomStickBar
|
|
206
|
+
rightBtnStyle={{borderRadius: 7.6, height: 44}}
|
|
207
|
+
rightAction={() => handleNext(1)}
|
|
208
|
+
leftAction={() => handleNext(0)}
|
|
209
|
+
/>
|
|
210
|
+
</>
|
|
211
|
+
)
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
export const ReviewDriver = (props: ReviewDriverParams) => {
|
|
216
|
+
const reviewDriverProps = {
|
|
217
|
+
...props,
|
|
218
|
+
UIComponent: ReviewDriverUI
|
|
219
|
+
}
|
|
220
|
+
return <ReviewDriverController {...reviewDriverProps} />
|
|
221
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import styled from 'styled-components/native'
|
|
2
|
+
|
|
3
|
+
export const ReviewOrderContainer = styled.View`
|
|
4
|
+
width: 100%;
|
|
5
|
+
flex: 1;
|
|
6
|
+
`
|
|
7
|
+
export const ReviewOrderTitle = styled.View`
|
|
8
|
+
|
|
9
|
+
`
|
|
10
|
+
|
|
11
|
+
export const BusinessLogo = styled.View`
|
|
12
|
+
margin-vertical: 5px;
|
|
13
|
+
align-items: center;
|
|
14
|
+
box-shadow: 0 1px 2px #ddd;
|
|
15
|
+
border-radius: 7.6px;
|
|
16
|
+
margin-bottom: 20px;
|
|
17
|
+
`
|
|
18
|
+
|
|
19
|
+
export const FormReviews = styled.View`
|
|
20
|
+
flex: 1;
|
|
21
|
+
`
|
|
22
|
+
|
|
23
|
+
export const Category = styled.View`
|
|
24
|
+
padding: 10px;
|
|
25
|
+
border-width: 1px;
|
|
26
|
+
border-color: ${(props: any) => props.theme.colors.secundaryContrast};
|
|
27
|
+
flex-direction: row;
|
|
28
|
+
justify-content: space-between;
|
|
29
|
+
margin-vertical: 5px;
|
|
30
|
+
border-radius: 10px;
|
|
31
|
+
`
|
|
32
|
+
|
|
33
|
+
export const Stars = styled.View`
|
|
34
|
+
flex-direction: row;
|
|
35
|
+
`
|
|
36
|
+
|
|
37
|
+
export const BlockWrap = styled.View`
|
|
38
|
+
margin-vertical: 16px;
|
|
39
|
+
padding-bottom: 20px;
|
|
40
|
+
`;
|
|
41
|
+
|
|
42
|
+
export const CommentItem = styled.TouchableOpacity`
|
|
43
|
+
padding: 3px 10px;
|
|
44
|
+
border-radius: 20px;
|
|
45
|
+
min-height: 24px;
|
|
46
|
+
`;
|