ordering-ui-react-native 0.15.8 → 0.15.9
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
CHANGED
|
@@ -6,7 +6,7 @@ import { GiftedChat, Actions, InputToolbar, Composer, Send, Bubble, MessageImage
|
|
|
6
6
|
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
|
-
import { TouchableOpacity, ActivityIndicator, StyleSheet, View, Platform, Keyboard,I18nManager } from 'react-native'
|
|
9
|
+
import { TouchableOpacity, ActivityIndicator, StyleSheet, View, Platform, Keyboard, I18nManager } from 'react-native'
|
|
10
10
|
import { Header, TitleHeader, Wrapper, QuickMessageContainer } from './styles'
|
|
11
11
|
import { MessagesParams } from '../../types'
|
|
12
12
|
|
|
@@ -36,6 +36,8 @@ const ORDER_STATUS: any = {
|
|
|
36
36
|
19: 'ORDER_DRIVER_ALMOST_ARRIVED_CUSTOMER',
|
|
37
37
|
20: 'ORDER_CUSTOMER_ALMOST_ARRIVED_BUSINESS',
|
|
38
38
|
21: 'ORDER_CUSTOMER_ARRIVED_BUSINESS',
|
|
39
|
+
22: 'ORDER_LOOKING_FOR_DRIVER',
|
|
40
|
+
23: 'ORDER_DRIVER_ON_WAY'
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
const imgOptions = {
|
|
@@ -93,7 +95,7 @@ const MessagesUI = (props: MessagesParams) => {
|
|
|
93
95
|
}
|
|
94
96
|
|
|
95
97
|
const handleImagePicker = () => {
|
|
96
|
-
launchImageLibrary(imgOptions, (response
|
|
98
|
+
launchImageLibrary(imgOptions, (response: any) => {
|
|
97
99
|
if (response.didCancel) {
|
|
98
100
|
// showToast(ToastType.Error, response.errorMessage);
|
|
99
101
|
} else if (response.errorMessage) {
|
|
@@ -119,10 +121,10 @@ const MessagesUI = (props: MessagesParams) => {
|
|
|
119
121
|
const messageConsole = (message: any) => {
|
|
120
122
|
return message.change?.attribute !== 'driver_id'
|
|
121
123
|
?
|
|
122
|
-
`${t('ORDER', 'Order')} ${t(message.change.attribute.toUpperCase(), message.change.attribute.replace('_', ' '))} ${t('CHANGED_FROM', 'Changed from')} ${
|
|
123
|
-
|
|
124
|
-
`${message.change.old
|
|
125
|
-
|
|
124
|
+
`${t('ORDER', 'Order')} ${t(message.change.attribute.toUpperCase(), message.change.attribute.replace('_', ' '))} ${t('CHANGED_FROM', 'Changed from')} ${filterSpecialStatus.includes(message.change.attribute) ?
|
|
125
|
+
`${message.change.old === null ? '0' : message.change.old} ${t('TO', 'to')} ${message.change.new || ''} ${t('MINUTES', 'Minutes')}` :
|
|
126
|
+
message.change.attribute === 'status' ? `${message.change.old !== null && t(ORDER_STATUS[parseInt(message.change.old, 10)])} ${t('TO', 'to')} ${t(ORDER_STATUS[parseInt(message.change.new, 10)])}`
|
|
127
|
+
: `${message.change.old} ${t('TO', 'to')} ${message.change.new || t('EMPTY', 'Empty')}`
|
|
126
128
|
}`
|
|
127
129
|
: message.change.new
|
|
128
130
|
?
|
|
@@ -133,13 +135,17 @@ const MessagesUI = (props: MessagesParams) => {
|
|
|
133
135
|
|
|
134
136
|
useEffect(() => {
|
|
135
137
|
let newMessages: Array<any> = []
|
|
136
|
-
const
|
|
138
|
+
const consoleText = `${t('ORDER_PLACED_FOR', 'Order placed for')} ${parseDate(order?.created_at)} ${t('VIA', 'Via')} ${order?.app_id ? t(order?.app_id.toUpperCase(), order?.app_id) : t('OTHER', 'Other')}`
|
|
137
139
|
const firstMessage = {
|
|
138
140
|
_id: 0,
|
|
139
|
-
text:
|
|
141
|
+
text: consoleText,
|
|
140
142
|
createdAt: order?.created_at,
|
|
141
|
-
system: true
|
|
143
|
+
system: true,
|
|
144
|
+
user: {
|
|
145
|
+
_id: 0
|
|
146
|
+
}
|
|
142
147
|
}
|
|
148
|
+
|
|
143
149
|
messages.messages.map((message: any) => {
|
|
144
150
|
let newMessage
|
|
145
151
|
if (message.type !== 0 && (messagesToShow?.messages?.length || (message?.can_see?.includes('2')) || (message?.can_see?.includes('4') && type === USER_TYPE.DRIVER))) {
|
|
@@ -159,7 +165,9 @@ const MessagesUI = (props: MessagesParams) => {
|
|
|
159
165
|
if (message.type === 0) {
|
|
160
166
|
newMessage = firstMessage
|
|
161
167
|
}
|
|
162
|
-
|
|
168
|
+
if (newMessage) {
|
|
169
|
+
newMessages = [...newMessages, newMessage]
|
|
170
|
+
}
|
|
163
171
|
})
|
|
164
172
|
setFormattedMessages([...newMessages.reverse()])
|
|
165
173
|
}, [messages.messages.length])
|
|
@@ -177,7 +185,7 @@ const MessagesUI = (props: MessagesParams) => {
|
|
|
177
185
|
}
|
|
178
186
|
}, [])
|
|
179
187
|
|
|
180
|
-
const RenderActions = (props
|
|
188
|
+
const RenderActions = (props: any) => {
|
|
181
189
|
return (
|
|
182
190
|
<Actions
|
|
183
191
|
{...props}
|
|
@@ -210,7 +218,7 @@ const MessagesUI = (props: MessagesParams) => {
|
|
|
210
218
|
)
|
|
211
219
|
}
|
|
212
220
|
|
|
213
|
-
const renderInputToolbar = (props
|
|
221
|
+
const renderInputToolbar = (props: any) => (
|
|
214
222
|
<InputToolbar
|
|
215
223
|
{...props}
|
|
216
224
|
containerStyle={{
|
|
@@ -271,7 +279,7 @@ const MessagesUI = (props: MessagesParams) => {
|
|
|
271
279
|
<OText size={14}>{t('NOT_SEND_MESSAGES', 'You can\'t send messages because the order has ended')}</OText>
|
|
272
280
|
</View>
|
|
273
281
|
) : (
|
|
274
|
-
<View style={{flexDirection: 'row', width: '80%'}}>
|
|
282
|
+
<View style={{ flexDirection: 'row', width: '80%' }}>
|
|
275
283
|
<Composer
|
|
276
284
|
{...props}
|
|
277
285
|
textInputStyle={{
|
|
@@ -308,20 +316,20 @@ const MessagesUI = (props: MessagesParams) => {
|
|
|
308
316
|
alwaysShowSend
|
|
309
317
|
containerStyle={styles.containerSend}
|
|
310
318
|
>
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
319
|
+
<OIconButton
|
|
320
|
+
onClick={onSubmit}
|
|
321
|
+
style={{
|
|
322
|
+
height: 32,
|
|
323
|
+
borderRadius: 25,
|
|
324
|
+
opacity: (sendMessage?.loading || (message === '' && !image) || messages?.loading) ? 0.4 : 1,
|
|
325
|
+
borderColor: theme.colors.primary,
|
|
326
|
+
}}
|
|
327
|
+
iconStyle={{ marginTop: 3, marginRight: 2 }}
|
|
328
|
+
icon={!sendMessage?.loading ? paperIcon : undefined}
|
|
329
|
+
RenderIcon={sendMessage?.loading ? () => <ActivityIndicator size='small' color={theme.colors.primary} /> : undefined}
|
|
330
|
+
disabled={(sendMessage?.loading || (message === '' && !image) || messages?.loading)}
|
|
331
|
+
disabledColor={theme.colors.white}
|
|
332
|
+
/>
|
|
325
333
|
</Send>
|
|
326
334
|
)
|
|
327
335
|
|
|
@@ -338,7 +346,7 @@ const MessagesUI = (props: MessagesParams) => {
|
|
|
338
346
|
}}
|
|
339
347
|
wrapperStyle={{
|
|
340
348
|
left: { backgroundColor: '#f7f7f7', padding: 5, borderBottomLeftRadius: 0 },
|
|
341
|
-
right: { backgroundColor: theme.colors.primary, padding: 5, borderBottomRightRadius: 0}
|
|
349
|
+
right: { backgroundColor: theme.colors.primary, padding: 5, borderBottomRightRadius: 0 }
|
|
342
350
|
}}
|
|
343
351
|
/>
|
|
344
352
|
)
|
|
@@ -357,7 +365,7 @@ const MessagesUI = (props: MessagesParams) => {
|
|
|
357
365
|
<>
|
|
358
366
|
<Wrapper>
|
|
359
367
|
<Header>
|
|
360
|
-
|
|
368
|
+
<OIcon
|
|
361
369
|
url={type === USER_TYPE.DRIVER ? order?.driver?.photo : order?.business?.logo}
|
|
362
370
|
width={60}
|
|
363
371
|
height={60}
|
|
@@ -415,7 +423,7 @@ const styles = StyleSheet.create({
|
|
|
415
423
|
justifyContent: 'center',
|
|
416
424
|
marginHorizontal: 4
|
|
417
425
|
},
|
|
418
|
-
editButton
|
|
426
|
+
editButton: {
|
|
419
427
|
borderRadius: 50,
|
|
420
428
|
backgroundColor: '#E9ECEF',
|
|
421
429
|
marginRight: 10,
|
|
@@ -387,7 +387,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
387
387
|
<OText style={{ textAlign: 'left' }}>{order?.delivery_option?.name}</OText>
|
|
388
388
|
</View>
|
|
389
389
|
)}
|
|
390
|
-
{order?.comment && (
|
|
390
|
+
{!!order?.comment && (
|
|
391
391
|
<View>
|
|
392
392
|
<OText size={18} style={{ textAlign: 'left' }} >{t('COMMENT', 'Comment')}</OText>
|
|
393
393
|
<OText style={{ textAlign: 'left' }}>{order?.comment}</OText>
|
|
@@ -94,8 +94,8 @@ const ChatUI = (props: MessagesParams) => {
|
|
|
94
94
|
Dimensions.get('window').width < Dimensions.get('window').height
|
|
95
95
|
? parseInt(parseFloat(String(Dimensions.get('window').width)).toFixed(0))
|
|
96
96
|
: parseInt(
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
parseFloat(String(Dimensions.get('window').height)).toFixed(0),
|
|
98
|
+
);
|
|
99
99
|
|
|
100
100
|
const [orientation, setOrientation] = useState<string>(
|
|
101
101
|
Dimensions.get('window').width < Dimensions.get('window').height
|
|
@@ -218,7 +218,7 @@ const ChatUI = (props: MessagesParams) => {
|
|
|
218
218
|
paddingLeft: 12,
|
|
219
219
|
paddingRight: 5,
|
|
220
220
|
},
|
|
221
|
-
editButton
|
|
221
|
+
editButton: {
|
|
222
222
|
borderRadius: 50,
|
|
223
223
|
backgroundColor: '#E9ECEF',
|
|
224
224
|
marginRight: 10,
|
|
@@ -366,15 +366,18 @@ const ChatUI = (props: MessagesParams) => {
|
|
|
366
366
|
return 'ORDER_CUSTOMER_ALMOST_ARRIVED_BUSINESS';
|
|
367
367
|
case 21:
|
|
368
368
|
return 'ORDER_CUSTOMER_ARRIVED_BUSINESS';
|
|
369
|
+
case 22:
|
|
370
|
+
return 'ORDER_LOOKING_FOR_DRIVER'
|
|
371
|
+
case 23:
|
|
372
|
+
return 'ORDER_DRIVER_ON_WAY'
|
|
369
373
|
default:
|
|
370
374
|
return ``;
|
|
371
375
|
}
|
|
372
376
|
}
|
|
373
377
|
|
|
374
378
|
if (attribute === 'prepared_in' || attribute === 'delivered_in') {
|
|
375
|
-
return `${hour < 10 ? '0' + hour : hour}:${min < 10 ? '0' + min : min} ${
|
|
376
|
-
|
|
377
|
-
}`;
|
|
379
|
+
return `${hour < 10 ? '0' + hour : hour}:${min < 10 ? '0' + min : min} ${status > 60 ? 'hours' : 'minutes'
|
|
380
|
+
}`;
|
|
378
381
|
}
|
|
379
382
|
};
|
|
380
383
|
|
|
@@ -400,30 +403,27 @@ const ChatUI = (props: MessagesParams) => {
|
|
|
400
403
|
style={{ ...styles.firstMessageText, textAlign: 'center' }}>
|
|
401
404
|
{message.change?.attribute !== 'driver_id'
|
|
402
405
|
? `${t('ORDER', 'Order')} ${t(
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
? t(
|
|
408
|
-
getStatus(
|
|
409
|
-
parseInt(message.change.old, 10),
|
|
410
|
-
message.change?.attribute,
|
|
411
|
-
),
|
|
412
|
-
)
|
|
413
|
-
: '0'
|
|
414
|
-
} ${t('TO', 'to')} ${t(
|
|
406
|
+
message.change.attribute.toUpperCase(),
|
|
407
|
+
message.change.attribute,
|
|
408
|
+
)} ${t('CHANGED_FROM', 'Changed from')} ${message.change.old !== null
|
|
409
|
+
? t(
|
|
415
410
|
getStatus(
|
|
416
|
-
parseInt(message.change.
|
|
411
|
+
parseInt(message.change.old, 10),
|
|
417
412
|
message.change?.attribute,
|
|
418
413
|
),
|
|
419
|
-
)
|
|
414
|
+
)
|
|
415
|
+
: '0'
|
|
416
|
+
} ${t('TO', 'to')} ${t(
|
|
417
|
+
getStatus(
|
|
418
|
+
parseInt(message.change.new, 10),
|
|
419
|
+
message.change?.attribute,
|
|
420
|
+
),
|
|
421
|
+
)}`
|
|
420
422
|
: message.change.new
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
} ${t('WAS_ASSIGNED_AS_DRIVER', 'Was assigned as driver')} ${
|
|
424
|
-
message.comment ? message.comment.length : ''
|
|
423
|
+
? `${message.driver?.name} ${message.driver?.lastname !== null ? message.driver.lastname : ''
|
|
424
|
+
} ${t('WAS_ASSIGNED_AS_DRIVER', 'Was assigned as driver')} ${message.comment ? message.comment.length : ''
|
|
425
425
|
}`
|
|
426
|
-
|
|
426
|
+
: `${t('DRIVER_UNASSIGNED', 'Driver unassigned')}`}
|
|
427
427
|
</OText>
|
|
428
428
|
<OText size={10} color={'#aaa'} style={{ alignSelf: 'flex-start' }}>
|
|
429
429
|
{parseTime(message?.created_at, { outputFormat: 'hh:mma' })}
|
|
@@ -928,8 +928,8 @@ const ChatUI = (props: MessagesParams) => {
|
|
|
928
928
|
borderWidth: 0,
|
|
929
929
|
opacity:
|
|
930
930
|
sendMessage?.loading ||
|
|
931
|
-
|
|
932
|
-
|
|
931
|
+
(message === '' && !image) ||
|
|
932
|
+
messages?.loading
|
|
933
933
|
? 0.6
|
|
934
934
|
: 1,
|
|
935
935
|
borderColor: theme.colors.transparent,
|
|
@@ -1034,7 +1034,7 @@ const ChatUI = (props: MessagesParams) => {
|
|
|
1034
1034
|
<OIcon
|
|
1035
1035
|
url={optimizeImage(
|
|
1036
1036
|
order?.customer?.photo ||
|
|
1037
|
-
|
|
1037
|
+
theme?.images?.dummies?.customerPhoto,
|
|
1038
1038
|
'h_300,c_limit',
|
|
1039
1039
|
)}
|
|
1040
1040
|
style={styles.avatarIcon}
|
|
@@ -1141,7 +1141,7 @@ const ChatUI = (props: MessagesParams) => {
|
|
|
1141
1141
|
backgroundColor={theme.colors.composerView}
|
|
1142
1142
|
onEnd={handleEnd}
|
|
1143
1143
|
/>
|
|
1144
|
-
|
|
1144
|
+
<TouchableOpacity
|
|
1145
1145
|
style={{
|
|
1146
1146
|
position: 'absolute',
|
|
1147
1147
|
right: 35,
|
|
@@ -35,6 +35,8 @@ const ORDER_STATUS: any = {
|
|
|
35
35
|
19: 'ORDER_DRIVER_ALMOST_ARRIVED_CUSTOMER',
|
|
36
36
|
20: 'ORDER_CUSTOMER_ALMOST_ARRIVED_BUSINESS',
|
|
37
37
|
21: 'ORDER_CUSTOMER_ARRIVED_BUSINESS',
|
|
38
|
+
22: 'ORDER_LOOKING_FOR_DRIVER',
|
|
39
|
+
23: 'ORDER_DRIVER_ON_WAY'
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
const filterSpecialStatus = ['prepared_in', 'delivered_in']
|