Skip to content

Commit

Permalink
Revert "Implemented: toast for background process on pack action on i…
Browse files Browse the repository at this point in the history
…n-progress page (#194)"

This reverts commit adcda3f.
  • Loading branch information
k2maan committed Jul 25, 2023
1 parent adcda3f commit b8b10c0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 42 deletions.
30 changes: 8 additions & 22 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,14 @@ const hasError = (response: any) => {
return typeof response.data != "object" || !!response.data._ERROR_MESSAGE_ || !!response.data._ERROR_MESSAGE_LIST_ || !!response.data.error;
}

const showToast = async (message: string, canDismiss?: boolean, manualDismiss?: boolean, position?: string) => {
const config = {
message,
position: position ? position : 'bottom',
} as any

if (canDismiss) {
config.buttons = [
{
text: 'Dismiss',
role: 'cancel',
},
]
}

if (!manualDismiss) {
config.duration = 3000
}

const toast = await toastController.create(config)
// present toast if manual dismiss is not needed
return !manualDismiss ? toast.present() : toast
const showToast = async (message: string) => {
const toast = await toastController
.create({
message,
duration: 3000,
position: 'bottom'
})
return toast.present();
}

const handleDateTimeInput = (dateTimeValue: any) => {
Expand Down
32 changes: 12 additions & 20 deletions src/views/InProgress.vue
Original file line number Diff line number Diff line change
Expand Up @@ -317,30 +317,20 @@ export default defineComponent({
'orderId': order.orderId
}
emitter.emit('presentLoader');
try {
emitter.emit('presentLoader');
const resp = await OrderService.packOrder(params);
if (hasError(resp)) {
if (resp.status === 200 && !hasError(resp)) {
showToast(translate('Order packed successfully'));
} else {
throw resp.data
}
emitter.emit('dismissLoader');
if (data.length) {
// additional parameters for dismiss button and manual dismiss ability
const toast: any = await showToast(translate('Order packed successfully. Document generation in process'), true, true)
toast.present()
if (data.includes('printPackingSlip') && data.includes('printShippingLabel')) {
await OrderService.printShippingLabelAndPackingSlip(order.shipmentIds)
} else if(data.includes('printPackingSlip')) {
await OrderService.printPackingSlip(order.shipmentIds)
} else if(data.includes('printShippingLabel')) {
await OrderService.printShippingLabel(order.shipmentIds)
}
toast.dismiss()
} else {
showToast(translate('Order packed successfully'));
if (data.includes('printPackingSlip') && data.includes('printShippingLabel')) {
await OrderService.printShippingLabelAndPackingSlip(order.shipmentIds)
} else if(data.includes('printPackingSlip')) {
await OrderService.printPackingSlip(order.shipmentIds)
} else if(data.includes('printShippingLabel')) {
await OrderService.printShippingLabel(order.shipmentIds)
}
// TODO: handle the case of fetching in progress orders after packing an order
// when packing an order the API runs too fast and the solr index does not update resulting in having the current packed order in the inProgress section
Expand All @@ -349,6 +339,8 @@ export default defineComponent({
showToast(translate('Failed to pack order'))
logger.error('Failed to pack order', err)
}
emitter.emit('dismissLoader');
}
}]
});
Expand Down

0 comments on commit b8b10c0

Please sign in to comment.