ordering-ui-react-native 0.17.52-release → 0.17.53-release
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/themes/business/src/components/OrderDetails/Delivery.tsx +160 -1
- package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +20 -16
- package/themes/business/src/components/ReviewCustomer/index.tsx +1 -1
- package/themes/original/src/components/BusinessProductsList/index.tsx +2 -1
package/package.json
CHANGED
|
@@ -4,6 +4,7 @@ import { StyleSheet, View } from 'react-native';
|
|
|
4
4
|
|
|
5
5
|
// Thirds
|
|
6
6
|
import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
|
|
7
|
+
import Clipboard from '@react-native-clipboard/clipboard';
|
|
7
8
|
|
|
8
9
|
//OrderingComponent
|
|
9
10
|
import {
|
|
@@ -28,7 +29,7 @@ import { OrderDetailsParams } from '../../types';
|
|
|
28
29
|
import { USER_TYPE } from '../../config/constants';
|
|
29
30
|
import { useTheme } from 'styled-components/native';
|
|
30
31
|
import { NotFoundSource } from '../NotFoundSource';
|
|
31
|
-
import { getOrderStatus } from '../../utils';
|
|
32
|
+
import { verifyDecimals, getProductPrice, getOrderStatus } from '../../utils';
|
|
32
33
|
import { OrderHeaderComponent } from './OrderHeaderComponent';
|
|
33
34
|
import { OrderContentComponent } from './OrderContentComponent';
|
|
34
35
|
//Styles
|
|
@@ -142,6 +143,163 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
142
143
|
}
|
|
143
144
|
};
|
|
144
145
|
|
|
146
|
+
const getFormattedSubOptionName = ({ quantity, name, position, price }: any) => {
|
|
147
|
+
if (name !== 'No') {
|
|
148
|
+
const pos = position && position !== 'whole' ? `(${t(position.toUpperCase(), position)})` : '';
|
|
149
|
+
return pos
|
|
150
|
+
? `${quantity} x ${name} ${pos} +${parsePrice(price)}\n`
|
|
151
|
+
: `${quantity} x ${name} +${parsePrice(price)}\n`;
|
|
152
|
+
} else {
|
|
153
|
+
return 'No\n';
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
const handleCopyClipboard = () => {
|
|
158
|
+
const businessName = !!order?.business?.name
|
|
159
|
+
? `${order?.business?.name} \n`
|
|
160
|
+
: '';
|
|
161
|
+
|
|
162
|
+
const businessEmail = !!order?.business?.email
|
|
163
|
+
? `${order?.business?.email} \n`
|
|
164
|
+
: '';
|
|
165
|
+
|
|
166
|
+
const businessCellphone = !!order?.business?.cellphone
|
|
167
|
+
? `${order?.business?.cellphone} \n`
|
|
168
|
+
: '';
|
|
169
|
+
|
|
170
|
+
const businessPhone = !!order?.business?.phone
|
|
171
|
+
? `${order?.business?.phone} \n`
|
|
172
|
+
: '';
|
|
173
|
+
|
|
174
|
+
const businessAddress = !!order?.business?.address
|
|
175
|
+
? `${order?.business?.address} \n`
|
|
176
|
+
: '';
|
|
177
|
+
|
|
178
|
+
const businessSpecialAddress = !!order?.business?.address_notes
|
|
179
|
+
? `${order?.business?.address_notes} \n \n`
|
|
180
|
+
: '';
|
|
181
|
+
|
|
182
|
+
const customerName = !!order?.customer?.name
|
|
183
|
+
? `${order?.customer?.name} ${order?.customer?.middle_name || ''} ${order?.customer?.lastname || ''
|
|
184
|
+
} ${order?.customer?.second_lastname || ''} \n`
|
|
185
|
+
: '';
|
|
186
|
+
|
|
187
|
+
const customerEmail = !!order?.customer.email
|
|
188
|
+
? `${order?.customer.email} \n`
|
|
189
|
+
: '';
|
|
190
|
+
|
|
191
|
+
const customerCellPhone = !!order?.customer?.cellphone
|
|
192
|
+
? `${order?.customer?.cellphone} \n`
|
|
193
|
+
: '';
|
|
194
|
+
|
|
195
|
+
const customerPhone = !!order?.customer?.phone
|
|
196
|
+
? `${order?.customer?.phone} \n`
|
|
197
|
+
: '';
|
|
198
|
+
|
|
199
|
+
const customerAddress = !!order?.customer?.address
|
|
200
|
+
? `${order?.customer?.address} \n`
|
|
201
|
+
: '';
|
|
202
|
+
|
|
203
|
+
const customerSpecialAddress = !!order?.customer?.address_notes
|
|
204
|
+
? `${order?.customer?.address_notes} \n`
|
|
205
|
+
: '';
|
|
206
|
+
|
|
207
|
+
const payment = order?.paymethod?.name
|
|
208
|
+
? `${order?.paymethod?.name} - ${order.delivery_type === 1
|
|
209
|
+
? t('DELIVERY', 'Delivery')
|
|
210
|
+
: order.delivery_type === 2
|
|
211
|
+
? t('PICKUP', 'Pickup')
|
|
212
|
+
: order.delivery_type === 3
|
|
213
|
+
? t('EAT_IN', 'Eat in')
|
|
214
|
+
: order.delivery_type === 4
|
|
215
|
+
? t('CURBSIDE', 'Curbside')
|
|
216
|
+
: t('DRIVER_THRU', 'Driver thru')
|
|
217
|
+
}\n`
|
|
218
|
+
: '';
|
|
219
|
+
|
|
220
|
+
const getSuboptions = (suboptions: any) => {
|
|
221
|
+
const array: any = []
|
|
222
|
+
suboptions?.length > 0 &&
|
|
223
|
+
suboptions?.map((suboption: any) => {
|
|
224
|
+
const string = `${getFormattedSubOptionName(suboption)}`
|
|
225
|
+
array.push(string)
|
|
226
|
+
})
|
|
227
|
+
|
|
228
|
+
return array.join('')
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const getOptions = (options: any, productComment: string = '') => {
|
|
232
|
+
const array: any = [];
|
|
233
|
+
|
|
234
|
+
options?.length &&
|
|
235
|
+
options?.map((option: any) => {
|
|
236
|
+
const string =
|
|
237
|
+
` ${option.name}\n ${getSuboptions(option.suboptions)}`;
|
|
238
|
+
|
|
239
|
+
array.push(string)
|
|
240
|
+
})
|
|
241
|
+
|
|
242
|
+
if (productComment) {
|
|
243
|
+
array.push(` ${t('COMMENT', 'Comment')}\n ${productComment}\n`)
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
return array.join('')
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
const productsInArray =
|
|
250
|
+
order?.products.length &&
|
|
251
|
+
order?.products.map((product: any, i: number) => {
|
|
252
|
+
const string =
|
|
253
|
+
`${product?.quantity} X ${product?.name} ${parsePrice(product.total ?? getProductPrice(product))}\n${getOptions(product.options, product.comment)}`;
|
|
254
|
+
|
|
255
|
+
return i === 0 ? ` ${string}` : string
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
const productsInString = productsInArray.join(' ');
|
|
259
|
+
const orderDetails = `${t(
|
|
260
|
+
'ORDER_DETAILS',
|
|
261
|
+
'Order Details',
|
|
262
|
+
)}:\n${productsInString}\n`;
|
|
263
|
+
|
|
264
|
+
const subtotal = `${t('SUBTOTAL', 'Subtotal')}: ${parsePrice(
|
|
265
|
+
order?.subtotal,
|
|
266
|
+
)}\n`;
|
|
267
|
+
|
|
268
|
+
const drivertip = `${t('DRIVER_TIP', 'Driver tip')} ${parsePrice(
|
|
269
|
+
order?.summary?.driver_tip || order?.totalDriverTip,
|
|
270
|
+
)}\n`;
|
|
271
|
+
|
|
272
|
+
const deliveryFee = `${t('DELIVERY_FEE', 'Delivery fee')} ${verifyDecimals(
|
|
273
|
+
order?.service_fee,
|
|
274
|
+
parseNumber,
|
|
275
|
+
)}% ${parsePrice(order?.summary?.service_fee || order?.serviceFee || 0)}\n`;
|
|
276
|
+
|
|
277
|
+
const total = `${t('TOTAL', 'Total')} ${parsePrice(
|
|
278
|
+
order?.summary?.total || order?.total,
|
|
279
|
+
)}\n`;
|
|
280
|
+
|
|
281
|
+
const orderStatus = `${t('INVOICE_ORDER_NO', 'Order No.')} ${order.id} ${t(
|
|
282
|
+
'IS',
|
|
283
|
+
'is',
|
|
284
|
+
)} ${getOrderStatus(order?.status, t)?.value}\n`;
|
|
285
|
+
|
|
286
|
+
Clipboard.setString(
|
|
287
|
+
`${orderStatus} ${payment} ${t(
|
|
288
|
+
'BUSINESS_DETAILS',
|
|
289
|
+
'Business Details',
|
|
290
|
+
)}\n ${businessName} ${businessEmail} ${businessCellphone} ${businessPhone} ${businessAddress} ${businessSpecialAddress}${t(
|
|
291
|
+
'CUSTOMER_DETAILS',
|
|
292
|
+
'Customer Details',
|
|
293
|
+
)}\n ${customerName} ${customerEmail} ${customerCellPhone} ${customerPhone} ${customerAddress} ${customerSpecialAddress}\n${orderDetails} ${subtotal} ${drivertip} ${deliveryFee} ${total}`,
|
|
294
|
+
);
|
|
295
|
+
|
|
296
|
+
showToast(
|
|
297
|
+
ToastType.Info,
|
|
298
|
+
t('COPY_TO_CLIPBOARD', 'Copy to clipboard.'),
|
|
299
|
+
1000,
|
|
300
|
+
);
|
|
301
|
+
};
|
|
302
|
+
|
|
145
303
|
const handleViewActionOrder = (action: string) => {
|
|
146
304
|
if (action === 'reject' && !isAllowedDriverRejectOrder) {
|
|
147
305
|
setAlertState({
|
|
@@ -387,6 +545,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
387
545
|
order={order}
|
|
388
546
|
handleOpenMapView={handleOpenMapView}
|
|
389
547
|
handleOpenMessagesForBusiness={handleOpenMessagesForBusiness}
|
|
548
|
+
handleCopyClipboard={handleCopyClipboard}
|
|
390
549
|
getOrderStatus={getOrderStatus}
|
|
391
550
|
handleArrowBack={handleArrowBack}
|
|
392
551
|
logisticOrderStatus={logisticOrderStatus}
|
|
@@ -140,14 +140,16 @@ export const OrderHeaderComponent = (props: OrderHeader) => {
|
|
|
140
140
|
style={styles.icons}
|
|
141
141
|
/>
|
|
142
142
|
</TouchableOpacity>
|
|
143
|
-
|
|
144
|
-
<
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
143
|
+
{!!handleViewSummaryOrder && (
|
|
144
|
+
<TouchableOpacity onPress={() => handleViewSummaryOrder?.()}>
|
|
145
|
+
<SimpleLineIcons
|
|
146
|
+
name='printer'
|
|
147
|
+
color={theme.colors.textGray}
|
|
148
|
+
size={20}
|
|
149
|
+
style={styles.icons}
|
|
150
|
+
/>
|
|
151
|
+
</TouchableOpacity>
|
|
152
|
+
)}
|
|
151
153
|
</>
|
|
152
154
|
)}
|
|
153
155
|
<OIconButton
|
|
@@ -205,14 +207,16 @@ export const OrderHeaderComponent = (props: OrderHeader) => {
|
|
|
205
207
|
style={styles.icons}
|
|
206
208
|
/>
|
|
207
209
|
</TouchableOpacity>
|
|
208
|
-
|
|
209
|
-
<
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
210
|
+
{!!handleViewSummaryOrder && (
|
|
211
|
+
<TouchableOpacity onPress={() => handleViewSummaryOrder?.()}>
|
|
212
|
+
<SimpleLineIcons
|
|
213
|
+
name='printer'
|
|
214
|
+
color={theme.colors.textGray}
|
|
215
|
+
size={20}
|
|
216
|
+
style={styles.icons}
|
|
217
|
+
/>
|
|
218
|
+
</TouchableOpacity>
|
|
219
|
+
)}
|
|
216
220
|
</>
|
|
217
221
|
)}
|
|
218
222
|
<OIconButton
|
|
@@ -161,7 +161,7 @@ const ReviewCustomerUI = (props: ReviewCustomerParams) => {
|
|
|
161
161
|
useEffect(() => {
|
|
162
162
|
if (scrollref?.current) {
|
|
163
163
|
Keyboard.addListener('keyboardDidShow', () => {
|
|
164
|
-
scrollref.current.scrollToEnd()
|
|
164
|
+
scrollref?.current && scrollref.current.scrollToEnd()
|
|
165
165
|
})
|
|
166
166
|
}
|
|
167
167
|
}, [scrollref?.current])
|
|
@@ -309,10 +309,11 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
|
|
|
309
309
|
? t('SEARCH_REDIRECT', 'Go to Businesses')
|
|
310
310
|
: t('CLEAR_FILTERS', 'Clear filters')
|
|
311
311
|
}
|
|
312
|
-
onClickButton={() =>
|
|
312
|
+
onClickButton={!businessSingleId ? () =>
|
|
313
313
|
!searchValue
|
|
314
314
|
? handleSearchRedirect && handleSearchRedirect()
|
|
315
315
|
: handleCancelSearch && handleCancelSearch()
|
|
316
|
+
: null
|
|
316
317
|
}
|
|
317
318
|
/>
|
|
318
319
|
</WrapperNotFound>
|