ordering-ui-react-native 0.12.18 → 0.12.19
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/config.json +2 -2
- package/themes/business/src/components 2/AcceptOrRejectOrder/index.tsx +0 -389
- package/themes/business/src/components 2/AcceptOrRejectOrder/styles.tsx +0 -36
- package/themes/business/src/components 2/BusinessController/index.tsx +0 -155
- package/themes/business/src/components 2/BusinessController/styles.tsx +0 -19
- package/themes/business/src/components 2/Chat/index.tsx +0 -1152
- package/themes/business/src/components 2/Chat/styles.tsx +0 -12
- package/themes/business/src/components 2/Contacts/index.tsx +0 -299
- package/themes/business/src/components 2/Contacts/styles.tsx +0 -42
- package/themes/business/src/components 2/DriverMap/index.tsx +0 -525
- package/themes/business/src/components 2/FloatingButton/index.tsx +0 -141
- package/themes/business/src/components 2/FloatingButton/styles.tsx +0 -35
- package/themes/business/src/components 2/ForgotPasswordForm/index.tsx +0 -204
- package/themes/business/src/components 2/ForgotPasswordForm/styles.tsx +0 -11
- package/themes/business/src/components 2/GoogleMap/index.tsx +0 -347
- package/themes/business/src/components 2/Home/index.tsx +0 -111
- package/themes/business/src/components 2/Home/styles.tsx +0 -27
- package/themes/business/src/components 2/LanguageSelector/index.tsx +0 -124
- package/themes/business/src/components 2/LanguageSelector/lang_country.json +0 -152
- package/themes/business/src/components 2/LanguageSelector/styles.tsx +0 -17
- package/themes/business/src/components 2/LoginForm/index.tsx +0 -663
- package/themes/business/src/components 2/LoginForm/styles.tsx +0 -48
- package/themes/business/src/components 2/LogoutButton/index.tsx +0 -63
- package/themes/business/src/components 2/MapView/index.tsx +0 -317
- package/themes/business/src/components 2/MessagesOption/index.tsx +0 -337
- package/themes/business/src/components 2/MessagesOption/styles.tsx +0 -27
- package/themes/business/src/components 2/NewOrderNotification/index.tsx +0 -167
- package/themes/business/src/components 2/NewOrderNotification/styles.tsx +0 -8
- package/themes/business/src/components 2/NotFoundSource/index.tsx +0 -52
- package/themes/business/src/components 2/NotFoundSource/styles.tsx +0 -17
- package/themes/business/src/components 2/OrderDetails/Business.tsx +0 -683
- package/themes/business/src/components 2/OrderDetails/Delivery.tsx +0 -454
- package/themes/business/src/components 2/OrderDetails/OrderContentComponent.tsx +0 -391
- package/themes/business/src/components 2/OrderDetails/OrderHeaderComponent.tsx +0 -148
- package/themes/business/src/components 2/OrderDetails/styles.tsx +0 -84
- package/themes/business/src/components 2/OrderMessage/index.tsx +0 -344
- package/themes/business/src/components 2/OrderMessage/styles.tsx +0 -5
- package/themes/business/src/components 2/OrderSummary/index.tsx +0 -700
- package/themes/business/src/components 2/OrderSummary/styles.tsx +0 -61
- package/themes/business/src/components 2/OrdersOption/index.tsx +0 -755
- package/themes/business/src/components 2/OrdersOption/styles.tsx +0 -54
- package/themes/business/src/components 2/OrdersOptionBusiness/index.tsx +0 -51
- package/themes/business/src/components 2/OrdersOptionBusiness/styles.tsx +0 -8
- package/themes/business/src/components 2/OrdersOptionCity/index.tsx +0 -52
- package/themes/business/src/components 2/OrdersOptionCity/styles.tsx +0 -8
- package/themes/business/src/components 2/OrdersOptionDate/index.tsx +0 -52
- package/themes/business/src/components 2/OrdersOptionDate/styles.tsx +0 -8
- package/themes/business/src/components 2/OrdersOptionDelivery/index.tsx +0 -35
- package/themes/business/src/components 2/OrdersOptionDelivery/styles.tsx +0 -8
- package/themes/business/src/components 2/OrdersOptionDriver/index.tsx +0 -50
- package/themes/business/src/components 2/OrdersOptionDriver/styles.tsx +0 -8
- package/themes/business/src/components 2/OrdersOptionPaymethod/index.tsx +0 -49
- package/themes/business/src/components 2/OrdersOptionPaymethod/styles.tsx +0 -8
- package/themes/business/src/components 2/OrdersOptionStatus/index.tsx +0 -46
- package/themes/business/src/components 2/OrdersOptionStatus/styles.tsx +0 -8
- package/themes/business/src/components 2/PhoneInputNumber/index.tsx +0 -160
- package/themes/business/src/components 2/PhoneInputNumber/styles.tsx +0 -3
- package/themes/business/src/components 2/PreviousMessages/index.tsx +0 -304
- package/themes/business/src/components 2/PreviousMessages/styles.tsx +0 -32
- package/themes/business/src/components 2/PreviousOrders/index.tsx +0 -180
- package/themes/business/src/components 2/PreviousOrders/styles.tsx +0 -38
- package/themes/business/src/components 2/ProductItemAccordion/index.tsx +0 -301
- package/themes/business/src/components 2/ProductItemAccordion/styles.tsx +0 -61
- package/themes/business/src/components 2/SearchBar/index.tsx +0 -112
- package/themes/business/src/components 2/SignupForm/index.tsx +0 -530
- package/themes/business/src/components 2/SignupForm/styles.tsx +0 -16
- package/themes/business/src/components 2/StoresList/index.tsx +0 -208
- package/themes/business/src/components 2/StoresList/styles.tsx +0 -26
- package/themes/business/src/components 2/UserFormDetails/index.tsx +0 -513
- package/themes/business/src/components 2/UserFormDetails/styles.tsx +0 -40
- package/themes/business/src/components 2/UserProfileForm/index.tsx +0 -496
- package/themes/business/src/components 2/UserProfileForm/styles.tsx +0 -36
- package/themes/business/src/components 2/VerifyPhone/index.tsx +0 -201
- package/themes/business/src/components 2/VerifyPhone/styles.tsx +0 -43
- package/themes/business/src/components 2/shared/OAlert.tsx +0 -52
- package/themes/business/src/components 2/shared/OButton.tsx +0 -149
- package/themes/business/src/components 2/shared/OChatBubble.tsx +0 -100
- package/themes/business/src/components 2/shared/ODropDown.tsx +0 -195
- package/themes/business/src/components 2/shared/ODropDownCalendar.tsx +0 -328
- package/themes/business/src/components 2/shared/OFab.tsx +0 -54
- package/themes/business/src/components 2/shared/OIcon.tsx +0 -67
- package/themes/business/src/components 2/shared/OIconButton.tsx +0 -127
- package/themes/business/src/components 2/shared/OInput.tsx +0 -144
- package/themes/business/src/components 2/shared/OLink.tsx +0 -76
- package/themes/business/src/components 2/shared/OModal.tsx +0 -275
- package/themes/business/src/components 2/shared/OSegment.tsx +0 -86
- package/themes/business/src/components 2/shared/OText.tsx +0 -55
- package/themes/business/src/components 2/shared/OTextarea.tsx +0 -46
- package/themes/business/src/components 2/shared/OToast.tsx +0 -92
- package/themes/business/src/components 2/shared/index.tsx +0 -27
|
@@ -1,683 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
StyleSheet,
|
|
4
|
-
View,
|
|
5
|
-
TouchableOpacity,
|
|
6
|
-
ActivityIndicator,
|
|
7
|
-
} from 'react-native';
|
|
8
|
-
import Clipboard from '@react-native-clipboard/clipboard';
|
|
9
|
-
import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
|
|
10
|
-
import { useTheme } from 'styled-components/native';
|
|
11
|
-
import {
|
|
12
|
-
ToastType,
|
|
13
|
-
useToast,
|
|
14
|
-
useLanguage,
|
|
15
|
-
OrderDetails as OrderDetailsController,
|
|
16
|
-
useUtils,
|
|
17
|
-
useConfig,
|
|
18
|
-
useSession,
|
|
19
|
-
} from 'ordering-components/native';
|
|
20
|
-
import {
|
|
21
|
-
OrderDetailsContainer,
|
|
22
|
-
Pickup,
|
|
23
|
-
AssignDriver,
|
|
24
|
-
DriverItem,
|
|
25
|
-
} from './styles';
|
|
26
|
-
import { AcceptOrRejectOrder } from '../AcceptOrRejectOrder';
|
|
27
|
-
import { Chat } from '../Chat';
|
|
28
|
-
import { FloatingButton } from '../FloatingButton';
|
|
29
|
-
import { GoogleMap } from '../GoogleMap';
|
|
30
|
-
import { OButton, OModal, OText, OIcon } from '../shared';
|
|
31
|
-
import { OrderDetailsParams } from '../../types';
|
|
32
|
-
import { verifyDecimals, getProductPrice, getOrderStatus } from '../../utils';
|
|
33
|
-
import { USER_TYPE } from '../../config/constants';
|
|
34
|
-
import CountryPicker from 'react-native-country-picker-modal';
|
|
35
|
-
import { NotFoundSource } from '../NotFoundSource';
|
|
36
|
-
import { OrderHeaderComponent } from './OrderHeaderComponent';
|
|
37
|
-
import { OrderContentComponent } from './OrderContentComponent';
|
|
38
|
-
|
|
39
|
-
export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
40
|
-
const {
|
|
41
|
-
navigation,
|
|
42
|
-
messages,
|
|
43
|
-
setMessages,
|
|
44
|
-
readMessages,
|
|
45
|
-
messagesReadList,
|
|
46
|
-
handleAssignDriver,
|
|
47
|
-
handleChangeOrderStatus,
|
|
48
|
-
isFromCheckout,
|
|
49
|
-
driverLocation,
|
|
50
|
-
actions,
|
|
51
|
-
titleAccept,
|
|
52
|
-
titleReject,
|
|
53
|
-
appTitle,
|
|
54
|
-
} = props;
|
|
55
|
-
|
|
56
|
-
const theme = useTheme();
|
|
57
|
-
const [, t] = useLanguage();
|
|
58
|
-
const [{ parsePrice, parseNumber, parseDate }] = useUtils();
|
|
59
|
-
const [{ user, token }] = useSession();
|
|
60
|
-
const [{ configs }] = useConfig();
|
|
61
|
-
const [, { showToast }] = useToast();
|
|
62
|
-
const [unreadAlert, setUnreadAlert] = useState({
|
|
63
|
-
business: false,
|
|
64
|
-
driver: false,
|
|
65
|
-
});
|
|
66
|
-
const { order, businessData, loading, error } = props.order;
|
|
67
|
-
const { drivers, loadingDriver } = props.drivers;
|
|
68
|
-
const itemsDrivers: any = [];
|
|
69
|
-
const [actionOrder, setActionOrder] = useState('');
|
|
70
|
-
const [openModalForBusiness, setOpenModalForBusiness] = useState(false);
|
|
71
|
-
const [openModalForAccept, setOpenModalForAccept] = useState(false);
|
|
72
|
-
const [openModalForMapView, setOpenModalForMapView] = useState(false);
|
|
73
|
-
const [isDriverModalVisible, setIsDriverModalVisible] = useState(false);
|
|
74
|
-
|
|
75
|
-
if (order?.status === 7 || order?.status === 4) {
|
|
76
|
-
if (drivers?.length > 0 && drivers) {
|
|
77
|
-
drivers.forEach((driver: any) => {
|
|
78
|
-
itemsDrivers.push({
|
|
79
|
-
available: driver?.available,
|
|
80
|
-
key: driver?.id,
|
|
81
|
-
value: driver?.id,
|
|
82
|
-
label: driver?.name,
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
if (
|
|
87
|
-
!drivers?.some((driver: any) => driver?.id === order?.driver?.id) &&
|
|
88
|
-
order?.driver?.id
|
|
89
|
-
) {
|
|
90
|
-
itemsDrivers.push({
|
|
91
|
-
available: order?.driver?.available,
|
|
92
|
-
key: order?.driver?.id,
|
|
93
|
-
value: order?.driver?.id,
|
|
94
|
-
label: order?.driver?.name,
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (order?.driver && (!drivers?.length || drivers?.length === 0)) {
|
|
100
|
-
itemsDrivers.push({
|
|
101
|
-
available: order?.driver?.available,
|
|
102
|
-
key: order?.driver?.id,
|
|
103
|
-
value: order?.driver?.id,
|
|
104
|
-
label: order?.driver?.name,
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (order?.driver) {
|
|
109
|
-
itemsDrivers.push({
|
|
110
|
-
available: true,
|
|
111
|
-
key: null,
|
|
112
|
-
value: null,
|
|
113
|
-
label: t('UNASSIGN_DRIVER', 'Unassign Driver'),
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
if (itemsDrivers.length > 0) {
|
|
118
|
-
itemsDrivers.sort((a: any, b: any) => {
|
|
119
|
-
if (a.available > b.available) return -1;
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
const getFormattedSubOptionName = ({ quantity, name, position, price }: any) => {
|
|
125
|
-
if (name !== 'No') {
|
|
126
|
-
const pos = position && position !== 'whole' ? `(${t(position.toUpperCase(), position)})` : '';
|
|
127
|
-
return pos
|
|
128
|
-
? `${quantity} x ${name} ${pos} +${parsePrice(price)}\n`
|
|
129
|
-
: `${quantity} x ${name} +${parsePrice(price)}\n`;
|
|
130
|
-
} else {
|
|
131
|
-
return 'No\n';
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
const handleCopyClipboard = () => {
|
|
136
|
-
const businessName = !!order?.business?.name
|
|
137
|
-
? `${order?.business?.name} \n`
|
|
138
|
-
: '';
|
|
139
|
-
|
|
140
|
-
const businessEmail = !!order?.business?.email
|
|
141
|
-
? `${order?.business?.email} \n`
|
|
142
|
-
: '';
|
|
143
|
-
|
|
144
|
-
const businessCellphone = !!order?.business?.cellphone
|
|
145
|
-
? `${order?.business?.cellphone} \n`
|
|
146
|
-
: '';
|
|
147
|
-
|
|
148
|
-
const businessPhone = !!order?.business?.phone
|
|
149
|
-
? `${order?.business?.phone} \n`
|
|
150
|
-
: '';
|
|
151
|
-
|
|
152
|
-
const businessAddress = !!order?.business?.address
|
|
153
|
-
? `${order?.business?.address} \n`
|
|
154
|
-
: '';
|
|
155
|
-
|
|
156
|
-
const businessSpecialAddress = !!order?.business?.address_notes
|
|
157
|
-
? `${order?.business?.address_notes} \n \n`
|
|
158
|
-
: '';
|
|
159
|
-
|
|
160
|
-
const customerName = !!order?.customer?.name
|
|
161
|
-
? `${order?.customer?.name} ${order?.customer?.middle_name || ''} ${
|
|
162
|
-
order?.customer?.lastname || ''
|
|
163
|
-
} ${order?.customer?.second_lastname || ''} \n`
|
|
164
|
-
: '';
|
|
165
|
-
|
|
166
|
-
const customerEmail = !!order?.customer.email
|
|
167
|
-
? `${order?.customer.email} \n`
|
|
168
|
-
: '';
|
|
169
|
-
|
|
170
|
-
const customerCellPhone = !!order?.customer?.cellphone
|
|
171
|
-
? `${order?.customer?.cellphone} \n`
|
|
172
|
-
: '';
|
|
173
|
-
|
|
174
|
-
const customerPhone = !!order?.customer?.phone
|
|
175
|
-
? `${order?.customer?.phone} \n`
|
|
176
|
-
: '';
|
|
177
|
-
|
|
178
|
-
const customerAddress = !!order?.customer?.address
|
|
179
|
-
? `${order?.customer?.address} \n`
|
|
180
|
-
: '';
|
|
181
|
-
|
|
182
|
-
const customerSpecialAddress = !!order?.customer?.address_notes
|
|
183
|
-
? `${order?.customer?.address_notes} \n`
|
|
184
|
-
: '';
|
|
185
|
-
|
|
186
|
-
const payment = order?.paymethod?.name
|
|
187
|
-
? `${order?.paymethod?.name} - ${
|
|
188
|
-
order.delivery_type === 1
|
|
189
|
-
? t('DELIVERY', 'Delivery')
|
|
190
|
-
: order.delivery_type === 2
|
|
191
|
-
? t('PICKUP', 'Pickup')
|
|
192
|
-
: order.delivery_type === 3
|
|
193
|
-
? t('EAT_IN', 'Eat in')
|
|
194
|
-
: order.delivery_type === 4
|
|
195
|
-
? t('CURBSIDE', 'Curbside')
|
|
196
|
-
: t('DRIVER_THRU', 'Driver thru')
|
|
197
|
-
}\n`
|
|
198
|
-
: '';
|
|
199
|
-
|
|
200
|
-
const getSuboptions = (suboptions: any) => {
|
|
201
|
-
const array: any = []
|
|
202
|
-
suboptions?.length > 0 &&
|
|
203
|
-
suboptions?.map((suboption: any) => {
|
|
204
|
-
const string = `${getFormattedSubOptionName(suboption)}`
|
|
205
|
-
array.push(string)
|
|
206
|
-
})
|
|
207
|
-
|
|
208
|
-
return array.join('')
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
const getOptions = (options: any, productComment: string = '') => {
|
|
212
|
-
const array: any = [];
|
|
213
|
-
|
|
214
|
-
options?.length &&
|
|
215
|
-
options?.map((option: any) => {
|
|
216
|
-
const string =
|
|
217
|
-
` ${option.name}\n ${getSuboptions(option.suboptions)}`;
|
|
218
|
-
|
|
219
|
-
array.push(string)
|
|
220
|
-
})
|
|
221
|
-
|
|
222
|
-
if (productComment) {
|
|
223
|
-
array.push(` ${t('COMMENT', 'Comment')}\n ${productComment}\n`)
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
return array.join('')
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
const productsInArray =
|
|
230
|
-
order?.products.length &&
|
|
231
|
-
order?.products.map((product: any, i: number) => {
|
|
232
|
-
const string =
|
|
233
|
-
`${product?.quantity} X ${product?.name} ${parsePrice(product.total ?? getProductPrice(product))}\n${getOptions(product.options, product.comment)}`;
|
|
234
|
-
|
|
235
|
-
return i === 0 ? ` ${string}` : string
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
const productsInString = productsInArray.join(' ');
|
|
239
|
-
const orderDetails = `${t(
|
|
240
|
-
'ORDER_DETAILS',
|
|
241
|
-
'Order Details',
|
|
242
|
-
)}:\n${productsInString}\n`;
|
|
243
|
-
|
|
244
|
-
const subtotal = `${t('SUBTOTAL', 'Subtotal')}: ${parsePrice(
|
|
245
|
-
order?.subtotal,
|
|
246
|
-
)}\n`;
|
|
247
|
-
|
|
248
|
-
const drivertip = `${t('DRIVER_TIP', 'Driver tip')} ${parsePrice(
|
|
249
|
-
order?.summary?.driver_tip || order?.totalDriverTip,
|
|
250
|
-
)}\n`;
|
|
251
|
-
|
|
252
|
-
const deliveryFee = `${t('DELIVERY_FEE', 'Delivery fee')} ${verifyDecimals(
|
|
253
|
-
order?.service_fee,
|
|
254
|
-
parseNumber,
|
|
255
|
-
)}% ${parsePrice(order?.summary?.service_fee || order?.serviceFee || 0)}\n`;
|
|
256
|
-
|
|
257
|
-
const total = `${t('TOTAL', 'Total')} ${parsePrice(
|
|
258
|
-
order?.summary?.total || order?.total,
|
|
259
|
-
)}\n`;
|
|
260
|
-
|
|
261
|
-
const orderStatus = `${t('INVOICE_ORDER_NO', 'Order No.')} ${order.id} ${t(
|
|
262
|
-
'IS',
|
|
263
|
-
'is',
|
|
264
|
-
)} ${getOrderStatus(order?.status, t)?.value}\n`;
|
|
265
|
-
|
|
266
|
-
Clipboard.setString(
|
|
267
|
-
`${orderStatus} ${payment} ${t(
|
|
268
|
-
'BUSINESS_DETAILS',
|
|
269
|
-
'Business Details',
|
|
270
|
-
)}\n ${businessName} ${businessEmail} ${businessCellphone} ${businessPhone} ${businessAddress} ${businessSpecialAddress}${t(
|
|
271
|
-
'CUSTOMER_DETAILS',
|
|
272
|
-
'Customer Details',
|
|
273
|
-
)}\n ${customerName} ${customerEmail} ${customerCellPhone} ${customerPhone} ${customerAddress} ${customerSpecialAddress}\n${orderDetails} ${subtotal} ${drivertip} ${deliveryFee} ${total}`,
|
|
274
|
-
);
|
|
275
|
-
|
|
276
|
-
showToast(
|
|
277
|
-
ToastType.Info,
|
|
278
|
-
t('COPY_TO_CLIPBOARD', 'Copy to clipboard.'),
|
|
279
|
-
1000,
|
|
280
|
-
);
|
|
281
|
-
};
|
|
282
|
-
|
|
283
|
-
const handleOpenMessagesForBusiness = () => {
|
|
284
|
-
setOpenModalForBusiness(true);
|
|
285
|
-
readMessages && readMessages();
|
|
286
|
-
setUnreadAlert({ ...unreadAlert, business: false });
|
|
287
|
-
};
|
|
288
|
-
|
|
289
|
-
const handleViewActionOrder = (action: string) => {
|
|
290
|
-
if (openModalForMapView) {
|
|
291
|
-
setOpenModalForMapView(false);
|
|
292
|
-
}
|
|
293
|
-
setActionOrder(action);
|
|
294
|
-
setOpenModalForAccept(true);
|
|
295
|
-
};
|
|
296
|
-
|
|
297
|
-
const handleViewSummaryOrder = () => {
|
|
298
|
-
navigation?.navigate &&
|
|
299
|
-
navigation.navigate('OrderSummary', {
|
|
300
|
-
order,
|
|
301
|
-
orderStatus: getOrderStatus(order?.status, t)?.value,
|
|
302
|
-
});
|
|
303
|
-
};
|
|
304
|
-
|
|
305
|
-
const handleCloseModal = () => {
|
|
306
|
-
setOpenModalForBusiness(false);
|
|
307
|
-
};
|
|
308
|
-
|
|
309
|
-
const handleOpenMapView = () => {
|
|
310
|
-
setOpenModalForMapView(!openModalForMapView);
|
|
311
|
-
};
|
|
312
|
-
|
|
313
|
-
const handleArrowBack: any = () => {
|
|
314
|
-
navigation?.canGoBack() && navigation.goBack();
|
|
315
|
-
};
|
|
316
|
-
|
|
317
|
-
useEffect(() => {
|
|
318
|
-
if (messagesReadList?.length) {
|
|
319
|
-
openModalForBusiness
|
|
320
|
-
? setUnreadAlert({ ...unreadAlert, business: false })
|
|
321
|
-
: setUnreadAlert({ ...unreadAlert, driver: false });
|
|
322
|
-
}
|
|
323
|
-
}, [messagesReadList]);
|
|
324
|
-
|
|
325
|
-
const locations = [
|
|
326
|
-
{
|
|
327
|
-
...order?.driver?.location,
|
|
328
|
-
title: t('DRIVER', 'Driver'),
|
|
329
|
-
icon:
|
|
330
|
-
order?.driver?.photo ||
|
|
331
|
-
'https://res.cloudinary.com/demo/image/fetch/c_thumb,g_face,r_max/https://www.freeiconspng.com/thumbs/driver-icon/driver-icon-14.png',
|
|
332
|
-
level: 4,
|
|
333
|
-
},
|
|
334
|
-
{
|
|
335
|
-
...order?.business?.location,
|
|
336
|
-
title: order?.business?.name,
|
|
337
|
-
icon: order?.business?.logo || theme.images.dummies.businessLogo,
|
|
338
|
-
level: 2,
|
|
339
|
-
},
|
|
340
|
-
{
|
|
341
|
-
...order?.customer?.location,
|
|
342
|
-
title: t('CUSTOMER', 'Customer'),
|
|
343
|
-
icon:
|
|
344
|
-
order?.customer?.photo ||
|
|
345
|
-
'https://res.cloudinary.com/demo/image/upload/c_thumb,g_face,r_max/d_avatar.png/non_existing_id.png',
|
|
346
|
-
level: 3,
|
|
347
|
-
},
|
|
348
|
-
];
|
|
349
|
-
|
|
350
|
-
useEffect(() => {
|
|
351
|
-
if (openModalForAccept) {
|
|
352
|
-
setOpenModalForAccept(false);
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
if (openModalForMapView) {
|
|
356
|
-
setOpenModalForMapView(false);
|
|
357
|
-
}
|
|
358
|
-
}, [loading]);
|
|
359
|
-
|
|
360
|
-
const showFloatButtonsAcceptOrReject: any = {
|
|
361
|
-
0: true,
|
|
362
|
-
};
|
|
363
|
-
|
|
364
|
-
useEffect(() => {
|
|
365
|
-
if (driverLocation) {
|
|
366
|
-
locations[0] = { ...locations[0], driverLocation };
|
|
367
|
-
}
|
|
368
|
-
}, [driverLocation]);
|
|
369
|
-
|
|
370
|
-
const styles = StyleSheet.create({
|
|
371
|
-
driverOff: {
|
|
372
|
-
backgroundColor: theme.colors.notAvailable,
|
|
373
|
-
},
|
|
374
|
-
btnPickUp: {
|
|
375
|
-
borderWidth: 0,
|
|
376
|
-
backgroundColor: theme.colors.btnBGWhite,
|
|
377
|
-
borderRadius: 8,
|
|
378
|
-
},
|
|
379
|
-
});
|
|
380
|
-
|
|
381
|
-
const locationsToSend = locations.filter(
|
|
382
|
-
(location: any) => location?.lat && location?.lng,
|
|
383
|
-
);
|
|
384
|
-
|
|
385
|
-
return (
|
|
386
|
-
<>
|
|
387
|
-
{(!order || Object.keys(order).length === 0) &&
|
|
388
|
-
(error?.length < 1 || !error) && (
|
|
389
|
-
<View
|
|
390
|
-
style={{
|
|
391
|
-
backgroundColor: theme.colors.backgroundLight,
|
|
392
|
-
}}>
|
|
393
|
-
{[...Array(6)].map((item, i) => (
|
|
394
|
-
<Placeholder key={i} Animation={Fade}>
|
|
395
|
-
<View style={{ flexDirection: 'row', marginBottom: 30 }}>
|
|
396
|
-
<Placeholder>
|
|
397
|
-
<PlaceholderLine width={90} />
|
|
398
|
-
<PlaceholderLine width={50} />
|
|
399
|
-
<PlaceholderLine width={20} />
|
|
400
|
-
<PlaceholderLine width={10} />
|
|
401
|
-
</Placeholder>
|
|
402
|
-
</View>
|
|
403
|
-
</Placeholder>
|
|
404
|
-
))}
|
|
405
|
-
</View>
|
|
406
|
-
)}
|
|
407
|
-
|
|
408
|
-
{(!!error || error) && (
|
|
409
|
-
<NotFoundSource
|
|
410
|
-
btnTitle={t('GO_TO_MY_ORDERS', 'Go to my orders')}
|
|
411
|
-
content={
|
|
412
|
-
props.order.error[0] ||
|
|
413
|
-
props.order.error ||
|
|
414
|
-
t('NETWORK_ERROR', 'Network Error')
|
|
415
|
-
}
|
|
416
|
-
onClickButton={() => navigation.navigate('Orders')}
|
|
417
|
-
/>
|
|
418
|
-
)}
|
|
419
|
-
|
|
420
|
-
{order && Object.keys(order).length > 0 && (error?.length < 1 || !error) && (
|
|
421
|
-
<View style={{ flex: 1 }}>
|
|
422
|
-
<OrderHeaderComponent
|
|
423
|
-
order={order}
|
|
424
|
-
handleOpenMapView={handleOpenMapView}
|
|
425
|
-
handleOpenMessagesForBusiness={handleOpenMessagesForBusiness}
|
|
426
|
-
getOrderStatus={getOrderStatus}
|
|
427
|
-
handleArrowBack={handleArrowBack}
|
|
428
|
-
/>
|
|
429
|
-
<OrderDetailsContainer
|
|
430
|
-
keyboardShouldPersistTaps="handled"
|
|
431
|
-
showsVerticalScrollIndicator={false}>
|
|
432
|
-
<>
|
|
433
|
-
<OrderContentComponent order={order} />
|
|
434
|
-
{(order?.status === 7 || order?.status === 4) &&
|
|
435
|
-
order?.delivery_type === 1 && (
|
|
436
|
-
<AssignDriver>
|
|
437
|
-
<OText style={{ marginBottom: 5 }} size={16} weight="600">
|
|
438
|
-
{t('ASSIGN_DRIVER', 'Assign driver')}
|
|
439
|
-
</OText>
|
|
440
|
-
|
|
441
|
-
<View
|
|
442
|
-
style={{
|
|
443
|
-
backgroundColor: theme.colors.inputChat,
|
|
444
|
-
borderRadius: 7.5,
|
|
445
|
-
}}>
|
|
446
|
-
<CountryPicker
|
|
447
|
-
// @ts-ignore
|
|
448
|
-
countryCode={undefined}
|
|
449
|
-
visible={isDriverModalVisible}
|
|
450
|
-
onClose={() => setIsDriverModalVisible(false)}
|
|
451
|
-
withCountryNameButton
|
|
452
|
-
renderFlagButton={() => (
|
|
453
|
-
<>
|
|
454
|
-
<TouchableOpacity
|
|
455
|
-
onPress={() => setIsDriverModalVisible(true)}
|
|
456
|
-
disabled={
|
|
457
|
-
itemsDrivers.length === 0 || loadingDriver
|
|
458
|
-
}>
|
|
459
|
-
{loadingDriver ? (
|
|
460
|
-
<DriverItem justifyContent="center">
|
|
461
|
-
<ActivityIndicator
|
|
462
|
-
size="small"
|
|
463
|
-
color={theme.colors.primary}
|
|
464
|
-
/>
|
|
465
|
-
</DriverItem>
|
|
466
|
-
) : (
|
|
467
|
-
<DriverItem justifyContent="space-between">
|
|
468
|
-
<OText>
|
|
469
|
-
{itemsDrivers.length > 0
|
|
470
|
-
? order?.driver?.name ||
|
|
471
|
-
t('SELECT_DRIVER', 'Select Driver')
|
|
472
|
-
: t('WITHOUT_DRIVERS', 'Without drivers')}
|
|
473
|
-
</OText>
|
|
474
|
-
<OIcon
|
|
475
|
-
src={theme?.images?.general?.chevronDown}
|
|
476
|
-
color={theme.colors.backArrow}
|
|
477
|
-
width={20}
|
|
478
|
-
height={20}
|
|
479
|
-
/>
|
|
480
|
-
</DriverItem>
|
|
481
|
-
)}
|
|
482
|
-
</TouchableOpacity>
|
|
483
|
-
</>
|
|
484
|
-
)}
|
|
485
|
-
flatListProps={{
|
|
486
|
-
keyExtractor: (item: any) => item.value,
|
|
487
|
-
data: itemsDrivers || [],
|
|
488
|
-
renderItem: ({ item }: any) => (
|
|
489
|
-
<TouchableOpacity
|
|
490
|
-
style={!item.available && styles.driverOff}
|
|
491
|
-
disabled={
|
|
492
|
-
!item.available ||
|
|
493
|
-
order?.driver?.id === item.value
|
|
494
|
-
}
|
|
495
|
-
onPress={() => {
|
|
496
|
-
handleAssignDriver &&
|
|
497
|
-
handleAssignDriver(item.value);
|
|
498
|
-
setIsDriverModalVisible(false);
|
|
499
|
-
}}>
|
|
500
|
-
<DriverItem>
|
|
501
|
-
<OText
|
|
502
|
-
color={!item.available && theme.colors.grey}>
|
|
503
|
-
{item.label}
|
|
504
|
-
{!item.available &&
|
|
505
|
-
` (${t('NOT_AVAILABLE', 'Not available')})`}
|
|
506
|
-
{item.value === order?.driver?.id &&
|
|
507
|
-
` (${t('SELECTED', 'Selected')})`}
|
|
508
|
-
</OText>
|
|
509
|
-
</DriverItem>
|
|
510
|
-
</TouchableOpacity>
|
|
511
|
-
),
|
|
512
|
-
}}
|
|
513
|
-
/>
|
|
514
|
-
</View>
|
|
515
|
-
</AssignDriver>
|
|
516
|
-
)}
|
|
517
|
-
|
|
518
|
-
{order?.status === 7 && (
|
|
519
|
-
<Pickup>
|
|
520
|
-
<OButton
|
|
521
|
-
style={styles.btnPickUp}
|
|
522
|
-
textStyle={{ color: theme.colors.primary }}
|
|
523
|
-
text={t('READY_FOR_PICKUP', 'Ready for pickup')}
|
|
524
|
-
onClick={() =>
|
|
525
|
-
handleChangeOrderStatus && handleChangeOrderStatus(4)
|
|
526
|
-
}
|
|
527
|
-
imgLeftStyle={{ tintColor: theme.colors.backArrow }}
|
|
528
|
-
imgRightSrc={false}
|
|
529
|
-
isLoading={loading}
|
|
530
|
-
/>
|
|
531
|
-
</Pickup>
|
|
532
|
-
)}
|
|
533
|
-
|
|
534
|
-
{order?.status === 4 && ![1].includes(order?.delivery_type) && (
|
|
535
|
-
<Pickup>
|
|
536
|
-
<OButton
|
|
537
|
-
style={{
|
|
538
|
-
...styles.btnPickUp,
|
|
539
|
-
backgroundColor: theme.colors.green,
|
|
540
|
-
}}
|
|
541
|
-
textStyle={{ color: theme.colors.white }}
|
|
542
|
-
text={t(
|
|
543
|
-
'PICKUP_COMPLETED_BY_CUSTOMER',
|
|
544
|
-
'Pickup completed by customer',
|
|
545
|
-
)}
|
|
546
|
-
onClick={() =>
|
|
547
|
-
handleChangeOrderStatus && handleChangeOrderStatus(15)
|
|
548
|
-
}
|
|
549
|
-
imgLeftStyle={{ tintColor: theme.colors.backArrow }}
|
|
550
|
-
imgRightSrc={false}
|
|
551
|
-
isLoading={loading}
|
|
552
|
-
/>
|
|
553
|
-
</Pickup>
|
|
554
|
-
)}
|
|
555
|
-
|
|
556
|
-
{order?.status === 4 && ![1].includes(order?.delivery_type) && (
|
|
557
|
-
<Pickup>
|
|
558
|
-
<OButton
|
|
559
|
-
style={{
|
|
560
|
-
...styles.btnPickUp,
|
|
561
|
-
backgroundColor: theme.colors.red,
|
|
562
|
-
}}
|
|
563
|
-
textStyle={{ color: theme.colors.white }}
|
|
564
|
-
text={t(
|
|
565
|
-
'ORDER_NOT_PICKEDUP_BY_CUSTOMER',
|
|
566
|
-
'Order not picked up by customer',
|
|
567
|
-
)}
|
|
568
|
-
onClick={() =>
|
|
569
|
-
handleChangeOrderStatus && handleChangeOrderStatus(17)
|
|
570
|
-
}
|
|
571
|
-
imgLeftStyle={{ tintColor: theme.colors.backArrow }}
|
|
572
|
-
imgRightSrc={false}
|
|
573
|
-
isLoading={loading}
|
|
574
|
-
/>
|
|
575
|
-
</Pickup>
|
|
576
|
-
)}
|
|
577
|
-
|
|
578
|
-
<OModal
|
|
579
|
-
open={openModalForBusiness}
|
|
580
|
-
order={order}
|
|
581
|
-
title={`${t('INVOICE_ORDER_NO', 'Order No.')} ${order?.id}`}
|
|
582
|
-
entireModal
|
|
583
|
-
onClose={() => handleCloseModal()}>
|
|
584
|
-
<Chat
|
|
585
|
-
type={
|
|
586
|
-
openModalForBusiness ? USER_TYPE.BUSINESS : USER_TYPE.DRIVER
|
|
587
|
-
}
|
|
588
|
-
orderId={order?.id}
|
|
589
|
-
messages={messages}
|
|
590
|
-
order={order}
|
|
591
|
-
setMessages={setMessages}
|
|
592
|
-
/>
|
|
593
|
-
</OModal>
|
|
594
|
-
|
|
595
|
-
<OModal
|
|
596
|
-
open={openModalForAccept}
|
|
597
|
-
onClose={() => setOpenModalForAccept(false)}
|
|
598
|
-
entireModal
|
|
599
|
-
customClose>
|
|
600
|
-
<AcceptOrRejectOrder
|
|
601
|
-
handleUpdateOrder={handleChangeOrderStatus}
|
|
602
|
-
closeModal={setOpenModalForAccept}
|
|
603
|
-
customerCellphone={order?.customer?.cellphone}
|
|
604
|
-
loading={loading}
|
|
605
|
-
action={actionOrder}
|
|
606
|
-
orderId={order?.id}
|
|
607
|
-
notShowCustomerPhone={false}
|
|
608
|
-
actions={actions}
|
|
609
|
-
titleAccept={titleAccept}
|
|
610
|
-
titleReject={titleReject}
|
|
611
|
-
appTitle={appTitle}
|
|
612
|
-
/>
|
|
613
|
-
</OModal>
|
|
614
|
-
|
|
615
|
-
<OModal
|
|
616
|
-
open={openModalForMapView}
|
|
617
|
-
onClose={() => handleOpenMapView()}
|
|
618
|
-
entireModal
|
|
619
|
-
customClose>
|
|
620
|
-
<GoogleMap
|
|
621
|
-
location={order?.customer?.location}
|
|
622
|
-
locations={locationsToSend}
|
|
623
|
-
driverLocation={driverLocation}
|
|
624
|
-
navigation={navigation}
|
|
625
|
-
handleViewActionOrder={handleViewActionOrder}
|
|
626
|
-
handleOpenMapView={handleOpenMapView}
|
|
627
|
-
readOnly
|
|
628
|
-
showAcceptOrReject={
|
|
629
|
-
showFloatButtonsAcceptOrReject[order?.status]
|
|
630
|
-
}
|
|
631
|
-
/>
|
|
632
|
-
</OModal>
|
|
633
|
-
</>
|
|
634
|
-
<View style={{ height: 30 }} />
|
|
635
|
-
</OrderDetailsContainer>
|
|
636
|
-
|
|
637
|
-
{order &&
|
|
638
|
-
Object.keys(order).length > 0 &&
|
|
639
|
-
getOrderStatus(order?.status, t)?.value ===
|
|
640
|
-
t('PENDING', 'Pending') && (
|
|
641
|
-
<FloatingButton
|
|
642
|
-
btnText={t('REJECT', 'Reject')}
|
|
643
|
-
isSecondaryBtn={false}
|
|
644
|
-
secondButtonClick={() => handleViewActionOrder('accept')}
|
|
645
|
-
firstButtonClick={() => handleViewActionOrder('reject')}
|
|
646
|
-
secondBtnText={t('ACCEPT', 'Accept')}
|
|
647
|
-
secondButton={true}
|
|
648
|
-
firstColorCustom={theme.colors.red}
|
|
649
|
-
secondColorCustom={theme.colors.green}
|
|
650
|
-
widthButton={'45%'}
|
|
651
|
-
/>
|
|
652
|
-
)}
|
|
653
|
-
|
|
654
|
-
{order &&
|
|
655
|
-
Object.keys(order).length > 0 &&
|
|
656
|
-
getOrderStatus(order?.status, t)?.value !==
|
|
657
|
-
t('PENDING', 'Pending') && (
|
|
658
|
-
<FloatingButton
|
|
659
|
-
btnText={t('COPY', 'Copy')}
|
|
660
|
-
isSecondaryBtn={false}
|
|
661
|
-
colorTxt1={theme.colors.primary}
|
|
662
|
-
secondButtonClick={handleViewSummaryOrder}
|
|
663
|
-
firstButtonClick={handleCopyClipboard}
|
|
664
|
-
secondBtnText={t('PRINT', 'Print')}
|
|
665
|
-
secondButton={true}
|
|
666
|
-
firstColorCustom="transparent"
|
|
667
|
-
secondColorCustom={theme.colors.primary}
|
|
668
|
-
widthButton={'45%'}
|
|
669
|
-
/>
|
|
670
|
-
)}
|
|
671
|
-
</View>
|
|
672
|
-
)}
|
|
673
|
-
</>
|
|
674
|
-
);
|
|
675
|
-
};
|
|
676
|
-
|
|
677
|
-
export const OrderDetailsBusiness = (props: OrderDetailsParams) => {
|
|
678
|
-
const orderDetailsProps = {
|
|
679
|
-
...props,
|
|
680
|
-
UIComponent: OrderDetailsUI,
|
|
681
|
-
};
|
|
682
|
-
return <OrderDetailsController {...orderDetailsProps} />;
|
|
683
|
-
};
|