ordering-ui-react-native 0.12.79 → 0.12.83

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.
Files changed (29) hide show
  1. package/package.json +1 -1
  2. package/src/components/BusinessesListing/index.tsx +35 -3
  3. package/src/components/BusinessesListing/styles.tsx +10 -0
  4. package/src/theme.json +3 -1
  5. package/src/utils/index.tsx +27 -0
  6. package/themes/doordash/src/components/BusinessesListing/index.tsx +33 -1
  7. package/themes/doordash/src/components/BusinessesListing/styles.tsx +11 -1
  8. package/themes/doordash/src/utils/index.tsx +27 -0
  9. package/themes/instacart/src/components/BusinessesListing/index.tsx +35 -3
  10. package/themes/instacart/src/components/BusinessesListing/styles.tsx +11 -1
  11. package/themes/instacart/src/utils/index.tsx +27 -0
  12. package/themes/original/index.tsx +2 -0
  13. package/themes/original/src/components/ActiveOrders/index.tsx +36 -16
  14. package/themes/original/src/components/ActiveOrders/styles.tsx +10 -0
  15. package/themes/original/src/components/MessageListing/index.tsx +297 -0
  16. package/themes/original/src/components/MessageListing/styles.tsx +16 -0
  17. package/themes/original/src/components/Messages/index.tsx +123 -81
  18. package/themes/original/src/components/Messages/styles.tsx +8 -0
  19. package/themes/original/src/components/UserProfile/index.tsx +10 -0
  20. package/themes/original/src/types/index.tsx +11 -3
  21. package/themes/original/src/utils/index.tsx +18 -0
  22. package/themes/single-business/src/components/BusinessesListing/index.tsx +33 -0
  23. package/themes/single-business/src/components/BusinessesListing/styles.tsx +9 -0
  24. package/themes/single-business/src/components/ProductForm/index.tsx +5 -2
  25. package/themes/single-business/src/components/ReviewOrder/index.tsx +18 -3
  26. package/themes/single-business/src/utils/index.tsx +27 -0
  27. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +36 -3
  28. package/themes/uber-eats/src/components/BusinessesListing/styles.tsx +8 -0
  29. package/themes/uber-eats/src/utils/index.tsx +27 -0
@@ -0,0 +1,297 @@
1
+ import React, { useState, useEffect } from 'react'
2
+ import { useLanguage, useOrder, ToastType, useToast, OrderList, OrderDetails as OrderDetailsConTableoller } from 'ordering-components/native'
3
+ import { useTheme } from 'styled-components/native';
4
+ import { useFocusEffect } from '@react-navigation/native'
5
+ import { OText, OModal } from '../shared'
6
+ import { NotFoundSource } from '../NotFoundSource'
7
+ import { ActiveOrders } from '../ActiveOrders'
8
+ import { Messages } from '../Messages';
9
+ import NavBar from '../NavBar'
10
+ import {
11
+ MessageListingParams,
12
+ OrdersOptionParams
13
+ } from '../../types'
14
+ import {
15
+ Placeholder,
16
+ PlaceholderLine,
17
+ Fade
18
+ } from "rn-placeholder";
19
+ import { View, BackHandler } from 'react-native'
20
+ import {
21
+ MessageListingWrapper,
22
+ MessageContainer
23
+ } from './styles';
24
+
25
+ const OrdersOptionUI = (props: OrdersOptionParams) => {
26
+ const {
27
+ navigation,
28
+ activeOrders,
29
+ orderList,
30
+ pagination,
31
+ titleContent,
32
+ customArray,
33
+ onNavigationRedirect,
34
+ orderStatus,
35
+ loadMoreOrders,
36
+ loadOrders,
37
+ setSelectedOrderId,
38
+ setOrderList,
39
+ setOpenMessges
40
+ } = props
41
+
42
+ const theme = useTheme();
43
+ const [, t] = useLanguage()
44
+ const [, { reorder }] = useOrder()
45
+ const { showToast } = useToast()
46
+ const { loading, error, orders: values } = orderList
47
+ const imageFails = activeOrders
48
+ ? theme.images.general.emptyActiveOrders
49
+ : theme.images.general.emptyPastOrders
50
+ const orders = customArray || values || []
51
+
52
+ const getOrderStatus = (s: string) => {
53
+ const status = parseInt(s)
54
+ const orderStatus = [
55
+ { key: 0, value: t('PENDING', 'Pending') },
56
+ { key: 1, value: t('COMPLETED', 'Completed') },
57
+ { key: 2, value: t('REJECTED', 'Rejected') },
58
+ { key: 3, value: t('DRIVER_IN_BUSINESS', 'Driver in business') },
59
+ { key: 4, value: t('PREPARATION_COMPLETED', 'Preparation Completed') },
60
+ { key: 5, value: t('REJECTED_BY_BUSINESS', 'Rejected by business') },
61
+ { key: 6, value: t('REJECTED_BY_DRIVER', 'Rejected by Driver') },
62
+ { key: 7, value: t('ACCEPTED_BY_BUSINESS', 'Accepted by business') },
63
+ { key: 8, value: t('ACCEPTED_BY_DRIVER', 'Accepted by driver') },
64
+ { key: 9, value: t('PICK_UP_COMPLETED_BY_DRIVER', 'Pick up completed by driver') },
65
+ { key: 10, value: t('PICK_UP_FAILED_BY_DRIVER', 'Pick up Failed by driver') },
66
+ { key: 11, value: t('DELIVERY_COMPLETED_BY_DRIVER', 'Delivery completed by driver') },
67
+ { key: 12, value: t('DELIVERY_FAILED_BY_DRIVER', 'Delivery Failed by driver') },
68
+ { key: 13, value: t('PREORDER', 'PreOrder') },
69
+ { key: 14, value: t('ORDER_NOT_READY', 'Order not ready') },
70
+ { key: 15, value: t('ORDER_PICKEDUP_COMPLETED_BY_CUSTOMER', 'Order picked up completed by customer') },
71
+ { key: 16, value: t('CANCELLED_BY_CUSTOMER', 'Cancelled by customer') },
72
+ { key: 17, value: t('ORDER_NOT_PICKEDUP_BY_CUSTOMER', 'Order not picked up by customer') },
73
+ { key: 18, value: t('DRIVER_ALMOST_ARRIVED_TO_BUSINESS', 'Driver almost arrived to business') },
74
+ { key: 19, value: t('DRIVER_ALMOST_ARRIVED_TO_CUSTOMER', 'Driver almost arrived to customer') },
75
+ { key: 20, value: t('ORDER_CUSTOMER_ALMOST_ARRIVED_BUSINESS', 'Customer almost arrived to business') },
76
+ { key: 21, value: t('ORDER_CUSTOMER_ARRIVED_BUSINESS', 'Customer arrived to business') }
77
+ ]
78
+
79
+ const objectStatus = orderStatus.find((o) => o.key === status)
80
+
81
+ return objectStatus && objectStatus
82
+ }
83
+
84
+ const handleClickOrder = (uuid: string) => {
85
+ setSelectedOrderId(uuid)
86
+ setOpenMessges(true)
87
+ }
88
+
89
+ useFocusEffect(
90
+ React.useCallback(() => {
91
+ loadOrders()
92
+ }, [navigation])
93
+ )
94
+
95
+ useEffect(() => {
96
+ if (loading) return
97
+ setOrderList(orderList)
98
+ }, [orderList, loading])
99
+
100
+ return (
101
+ <>
102
+ {!loading && orders.length === 0 && (
103
+ <NotFoundSource
104
+ content={t('NO_RESULTS_FOUND', 'Sorry, no results found')}
105
+ image={imageFails}
106
+ conditioned
107
+ />
108
+ )}
109
+ {loading && (
110
+ <View style={{ marginTop: 30 }}>
111
+ {[...Array(6)].map((item, i) => (
112
+ <Placeholder key={i} Animation={Fade}>
113
+ <View style={{ width: '100%', flexDirection: 'row' }}>
114
+ <PlaceholderLine width={20} height={70} style={{ marginRight: 20, marginBottom: 20 }} />
115
+ <Placeholder>
116
+ <PlaceholderLine width={30} style={{ marginTop: 5 }} />
117
+ <PlaceholderLine width={50} />
118
+ <PlaceholderLine width={20} />
119
+ </Placeholder>
120
+ </View>
121
+ </Placeholder>
122
+ ))}
123
+ </View>
124
+ )}
125
+ {!loading && !error && orders.length > 0 && (
126
+ <ActiveOrders
127
+ orders={orders.filter((order: any) => orderStatus.includes(order.status))}
128
+ pagination={pagination}
129
+ loadMoreOrders={loadMoreOrders}
130
+ customArray={customArray}
131
+ getOrderStatus={getOrderStatus}
132
+ onNavigationRedirect={onNavigationRedirect}
133
+ isMessageView
134
+ handleClickOrder={handleClickOrder}
135
+ />
136
+ )}
137
+ </>
138
+ )
139
+ }
140
+
141
+ const OrderMessageUI = (props: any) => {
142
+ const {
143
+ navigation,
144
+ messages,
145
+ setMessages,
146
+ readMessages,
147
+ messagesReadList,
148
+ setOpenMessges
149
+ } = props;
150
+ const [openModalForBusiness, setOpenModalForBusiness] = useState(false);
151
+ const [openModalForDriver, setOpenModalForDriver] = useState(false);
152
+ const [unreadAlert, setUnreadAlert] = useState({
153
+ business: false,
154
+ driver: false,
155
+ });
156
+ const [, t] = useLanguage()
157
+ const { order } = props.order;
158
+ const handleArrowBack: any = () => {
159
+ navigation.navigate('BottomTab');
160
+ };
161
+
162
+ const handleClose = () => {
163
+ setOpenMessges(false)
164
+ }
165
+
166
+ useEffect(() => {
167
+ if (messagesReadList?.length) {
168
+ openModalForBusiness
169
+ ? setUnreadAlert({ ...unreadAlert, business: false })
170
+ : setUnreadAlert({ ...unreadAlert, driver: false });
171
+ }
172
+ }, [messagesReadList]);
173
+
174
+ useEffect(() => {
175
+ setOpenModalForBusiness(true);
176
+ setOpenModalForDriver(true);
177
+ readMessages && readMessages();
178
+ }, [order])
179
+
180
+ useEffect(() => {
181
+ BackHandler.addEventListener('hardwareBackPress', handleArrowBack);
182
+ return () => {
183
+ BackHandler.removeEventListener('hardwareBackPress', handleArrowBack);
184
+ };
185
+ }, []);
186
+
187
+ return (
188
+ <>
189
+ {(order?.business && !order?.driver) && (
190
+ <Messages
191
+ orderId={order?.id}
192
+ messages={messages}
193
+ order={order}
194
+ setMessages={setMessages}
195
+ readMessages={readMessages}
196
+ isMeesageListing
197
+ onClose={() => handleClose()}
198
+ />
199
+ )}
200
+ </>
201
+
202
+ )
203
+ }
204
+
205
+ export const OrderListing = (props: OrdersOptionParams) => {
206
+ const OrderListingProps = {
207
+ ...props,
208
+ UIComponent: OrdersOptionUI,
209
+ orderStatus: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21],
210
+ useDefualtSessionManager: true,
211
+ paginationSettings: {
212
+ initialPage: 1,
213
+ pageSize: 10,
214
+ controlType: 'infinity'
215
+ }
216
+ }
217
+ return <OrderList {...OrderListingProps} />
218
+ }
219
+
220
+ export const MessagesView = (props: any) => {
221
+ const orderDetailsProps = {
222
+ ...props,
223
+ UIComponent: OrderMessageUI,
224
+ };
225
+ return <OrderDetailsConTableoller {...orderDetailsProps} />;
226
+ };
227
+
228
+
229
+ export const MessageListing = (props: MessageListingParams) => {
230
+ const {
231
+ navigation
232
+ } = props
233
+ const [orderListStatus, setOrderListStatus] = useState({
234
+ error: null,
235
+ loading: false,
236
+ orders: []
237
+ })
238
+ const [selectedOrderId, setSelectedOrderId] = useState(null)
239
+ const [seletedOrder, setSeletedOrder] = useState<any>()
240
+ const [openMessages, setOpenMessges] = useState(false)
241
+ const [, t] = useLanguage()
242
+
243
+ const goToBack = () => {
244
+ navigation?.canGoBack() && navigation.goBack()
245
+ setSelectedOrderId(null)
246
+ setSeletedOrder([])
247
+ }
248
+
249
+ const handleCloseModal = () => {
250
+ setOpenMessges(false)
251
+ }
252
+
253
+ useEffect(() => {
254
+ if (!orderListStatus?.loading && selectedOrderId) {
255
+ const _orders = orderListStatus?.orders
256
+ const _seletedOrder = _orders.find((order: any) => order?.uuid === selectedOrderId)
257
+ setSeletedOrder(_seletedOrder)
258
+ }
259
+ }, [orderListStatus, selectedOrderId])
260
+
261
+ useEffect(() => {
262
+
263
+ }, [orderListStatus])
264
+
265
+ return (
266
+ <MessageListingWrapper>
267
+ <NavBar
268
+ title={t('MESSAGES', 'Messages')}
269
+ titleAlign={'center'}
270
+ onActionLeft={goToBack}
271
+ showCall={false}
272
+ paddingTop={10}
273
+ btnStyle={{ paddingLeft: 0 }}
274
+ />
275
+ <OrderListing
276
+ ordersLength={{ activeOrdersLength: 0, previousOrdersLength: 0 }}
277
+ setSelectedOrderId={setSelectedOrderId}
278
+ setOrderList={setOrderListStatus}
279
+ setOpenMessges={setOpenMessges}
280
+ />
281
+ {openMessages && seletedOrder && (
282
+ <OModal
283
+ open={openMessages}
284
+ entireModal
285
+ customClose
286
+ onClose={() => handleCloseModal()}
287
+ >
288
+ <MessagesView
289
+ order={seletedOrder}
290
+ setOpenMessges={setOpenMessges}
291
+ />
292
+ </OModal>
293
+ )}
294
+ </MessageListingWrapper>
295
+ )
296
+ }
297
+
@@ -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
- const chatDisabled = previousStatus.includes(order?.status)
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
- { 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
- ]
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
- const handleClickQuickMessage = (text: string) => {
54
- setMessage && setMessage(`${message}${text}`)
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
- 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
- }
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
- <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
- ) : (
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 ? 270 : 24);
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
- <Header>
400
- <OIconButton icon={theme.images.general.arrow_left} style={{ paddingStart: 10, borderColor: theme.colors.clear }} onClick={onClose} />
401
- <View style={{ marginRight: 10, shadowColor: theme.colors.black, shadowOpacity: 0.1, shadowOffset: { width: 0, height: 1 }, shadowRadius: 2 }}>
402
- <OIcon
403
- url={type === USER_TYPE.DRIVER ? order?.driver?.photo : order?.business?.logo}
404
- width={32}
405
- height={32}
406
- style={{ borderRadius: 7.6 }}
407
- />
408
- </View>
409
- <TitleHeader>
410
- <OText size={14} lineHeight={21} weight={'600'}>{type === USER_TYPE.DRIVER ? order?.driver?.name : order?.business?.name}</OText>
411
- <OText size={12} color={theme.colors.textSecondary}>{type === USER_TYPE.DRIVER ? t('DRIVER', 'Driver') : t('BUSINESS', 'Business')}</OText>
412
- </TitleHeader>
413
- </Header>
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
- editButton : {
464
- borderRadius: 50,
465
- backgroundColor: '#E9ECEF',
466
- marginRight: 10,
467
- height: 24,
468
- borderWidth: 1,
469
- paddingLeft: 0,
470
- paddingRight: 0
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) => {
@@ -17,3 +17,11 @@ export const Header = styled.View`
17
17
  export const TitleHeader = styled.View``
18
18
 
19
19
  export const QuickMessageContainer = styled.ScrollView``
20
+
21
+ export const ProfileMessageHeader = styled.View`
22
+ flex-direction: row;
23
+ justify-content: space-between;
24
+ align-items: center;
25
+ padding-bottom: 0px;
26
+ padding-horizontal: 20px;
27
+ `
@@ -13,6 +13,7 @@ import { Platform, StyleSheet, TouchableOpacity, View } from 'react-native';
13
13
  import { ProfileParams } from '../../types';
14
14
  import { LogoutButton } from '../LogoutButton'
15
15
  import { LanguageSelector } from '../LanguageSelector'
16
+ import MessageCircle from 'react-native-vector-icons/AntDesign'
16
17
 
17
18
  import {
18
19
  OIcon,
@@ -78,6 +79,11 @@ const ProfileListUI = (props: ProfileParams) => {
78
79
  pagePadding: {
79
80
  paddingLeft: 40,
80
81
  paddingRight: 40
82
+ },
83
+ messageIconStyle: {
84
+ fontSize: 18,
85
+ fontWeight: 'bold',
86
+ marginEnd: 14
81
87
  }
82
88
  });
83
89
 
@@ -150,6 +156,10 @@ const ProfileListUI = (props: ProfileParams) => {
150
156
  <OIcon src={theme.images.general.pin} width={16} color={theme.colors.textNormal} style={{ marginEnd: 14 }} />
151
157
  <OText size={14} lineHeight={24} weight={'400'} color={theme.colors.textNormal}>{t('MY_SAVED_PLACES', 'My saved places')}</OText>
152
158
  </ListItem>
159
+ <ListItem onPress={() => onRedirect('Messages', { isFromProfile: true, isGoBack: true })} activeOpacity={0.7}>
160
+ <MessageCircle name='message1' style={styles.messageIconStyle} color={theme.colors.textNormal} />
161
+ <OText size={14} lineHeight={24} weight={'400'} color={theme.colors.textNormal}>{t('MESSAGES', 'Messages')}</OText>
162
+ </ListItem>
153
163
  <ListItem onPress={() => navigation.navigate('Help', {})} activeOpacity={0.7}>
154
164
  <OIcon src={theme.images.general.ic_help} width={16} color={theme.colors.textNormal} style={{ marginEnd: 14 }} />
155
165
  <OText size={14} lineHeight={24} weight={'400'} color={theme.colors.textNormal}>{t('HELP', 'Help')}</OText>
@@ -261,7 +261,9 @@ export interface OrdersOptionParams {
261
261
  setOrderList?: any,
262
262
  preOrders?: boolean,
263
263
  setOrdersLength?: ({ activeOrdersLength, previousOrdersLength }: { activeOrdersLength: number, previousOrdersLength: number }) => void,
264
- ordersLength: { activeOrdersLength: number, previousOrdersLength: number }
264
+ ordersLength: { activeOrdersLength: number, previousOrdersLength: number },
265
+ setSelectedOrderId?: any,
266
+ setOpenMessges?: any
265
267
  }
266
268
  export interface ActiveOrdersParams {
267
269
  orders?: any,
@@ -272,7 +274,9 @@ export interface ActiveOrdersParams {
272
274
  setScreen?: any,
273
275
  screen?: any,
274
276
  loadMoreOrders?: () => {},
275
- onNavigationRedirect?: (route: string, params?: any) => {}
277
+ onNavigationRedirect?: (route: string, params?: any) => {},
278
+ isMessageView?: boolean,
279
+ handleClickOrder?: any
276
280
  }
277
281
  export interface PreviousOrdersParams {
278
282
  orders?: any,
@@ -334,6 +338,7 @@ export interface MessagesParams {
334
338
  setMessages?: () => {},
335
339
  readMessages?: () => {},
336
340
  onClose?: () => void,
341
+ isMeesageListing?: boolean
337
342
  }
338
343
  export interface ViewInterface {
339
344
  navigation?: any;
@@ -459,4 +464,7 @@ export interface HelpGuideParams {
459
464
  export interface HelpAccountAndPaymentParams {
460
465
  navigation: any;
461
466
  }
462
-
467
+
468
+ export interface MessageListingParams {
469
+ navigation: any;
470
+ }
@@ -177,4 +177,22 @@ export const getTypesText = (value: number) => {
177
177
  */
178
178
  export const convertToRadian = (value: number) => {
179
179
  return value * Math.PI / 180
180
+ }
181
+
182
+ /**
183
+ * Function to distance between two locations
184
+ * @param lat1 Lat for first location
185
+ * @param lon1 Lon for first location
186
+ * @param lat2 Lat for second location
187
+ * @param lon2 Lon for second location
188
+ */
189
+ export const getDistance = (lat1: any, lon1: any, lat2: any, lon2: any) => {
190
+ const R = 6371 // km
191
+ const dLat = convertToRadian(lat2 - lat1)
192
+ const dLon = convertToRadian(lon2 - lon1)
193
+ const curLat1 = convertToRadian(lat1)
194
+ const curLat2 = convertToRadian(lat2)
195
+ const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.sin(dLon / 2) * Math.sin(dLon / 2) * Math.cos(curLat1) * Math.cos(curLat2)
196
+ const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a))
197
+ return R * c
180
198
  }