ordering-ui-react-native 0.12.77 → 0.12.81
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/BusinessesListing/index.tsx +35 -3
- package/src/components/BusinessesListing/styles.tsx +10 -0
- package/src/components/Checkout/index.tsx +77 -8
- package/src/components/Messages/index.tsx +3 -3
- package/src/components/PaymentOptions/index.tsx +2 -2
- package/src/theme.json +3 -1
- package/src/utils/index.tsx +27 -0
- package/themes/doordash/src/components/BusinessesListing/index.tsx +33 -1
- package/themes/doordash/src/components/BusinessesListing/styles.tsx +11 -1
- package/themes/doordash/src/utils/index.tsx +27 -0
- package/themes/instacart/src/components/BusinessesListing/index.tsx +35 -3
- package/themes/instacart/src/components/BusinessesListing/styles.tsx +11 -1
- package/themes/instacart/src/utils/index.tsx +27 -0
- package/themes/original/index.tsx +2 -0
- package/themes/original/src/components/ActiveOrders/index.tsx +36 -16
- package/themes/original/src/components/ActiveOrders/styles.tsx +10 -0
- package/themes/original/src/components/MessageListing/index.tsx +298 -0
- package/themes/original/src/components/MessageListing/styles.tsx +16 -0
- package/themes/original/src/components/Messages/index.tsx +123 -81
- package/themes/original/src/components/Messages/styles.tsx +8 -0
- package/themes/original/src/components/UserProfile/index.tsx +10 -0
- package/themes/original/src/types/index.tsx +11 -3
- package/themes/original/src/utils/index.tsx +18 -0
- package/themes/single-business/src/components/BusinessesListing/index.tsx +33 -0
- package/themes/single-business/src/components/BusinessesListing/styles.tsx +9 -0
- package/themes/single-business/src/utils/index.tsx +27 -0
- package/themes/uber-eats/src/components/BusinessesListing/index.tsx +36 -3
- package/themes/uber-eats/src/components/BusinessesListing/styles.tsx +8 -0
- package/themes/uber-eats/src/utils/index.tsx +27 -0
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
OrderInformation,
|
|
11
11
|
BusinessInformation,
|
|
12
12
|
Price,
|
|
13
|
+
UnreadMessageCounter,
|
|
13
14
|
LoadMore
|
|
14
15
|
} from './styles';
|
|
15
16
|
import { View, StyleSheet } from 'react-native';
|
|
@@ -26,6 +27,8 @@ export const ActiveOrders = (props: ActiveOrdersParams) => {
|
|
|
26
27
|
pagination,
|
|
27
28
|
loadMoreOrders,
|
|
28
29
|
getOrderStatus,
|
|
30
|
+
isMessageView,
|
|
31
|
+
handleClickOrder
|
|
29
32
|
} = props;
|
|
30
33
|
|
|
31
34
|
const theme = useTheme();
|
|
@@ -38,6 +41,10 @@ export const ActiveOrders = (props: ActiveOrdersParams) => {
|
|
|
38
41
|
};
|
|
39
42
|
|
|
40
43
|
const handleClickCard = (uuid: string) => {
|
|
44
|
+
if (isMessageView ) {
|
|
45
|
+
handleClickOrder(uuid)
|
|
46
|
+
return
|
|
47
|
+
}
|
|
41
48
|
onNavigationRedirect &&
|
|
42
49
|
onNavigationRedirect('OrderDetails', { orderId: uuid });
|
|
43
50
|
};
|
|
@@ -49,15 +56,15 @@ export const ActiveOrders = (props: ActiveOrdersParams) => {
|
|
|
49
56
|
onPress={() => handleClickCard(order?.uuid)}
|
|
50
57
|
activeOpacity={0.7}>
|
|
51
58
|
{/* {!!(configs?.google_maps_api_key?.value) && (
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
<Map>
|
|
60
|
+
<OIcon
|
|
61
|
+
url={getGoogleMapImage(order?.business?.location, configs?.google_maps_api_key?.value)}
|
|
62
|
+
height={100}
|
|
63
|
+
width={320}
|
|
64
|
+
style={{resizeMode: 'cover', borderTopRightRadius: 24, borderTopLeftRadius: 24}}
|
|
65
|
+
/>
|
|
66
|
+
</Map>
|
|
67
|
+
)} */}
|
|
61
68
|
<Information>
|
|
62
69
|
{!!order.business?.logo && (
|
|
63
70
|
<Logo>
|
|
@@ -96,15 +103,28 @@ export const ActiveOrders = (props: ActiveOrdersParams) => {
|
|
|
96
103
|
</OText>
|
|
97
104
|
{/* )} */}
|
|
98
105
|
</BusinessInformation>
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
{
|
|
102
|
-
|
|
103
|
-
|
|
106
|
+
{isMessageView ? (
|
|
107
|
+
<>
|
|
108
|
+
{order?.unread_count > 0 && (
|
|
109
|
+
<UnreadMessageCounter>
|
|
110
|
+
<OText size={12} color={theme.colors.primary} lineHeight={18} >
|
|
111
|
+
{order?.unread_count}
|
|
112
|
+
</OText>
|
|
113
|
+
</UnreadMessageCounter>
|
|
114
|
+
)}
|
|
115
|
+
</>
|
|
116
|
+
) : (
|
|
117
|
+
<Price>
|
|
118
|
+
<OText size={12} lineHeight={18}>
|
|
119
|
+
{parsePrice(order?.summary?.total || order?.total)}
|
|
120
|
+
</OText>
|
|
121
|
+
</Price>
|
|
122
|
+
)}
|
|
123
|
+
|
|
104
124
|
</OrderInformation>
|
|
105
125
|
</Information>
|
|
106
|
-
</Card>
|
|
107
|
-
</React.Fragment>
|
|
126
|
+
</Card >
|
|
127
|
+
</React.Fragment >
|
|
108
128
|
);
|
|
109
129
|
|
|
110
130
|
return (
|
|
@@ -42,6 +42,16 @@ export const Price = styled.View`
|
|
|
42
42
|
margin-left: 10px;
|
|
43
43
|
width: 30%;
|
|
44
44
|
`
|
|
45
|
+
|
|
46
|
+
export const UnreadMessageCounter = styled.View`
|
|
47
|
+
justify-content: center;
|
|
48
|
+
align-items: center;
|
|
49
|
+
margin-left: 10px;
|
|
50
|
+
width: 24px;
|
|
51
|
+
height: 24px;
|
|
52
|
+
border-radius: 7.6px;
|
|
53
|
+
background-color: ${(props: any) => props.theme.colors.primaryContrast};
|
|
54
|
+
`
|
|
45
55
|
export const LoadMore = styled.View`
|
|
46
56
|
flex-direction: row;
|
|
47
57
|
justify-content: center;
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react'
|
|
2
|
+
import { OrderList, useLanguage, useOrder, ToastType, useToast } from 'ordering-components/native'
|
|
3
|
+
import { OrderDetails as OrderDetailsConTableoller } from './naked'
|
|
4
|
+
import { useTheme } from 'styled-components/native';
|
|
5
|
+
import { useFocusEffect } from '@react-navigation/native'
|
|
6
|
+
import { OText, OModal } from '../shared'
|
|
7
|
+
import { NotFoundSource } from '../NotFoundSource'
|
|
8
|
+
import { ActiveOrders } from '../ActiveOrders'
|
|
9
|
+
import { Messages } from '../Messages';
|
|
10
|
+
import NavBar from '../NavBar'
|
|
11
|
+
import {
|
|
12
|
+
MessageListingParams,
|
|
13
|
+
OrdersOptionParams
|
|
14
|
+
} from '../../types'
|
|
15
|
+
import {
|
|
16
|
+
Placeholder,
|
|
17
|
+
PlaceholderLine,
|
|
18
|
+
Fade
|
|
19
|
+
} from "rn-placeholder";
|
|
20
|
+
import { View, BackHandler } from 'react-native'
|
|
21
|
+
import {
|
|
22
|
+
MessageListingWrapper,
|
|
23
|
+
MessageContainer
|
|
24
|
+
} from './styles';
|
|
25
|
+
|
|
26
|
+
const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
27
|
+
const {
|
|
28
|
+
navigation,
|
|
29
|
+
activeOrders,
|
|
30
|
+
orderList,
|
|
31
|
+
pagination,
|
|
32
|
+
titleContent,
|
|
33
|
+
customArray,
|
|
34
|
+
onNavigationRedirect,
|
|
35
|
+
orderStatus,
|
|
36
|
+
loadMoreOrders,
|
|
37
|
+
loadOrders,
|
|
38
|
+
setSelectedOrderId,
|
|
39
|
+
setOrderList,
|
|
40
|
+
setOpenMessges
|
|
41
|
+
} = props
|
|
42
|
+
|
|
43
|
+
const theme = useTheme();
|
|
44
|
+
const [, t] = useLanguage()
|
|
45
|
+
const [, { reorder }] = useOrder()
|
|
46
|
+
const { showToast } = useToast()
|
|
47
|
+
const { loading, error, orders: values } = orderList
|
|
48
|
+
const imageFails = activeOrders
|
|
49
|
+
? theme.images.general.emptyActiveOrders
|
|
50
|
+
: theme.images.general.emptyPastOrders
|
|
51
|
+
const orders = customArray || values || []
|
|
52
|
+
|
|
53
|
+
const getOrderStatus = (s: string) => {
|
|
54
|
+
const status = parseInt(s)
|
|
55
|
+
const orderStatus = [
|
|
56
|
+
{ key: 0, value: t('PENDING', 'Pending') },
|
|
57
|
+
{ key: 1, value: t('COMPLETED', 'Completed') },
|
|
58
|
+
{ key: 2, value: t('REJECTED', 'Rejected') },
|
|
59
|
+
{ key: 3, value: t('DRIVER_IN_BUSINESS', 'Driver in business') },
|
|
60
|
+
{ key: 4, value: t('PREPARATION_COMPLETED', 'Preparation Completed') },
|
|
61
|
+
{ key: 5, value: t('REJECTED_BY_BUSINESS', 'Rejected by business') },
|
|
62
|
+
{ key: 6, value: t('REJECTED_BY_DRIVER', 'Rejected by Driver') },
|
|
63
|
+
{ key: 7, value: t('ACCEPTED_BY_BUSINESS', 'Accepted by business') },
|
|
64
|
+
{ key: 8, value: t('ACCEPTED_BY_DRIVER', 'Accepted by driver') },
|
|
65
|
+
{ key: 9, value: t('PICK_UP_COMPLETED_BY_DRIVER', 'Pick up completed by driver') },
|
|
66
|
+
{ key: 10, value: t('PICK_UP_FAILED_BY_DRIVER', 'Pick up Failed by driver') },
|
|
67
|
+
{ key: 11, value: t('DELIVERY_COMPLETED_BY_DRIVER', 'Delivery completed by driver') },
|
|
68
|
+
{ key: 12, value: t('DELIVERY_FAILED_BY_DRIVER', 'Delivery Failed by driver') },
|
|
69
|
+
{ key: 13, value: t('PREORDER', 'PreOrder') },
|
|
70
|
+
{ key: 14, value: t('ORDER_NOT_READY', 'Order not ready') },
|
|
71
|
+
{ key: 15, value: t('ORDER_PICKEDUP_COMPLETED_BY_CUSTOMER', 'Order picked up completed by customer') },
|
|
72
|
+
{ key: 16, value: t('CANCELLED_BY_CUSTOMER', 'Cancelled by customer') },
|
|
73
|
+
{ key: 17, value: t('ORDER_NOT_PICKEDUP_BY_CUSTOMER', 'Order not picked up by customer') },
|
|
74
|
+
{ key: 18, value: t('DRIVER_ALMOST_ARRIVED_TO_BUSINESS', 'Driver almost arrived to business') },
|
|
75
|
+
{ key: 19, value: t('DRIVER_ALMOST_ARRIVED_TO_CUSTOMER', 'Driver almost arrived to customer') },
|
|
76
|
+
{ key: 20, value: t('ORDER_CUSTOMER_ALMOST_ARRIVED_BUSINESS', 'Customer almost arrived to business') },
|
|
77
|
+
{ key: 21, value: t('ORDER_CUSTOMER_ARRIVED_BUSINESS', 'Customer arrived to business') }
|
|
78
|
+
]
|
|
79
|
+
|
|
80
|
+
const objectStatus = orderStatus.find((o) => o.key === status)
|
|
81
|
+
|
|
82
|
+
return objectStatus && objectStatus
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const handleClickOrder = (uuid: string) => {
|
|
86
|
+
setSelectedOrderId(uuid)
|
|
87
|
+
setOpenMessges(true)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
useFocusEffect(
|
|
91
|
+
React.useCallback(() => {
|
|
92
|
+
loadOrders()
|
|
93
|
+
}, [navigation])
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
if (loading) return
|
|
98
|
+
setOrderList(orderList)
|
|
99
|
+
}, [orderList, loading])
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<>
|
|
103
|
+
{!loading && orders.length === 0 && (
|
|
104
|
+
<NotFoundSource
|
|
105
|
+
content={t('NO_RESULTS_FOUND', 'Sorry, no results found')}
|
|
106
|
+
image={imageFails}
|
|
107
|
+
conditioned
|
|
108
|
+
/>
|
|
109
|
+
)}
|
|
110
|
+
{loading && (
|
|
111
|
+
<View style={{ marginTop: 30 }}>
|
|
112
|
+
{[...Array(6)].map((item, i) => (
|
|
113
|
+
<Placeholder key={i} Animation={Fade}>
|
|
114
|
+
<View style={{ width: '100%', flexDirection: 'row' }}>
|
|
115
|
+
<PlaceholderLine width={20} height={70} style={{ marginRight: 20, marginBottom: 20 }} />
|
|
116
|
+
<Placeholder>
|
|
117
|
+
<PlaceholderLine width={30} style={{ marginTop: 5 }} />
|
|
118
|
+
<PlaceholderLine width={50} />
|
|
119
|
+
<PlaceholderLine width={20} />
|
|
120
|
+
</Placeholder>
|
|
121
|
+
</View>
|
|
122
|
+
</Placeholder>
|
|
123
|
+
))}
|
|
124
|
+
</View>
|
|
125
|
+
)}
|
|
126
|
+
{!loading && !error && orders.length > 0 && (
|
|
127
|
+
<ActiveOrders
|
|
128
|
+
orders={orders.filter((order: any) => orderStatus.includes(order.status))}
|
|
129
|
+
pagination={pagination}
|
|
130
|
+
loadMoreOrders={loadMoreOrders}
|
|
131
|
+
customArray={customArray}
|
|
132
|
+
getOrderStatus={getOrderStatus}
|
|
133
|
+
onNavigationRedirect={onNavigationRedirect}
|
|
134
|
+
isMessageView
|
|
135
|
+
handleClickOrder={handleClickOrder}
|
|
136
|
+
/>
|
|
137
|
+
)}
|
|
138
|
+
</>
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const OrderMessageUI = (props: any) => {
|
|
143
|
+
const {
|
|
144
|
+
navigation,
|
|
145
|
+
messages,
|
|
146
|
+
setMessages,
|
|
147
|
+
readMessages,
|
|
148
|
+
messagesReadList,
|
|
149
|
+
setOpenMessges
|
|
150
|
+
} = props;
|
|
151
|
+
const [openModalForBusiness, setOpenModalForBusiness] = useState(false);
|
|
152
|
+
const [openModalForDriver, setOpenModalForDriver] = useState(false);
|
|
153
|
+
const [unreadAlert, setUnreadAlert] = useState({
|
|
154
|
+
business: false,
|
|
155
|
+
driver: false,
|
|
156
|
+
});
|
|
157
|
+
const [, t] = useLanguage()
|
|
158
|
+
const { order } = props.order;
|
|
159
|
+
const handleArrowBack: any = () => {
|
|
160
|
+
navigation.navigate('BottomTab');
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
const handleClose = () => {
|
|
164
|
+
setOpenMessges(false)
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
useEffect(() => {
|
|
168
|
+
if (messagesReadList?.length) {
|
|
169
|
+
openModalForBusiness
|
|
170
|
+
? setUnreadAlert({ ...unreadAlert, business: false })
|
|
171
|
+
: setUnreadAlert({ ...unreadAlert, driver: false });
|
|
172
|
+
}
|
|
173
|
+
}, [messagesReadList]);
|
|
174
|
+
|
|
175
|
+
useEffect(() => {
|
|
176
|
+
setOpenModalForBusiness(true);
|
|
177
|
+
setOpenModalForDriver(true);
|
|
178
|
+
readMessages && readMessages();
|
|
179
|
+
}, [order])
|
|
180
|
+
|
|
181
|
+
useEffect(() => {
|
|
182
|
+
BackHandler.addEventListener('hardwareBackPress', handleArrowBack);
|
|
183
|
+
return () => {
|
|
184
|
+
BackHandler.removeEventListener('hardwareBackPress', handleArrowBack);
|
|
185
|
+
};
|
|
186
|
+
}, []);
|
|
187
|
+
|
|
188
|
+
return (
|
|
189
|
+
<>
|
|
190
|
+
{(order?.business && !order?.driver) && (
|
|
191
|
+
<Messages
|
|
192
|
+
orderId={order?.id}
|
|
193
|
+
messages={messages}
|
|
194
|
+
order={order}
|
|
195
|
+
setMessages={setMessages}
|
|
196
|
+
readMessages={readMessages}
|
|
197
|
+
isMeesageListing
|
|
198
|
+
onClose={() => handleClose()}
|
|
199
|
+
/>
|
|
200
|
+
)}
|
|
201
|
+
</>
|
|
202
|
+
|
|
203
|
+
)
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export const OrderListing = (props: OrdersOptionParams) => {
|
|
207
|
+
const OrderListingProps = {
|
|
208
|
+
...props,
|
|
209
|
+
UIComponent: OrdersOptionUI,
|
|
210
|
+
orderStatus: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21],
|
|
211
|
+
useDefualtSessionManager: true,
|
|
212
|
+
paginationSettings: {
|
|
213
|
+
initialPage: 1,
|
|
214
|
+
pageSize: 10,
|
|
215
|
+
controlType: 'infinity'
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return <OrderList {...OrderListingProps} />
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export const MessagesView = (props: any) => {
|
|
222
|
+
const orderDetailsProps = {
|
|
223
|
+
...props,
|
|
224
|
+
UIComponent: OrderMessageUI,
|
|
225
|
+
};
|
|
226
|
+
return <OrderDetailsConTableoller {...orderDetailsProps} />;
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
export const MessageListing = (props: MessageListingParams) => {
|
|
231
|
+
const {
|
|
232
|
+
navigation
|
|
233
|
+
} = props
|
|
234
|
+
const [orderListStatus, setOrderListStatus] = useState({
|
|
235
|
+
error: null,
|
|
236
|
+
loading: false,
|
|
237
|
+
orders: []
|
|
238
|
+
})
|
|
239
|
+
const [selectedOrderId, setSelectedOrderId] = useState(null)
|
|
240
|
+
const [seletedOrder, setSeletedOrder] = useState<any>()
|
|
241
|
+
const [openMessages, setOpenMessges] = useState(false)
|
|
242
|
+
const [, t] = useLanguage()
|
|
243
|
+
|
|
244
|
+
const goToBack = () => {
|
|
245
|
+
navigation?.canGoBack() && navigation.goBack()
|
|
246
|
+
setSelectedOrderId(null)
|
|
247
|
+
setSeletedOrder([])
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
const handleCloseModal = () => {
|
|
251
|
+
setOpenMessges(false)
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
useEffect(() => {
|
|
255
|
+
if (!orderListStatus?.loading && selectedOrderId) {
|
|
256
|
+
const _orders = orderListStatus?.orders
|
|
257
|
+
const _seletedOrder = _orders.find((order: any) => order?.uuid === selectedOrderId)
|
|
258
|
+
setSeletedOrder(_seletedOrder)
|
|
259
|
+
}
|
|
260
|
+
}, [orderListStatus, selectedOrderId])
|
|
261
|
+
|
|
262
|
+
useEffect(() => {
|
|
263
|
+
|
|
264
|
+
}, [orderListStatus])
|
|
265
|
+
|
|
266
|
+
return (
|
|
267
|
+
<MessageListingWrapper>
|
|
268
|
+
<NavBar
|
|
269
|
+
title={t('MESSAGES', 'Messages')}
|
|
270
|
+
titleAlign={'center'}
|
|
271
|
+
onActionLeft={goToBack}
|
|
272
|
+
showCall={false}
|
|
273
|
+
paddingTop={10}
|
|
274
|
+
btnStyle={{ paddingLeft: 0 }}
|
|
275
|
+
/>
|
|
276
|
+
<OrderListing
|
|
277
|
+
ordersLength={{ activeOrdersLength: 0, previousOrdersLength: 0 }}
|
|
278
|
+
setSelectedOrderId={setSelectedOrderId}
|
|
279
|
+
setOrderList={setOrderListStatus}
|
|
280
|
+
setOpenMessges={setOpenMessges}
|
|
281
|
+
/>
|
|
282
|
+
{openMessages && seletedOrder && (
|
|
283
|
+
<OModal
|
|
284
|
+
open={openMessages}
|
|
285
|
+
entireModal
|
|
286
|
+
customClose
|
|
287
|
+
onClose={() => handleCloseModal()}
|
|
288
|
+
>
|
|
289
|
+
<MessagesView
|
|
290
|
+
order={seletedOrder}
|
|
291
|
+
setOpenMessges={setOpenMessges}
|
|
292
|
+
/>
|
|
293
|
+
</OModal>
|
|
294
|
+
)}
|
|
295
|
+
</MessageListingWrapper>
|
|
296
|
+
)
|
|
297
|
+
}
|
|
298
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import styled from 'styled-components/native'
|
|
2
|
+
|
|
3
|
+
export const MessageListingWrapper = styled.View`
|
|
4
|
+
position: relative;
|
|
5
|
+
`
|
|
6
|
+
|
|
7
|
+
export const MessageContainer = styled.View`
|
|
8
|
+
position: absolute;
|
|
9
|
+
top: 0;
|
|
10
|
+
left: 0;
|
|
11
|
+
margin: 0;
|
|
12
|
+
width: 100%;
|
|
13
|
+
height: 100%;
|
|
14
|
+
`
|
|
15
|
+
|
|
16
|
+
|
|
@@ -7,13 +7,12 @@ import { USER_TYPE } from '../../config/constants'
|
|
|
7
7
|
import MaterialCommunityIcon from 'react-native-vector-icons/MaterialCommunityIcons'
|
|
8
8
|
import { OIcon, OIconButton, OText, OButton } from '../shared'
|
|
9
9
|
import { TouchableOpacity, ActivityIndicator, StyleSheet, View, Platform, Keyboard } from 'react-native'
|
|
10
|
-
import { Header, TitleHeader, Wrapper, QuickMessageContainer } from './styles'
|
|
10
|
+
import { Header, TitleHeader, Wrapper, QuickMessageContainer, ProfileMessageHeader } from './styles'
|
|
11
11
|
import { MessagesParams } from '../../types'
|
|
12
12
|
import { useWindowDimensions } from 'react-native'
|
|
13
13
|
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
14
14
|
|
|
15
15
|
const MessagesUI = (props: MessagesParams) => {
|
|
16
|
-
|
|
17
16
|
const {
|
|
18
17
|
type,
|
|
19
18
|
order,
|
|
@@ -27,6 +26,7 @@ const MessagesUI = (props: MessagesParams) => {
|
|
|
27
26
|
setImage,
|
|
28
27
|
readMessages,
|
|
29
28
|
onClose,
|
|
29
|
+
isMeesageListing
|
|
30
30
|
} = props
|
|
31
31
|
|
|
32
32
|
const [{ user }] = useSession()
|
|
@@ -37,22 +37,22 @@ const MessagesUI = (props: MessagesParams) => {
|
|
|
37
37
|
const [formattedMessages, setFormattedMessages] = useState<Array<any>>([])
|
|
38
38
|
const [isKeyboardShow, setIsKeyboardShow] = useState(false)
|
|
39
39
|
const previousStatus = [1, 2, 5, 6, 10, 11, 12, 16, 17]
|
|
40
|
-
|
|
40
|
+
const chatDisabled = previousStatus.includes(order?.status)
|
|
41
41
|
const { height } = useWindowDimensions();
|
|
42
42
|
const { top, bottom } = useSafeAreaInsets();
|
|
43
43
|
|
|
44
44
|
const theme = useTheme();
|
|
45
45
|
|
|
46
46
|
const quickMessageList = [
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
{ key: 'customer_message_1', text: t('CUSTOMER_MESSAGE_1', 'Lorem ipsum 1') },
|
|
48
|
+
{ key: 'customer_message_2', text: t('CUSTOMER_MESSAGE_2', 'Lorem ipsum 2') },
|
|
49
|
+
{ key: 'customer_message_3', text: t('CUSTOMER_MESSAGE_3', 'Lorem ipsum 3') },
|
|
50
|
+
{ key: 'customer_message_4', text: t('CUSTOMER_MESSAGE_4', 'Lorem ipsum 4') }
|
|
51
|
+
]
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
const handleClickQuickMessage = (text: string) => {
|
|
54
|
+
setMessage && setMessage(`${message}${text}`)
|
|
55
|
+
}
|
|
56
56
|
|
|
57
57
|
const onChangeMessage = (val: string) => {
|
|
58
58
|
setMessage && setMessage(val)
|
|
@@ -239,37 +239,37 @@ const MessagesUI = (props: MessagesParams) => {
|
|
|
239
239
|
}
|
|
240
240
|
|
|
241
241
|
const renderAccessory = () => {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
242
|
+
return (
|
|
243
|
+
<QuickMessageContainer
|
|
244
|
+
style={{
|
|
245
|
+
marginLeft: 10,
|
|
246
|
+
marginBottom: 10
|
|
247
|
+
}}
|
|
248
|
+
contentContainerStyle={{
|
|
249
|
+
alignItems: 'center',
|
|
250
|
+
}}
|
|
251
|
+
horizontal
|
|
252
|
+
showsHorizontalScrollIndicator={false}
|
|
253
|
+
>
|
|
254
|
+
{quickMessageList.map((quickMessage, i) => (
|
|
255
|
+
<OButton
|
|
256
|
+
key={i}
|
|
257
|
+
text={quickMessage.text}
|
|
258
|
+
bgColor='#E9ECEF'
|
|
259
|
+
borderColor='#E9ECEF'
|
|
260
|
+
imgRightSrc={null}
|
|
261
|
+
textStyle={{
|
|
262
|
+
fontSize: 11,
|
|
263
|
+
lineHeight: 16,
|
|
264
|
+
color: '#414954'
|
|
265
|
+
}}
|
|
266
|
+
style={{ ...styles.editButton }}
|
|
267
|
+
onClick={() => handleClickQuickMessage(quickMessage.text)}
|
|
268
|
+
/>
|
|
269
|
+
))}
|
|
270
|
+
</QuickMessageContainer>
|
|
271
|
+
)
|
|
272
|
+
}
|
|
273
273
|
|
|
274
274
|
const renderInputToolbar = (props: typeof InputToolbarProps) => (
|
|
275
275
|
<InputToolbar
|
|
@@ -285,20 +285,20 @@ const MessagesUI = (props: MessagesParams) => {
|
|
|
285
285
|
|
|
286
286
|
const renderComposer = (props: typeof ComposerProps) => (
|
|
287
287
|
chatDisabled ? (
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
288
|
+
<View
|
|
289
|
+
style={{
|
|
290
|
+
width: '100%',
|
|
291
|
+
flexDirection: 'column',
|
|
292
|
+
alignItems: 'center'
|
|
293
|
+
}}
|
|
294
|
+
>
|
|
295
|
+
<MaterialCommunityIcon
|
|
296
|
+
name='close-octagon-outline'
|
|
297
|
+
size={24}
|
|
298
|
+
/>
|
|
299
|
+
<OText size={14}>{t('NOT_SEND_MESSAGES', 'You can\'t send messages because the order has ended')}</OText>
|
|
300
|
+
</View>
|
|
301
|
+
) : (
|
|
302
302
|
<View style={{
|
|
303
303
|
flexDirection: 'row', width: '80%', alignItems: 'center', backgroundColor: theme.colors.backgroundGray100,
|
|
304
304
|
borderRadius: 7.6,
|
|
@@ -387,7 +387,7 @@ const MessagesUI = (props: MessagesParams) => {
|
|
|
387
387
|
|
|
388
388
|
const getViewHeight = () => {
|
|
389
389
|
if (Platform.OS === 'android') {
|
|
390
|
-
return height - top - bottom - (isKeyboardShow ?
|
|
390
|
+
return height - top - bottom - (isKeyboardShow ? 300 : 24);
|
|
391
391
|
} else {
|
|
392
392
|
return height - top - bottom - 10;
|
|
393
393
|
}
|
|
@@ -396,21 +396,53 @@ const MessagesUI = (props: MessagesParams) => {
|
|
|
396
396
|
return (
|
|
397
397
|
<View style={{ height: getViewHeight(), width: '100%', paddingTop: 12, backgroundColor: 'white' }}>
|
|
398
398
|
<Wrapper>
|
|
399
|
-
|
|
400
|
-
<
|
|
401
|
-
|
|
402
|
-
<
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
<
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
399
|
+
{!isMeesageListing ? (
|
|
400
|
+
<Header>
|
|
401
|
+
<OIconButton icon={theme.images.general.arrow_left} style={{ paddingStart: 10, borderColor: theme.colors.clear }} onClick={onClose} />
|
|
402
|
+
<View style={{ marginRight: 10, shadowColor: theme.colors.black, shadowOpacity: 0.1, shadowOffset: { width: 0, height: 1 }, shadowRadius: 2 }}>
|
|
403
|
+
<OIcon
|
|
404
|
+
url={type === USER_TYPE.DRIVER ? order?.driver?.photo : order?.business?.logo}
|
|
405
|
+
width={32}
|
|
406
|
+
height={32}
|
|
407
|
+
style={{ borderRadius: 7.6 }}
|
|
408
|
+
/>
|
|
409
|
+
</View>
|
|
410
|
+
<TitleHeader>
|
|
411
|
+
<OText size={14} lineHeight={21} weight={'600'}>{type === USER_TYPE.DRIVER ? order?.driver?.name : order?.business?.name}</OText>
|
|
412
|
+
<OText size={12} color={theme.colors.textSecondary}>{type === USER_TYPE.DRIVER ? t('DRIVER', 'Driver') : t('BUSINESS', 'Business')}</OText>
|
|
413
|
+
</TitleHeader>
|
|
414
|
+
</Header>
|
|
415
|
+
) : (
|
|
416
|
+
<ProfileMessageHeader>
|
|
417
|
+
<View style={{ ...styles.headerTitle }}>
|
|
418
|
+
<TouchableOpacity
|
|
419
|
+
style={styles.headerItem}
|
|
420
|
+
onPress={onClose}>
|
|
421
|
+
<OIcon src={theme.images.general.arrow_left} width={16} />
|
|
422
|
+
</TouchableOpacity>
|
|
423
|
+
<OText size={18}>{t('ORDER', theme?.defaultLanguages?.ORDER || 'Order')} #{order?.id}</OText>
|
|
424
|
+
</View>
|
|
425
|
+
<View>
|
|
426
|
+
{order.business && (
|
|
427
|
+
<OIcon
|
|
428
|
+
url={order?.business?.logo}
|
|
429
|
+
width={32}
|
|
430
|
+
height={32}
|
|
431
|
+
style={{ borderRadius: 7.6 }}
|
|
432
|
+
/>
|
|
433
|
+
)}
|
|
434
|
+
|
|
435
|
+
{order?.driver && (
|
|
436
|
+
<OIcon
|
|
437
|
+
url={order?.driver?.photo}
|
|
438
|
+
width={32}
|
|
439
|
+
height={32}
|
|
440
|
+
style={{ borderRadius: 7.6 }}
|
|
441
|
+
/>
|
|
442
|
+
)}
|
|
443
|
+
</View>
|
|
444
|
+
</ProfileMessageHeader>
|
|
445
|
+
)}
|
|
414
446
|
<GiftedChat
|
|
415
447
|
messages={formattedMessages}
|
|
416
448
|
user={{
|
|
@@ -460,15 +492,25 @@ const styles = StyleSheet.create({
|
|
|
460
492
|
justifyContent: 'center',
|
|
461
493
|
marginHorizontal: 4
|
|
462
494
|
},
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
495
|
+
editButton: {
|
|
496
|
+
borderRadius: 50,
|
|
497
|
+
backgroundColor: '#E9ECEF',
|
|
498
|
+
marginRight: 10,
|
|
499
|
+
height: 24,
|
|
500
|
+
borderWidth: 1,
|
|
501
|
+
paddingLeft: 0,
|
|
502
|
+
paddingRight: 0
|
|
503
|
+
},
|
|
504
|
+
headerTitle: {
|
|
505
|
+
flexDirection: 'row',
|
|
506
|
+
alignItems: 'center'
|
|
507
|
+
},
|
|
508
|
+
headerItem: {
|
|
509
|
+
overflow: 'hidden',
|
|
510
|
+
width: 35,
|
|
511
|
+
marginVertical: 18,
|
|
512
|
+
}
|
|
513
|
+
|
|
472
514
|
})
|
|
473
515
|
|
|
474
516
|
export const Messages = (props: MessagesParams) => {
|