ordering-ui-react-native 0.23.83 → 0.23.84
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
|
@@ -8,7 +8,8 @@ interface Props {
|
|
|
8
8
|
title: string,
|
|
9
9
|
content: Array<string>,
|
|
10
10
|
onClose: () => void,
|
|
11
|
-
onAccept: () => void
|
|
11
|
+
onAccept: () => void,
|
|
12
|
+
onCancel: () => void
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
const Alert = (props: Props) => {
|
|
@@ -38,6 +39,7 @@ const Alert = (props: Props) => {
|
|
|
38
39
|
confirmText={t('ACCEPT', 'Accept')}
|
|
39
40
|
confirmButtonColor={theme.colors.primary}
|
|
40
41
|
onCancelPressed={() => onClose()}
|
|
42
|
+
showCancelButton={!!props.onCancel}
|
|
41
43
|
onConfirmPressed={() => onAccept()}
|
|
42
44
|
/>
|
|
43
45
|
)
|
|
@@ -3,8 +3,7 @@ import {
|
|
|
3
3
|
StyleSheet,
|
|
4
4
|
View,
|
|
5
5
|
TouchableOpacity,
|
|
6
|
-
ActivityIndicator
|
|
7
|
-
Alert,
|
|
6
|
+
ActivityIndicator
|
|
8
7
|
} from 'react-native';
|
|
9
8
|
import Clipboard from '@react-native-clipboard/clipboard';
|
|
10
9
|
import { StarPRNT } from 'react-native-star-prnt';
|
|
@@ -39,6 +38,7 @@ import { OrderHeaderComponent } from './OrderHeaderComponent';
|
|
|
39
38
|
import { OrderContentComponent } from './OrderContentComponent';
|
|
40
39
|
import { _retrieveStoreData } from '../../providers/StoreUtil'
|
|
41
40
|
import { usePrinterCommands } from './usePrinterCommands'
|
|
41
|
+
import Alert from '../../../../../src/providers/AlertProvider'
|
|
42
42
|
|
|
43
43
|
export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
44
44
|
const {
|
|
@@ -78,6 +78,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
78
78
|
const [isDriverModalVisible, setIsDriverModalVisible] = useState(false);
|
|
79
79
|
const [printerSettings, setPrinterSettings] = useState<any>('')
|
|
80
80
|
const [autoPrintEnabled, setAutoPrintEnabled] = useState<boolean>(false)
|
|
81
|
+
const [alertState, setAlertState] = useState<any>({ open: false, title: '', content: [] })
|
|
81
82
|
|
|
82
83
|
const orderToComplete = [4, 20, 21]
|
|
83
84
|
const orderToReady = [7, 14]
|
|
@@ -139,6 +140,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
139
140
|
if (order?.status === 7 && autoPrintEnabled && printerSettings) {
|
|
140
141
|
handleViewSummaryOrder()
|
|
141
142
|
}
|
|
143
|
+
return order
|
|
142
144
|
}
|
|
143
145
|
}
|
|
144
146
|
|
|
@@ -267,7 +269,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
267
269
|
)}:\n${productsInString}\n`;
|
|
268
270
|
|
|
269
271
|
const subtotal = `${t('SUBTOTAL', 'Subtotal')}: ${parsePrice(
|
|
270
|
-
order?.subtotal,
|
|
272
|
+
order?.subtotal,
|
|
271
273
|
{ currency: getCurrenySymbol(order?.currency) }
|
|
272
274
|
)}\n`;
|
|
273
275
|
|
|
@@ -315,10 +317,42 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
315
317
|
setUnreadAlert({ ...unreadAlert, business: false });
|
|
316
318
|
};
|
|
317
319
|
|
|
318
|
-
const handleViewActionOrder = (action: string) => {
|
|
320
|
+
const handleViewActionOrder = (action: string, options?: any) => {
|
|
319
321
|
if (openModalForMapView) {
|
|
320
322
|
setOpenModalForMapView(false);
|
|
321
323
|
}
|
|
324
|
+
if (options?.alert) {
|
|
325
|
+
let bodyToSend: any = {};
|
|
326
|
+
const orderStatus: any = {
|
|
327
|
+
acceptByBusiness: {
|
|
328
|
+
status: 7,
|
|
329
|
+
},
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
if (actions && action === 'accept') {
|
|
333
|
+
bodyToSend = orderStatus[actions.accept];
|
|
334
|
+
}
|
|
335
|
+
bodyToSend.id = order?.id;
|
|
336
|
+
setAlertState({
|
|
337
|
+
open: true,
|
|
338
|
+
content: options?.content,
|
|
339
|
+
title: t('ORDER_STATUS', 'Order status'),
|
|
340
|
+
onAccept: async () => {
|
|
341
|
+
setAlertState({
|
|
342
|
+
open: false,
|
|
343
|
+
content: []
|
|
344
|
+
})
|
|
345
|
+
const order = await handleChangeOrderStatus(bodyToSend?.status, bodyToSend)
|
|
346
|
+
if (order?.id) {
|
|
347
|
+
setActionOrder(action);
|
|
348
|
+
setOpenModalForAccept(true);
|
|
349
|
+
} else {
|
|
350
|
+
showToast(ToastType.Error, t('FAILED_TO_UPDATE_ORDER', 'Failed to update order'), 5000)
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
})
|
|
354
|
+
return
|
|
355
|
+
}
|
|
322
356
|
setActionOrder(action);
|
|
323
357
|
setOpenModalForAccept(true);
|
|
324
358
|
};
|
|
@@ -366,6 +400,14 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
366
400
|
navigation?.canGoBack() && navigation.goBack();
|
|
367
401
|
};
|
|
368
402
|
|
|
403
|
+
const closeAlert = () => {
|
|
404
|
+
setAlertState({
|
|
405
|
+
open: false,
|
|
406
|
+
title: '',
|
|
407
|
+
content: []
|
|
408
|
+
})
|
|
409
|
+
}
|
|
410
|
+
|
|
369
411
|
useEffect(() => {
|
|
370
412
|
if (messagesReadList?.length) {
|
|
371
413
|
openModalForBusiness
|
|
@@ -408,7 +450,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
408
450
|
];
|
|
409
451
|
|
|
410
452
|
useEffect(() => {
|
|
411
|
-
if (openModalForAccept) {
|
|
453
|
+
if (openModalForAccept && !loading) {
|
|
412
454
|
setOpenModalForAccept(false);
|
|
413
455
|
}
|
|
414
456
|
|
|
@@ -656,7 +698,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
656
698
|
<FloatingButton
|
|
657
699
|
btnText={t('REJECT', 'Reject')}
|
|
658
700
|
isSecondaryBtn={false}
|
|
659
|
-
secondButtonClick={() => handleViewActionOrder('accept')}
|
|
701
|
+
secondButtonClick={() => handleViewActionOrder('accept', { alert: true, content: t('DO_YOU_WANT_ACCEPT_ORDER', 'Do you want to accept the order?') })}
|
|
660
702
|
firstButtonClick={() => handleViewActionOrder('reject')}
|
|
661
703
|
secondBtnText={t('ACCEPT', 'Accept')}
|
|
662
704
|
secondButton={true}
|
|
@@ -698,6 +740,14 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
698
740
|
)}
|
|
699
741
|
</View>
|
|
700
742
|
)}
|
|
743
|
+
<Alert
|
|
744
|
+
open={alertState.open}
|
|
745
|
+
content={alertState.content}
|
|
746
|
+
title={alertState.title || ''}
|
|
747
|
+
onAccept={alertState.onAccept}
|
|
748
|
+
onClose={closeAlert}
|
|
749
|
+
onCancel={closeAlert}
|
|
750
|
+
/>
|
|
701
751
|
</>
|
|
702
752
|
);
|
|
703
753
|
};
|