diff --git a/src/components/GenerateTrackingCodeModal.vue b/src/components/GenerateTrackingCodeModal.vue index fbfe481d..de9a5c46 100644 --- a/src/components/GenerateTrackingCodeModal.vue +++ b/src/components/GenerateTrackingCodeModal.vue @@ -209,7 +209,10 @@ export default defineComponent({ // Getting all the shipmentIds from shipmentPackages for which label is missing const shipmentIds = order.shipmentPackages ?.filter((shipmentPackage: any) => !shipmentPackage.trackingCode) - .map((shipmentPackage: any) => shipmentPackage.shipmentId); + .reduce((uniqueIds: any[], shipmentPackage: any) => { + if(!uniqueIds.includes(shipmentPackage.shipmentId)) uniqueIds.push(shipmentPackage.shipmentId); + return uniqueIds; + }, []); if(!shipmentIds?.length) { showToast(translate("Failed to generate shipping label")) diff --git a/src/components/OrderLookupLabelActionsPopover.vue b/src/components/OrderLookupLabelActionsPopover.vue index 6f28e8f2..11e69585 100644 --- a/src/components/OrderLookupLabelActionsPopover.vue +++ b/src/components/OrderLookupLabelActionsPopover.vue @@ -51,7 +51,9 @@ export default defineComponent({ const shippingLabelPdfUrls = [] as any; shipmentPackages.map((shipmentPackage: any) => { - shipmentIds.push(shipmentPackage.shipmentId) + if(!shipmentIds.includes(shipmentPackage.shipmentId)) { + shipmentIds.push(shipmentPackage.shipmentId) + } shipmentPackage.labelImageUrl && shippingLabelPdfUrls.push(shipmentPackage.labelImageUrl) }) diff --git a/src/components/ShippingLabelActionPopover.vue b/src/components/ShippingLabelActionPopover.vue index 2f32a7fa..bff9cff7 100644 --- a/src/components/ShippingLabelActionPopover.vue +++ b/src/components/ShippingLabelActionPopover.vue @@ -61,16 +61,20 @@ popoverController.dismiss() }, async voidShippingLabel(order: any) { + const shipmentIds = [] as any; let resp = {} as any; try { for (const shipmentPackage of order.shipmentPackages) { - resp = await OrderService.voidShipmentLabel({ - "shipmentId": shipmentPackage.shipmentId, - "shipmentRouteSegmentId": shipmentPackage.shipmentRouteSegmentId - }) - - if(hasError(resp)) { - throw resp.data; + if(!shipmentIds.includes(shipmentPackage.shipmentId)) { + resp = await OrderService.voidShipmentLabel({ + "shipmentId": shipmentPackage.shipmentId, + "shipmentRouteSegmentId": shipmentPackage.shipmentRouteSegmentId + }) + + if(hasError(resp)) { + throw resp.data; + } + shipmentIds.push(shipmentPackage.shipmentId); } } showToast(translate("Shipping label voided successfully.")) diff --git a/src/views/Completed.vue b/src/views/Completed.vue index ce4d28e3..49fee897 100644 --- a/src/views/Completed.vue +++ b/src/views/Completed.vue @@ -635,7 +635,10 @@ export default defineComponent({ // Getting all the shipmentIds from shipmentPackages for which label is missing const shipmentIds = order.shipmentPackages ?.filter((shipmentPackage: any) => !shipmentPackage.trackingCode) - .map((shipmentPackage: any) => shipmentPackage.shipmentId); + .reduce((uniqueIds: any[], shipmentPackage: any) => { + if(!uniqueIds.includes(shipmentPackage.shipmentId)) uniqueIds.push(shipmentPackage.shipmentId); + return uniqueIds; + }, []); // Don't make any api call when we does not have any shipmentIds for order if(!shipmentIds?.length) { diff --git a/src/views/OrderDetail.vue b/src/views/OrderDetail.vue index 46ea3ac4..9fc518bd 100644 --- a/src/views/OrderDetail.vue +++ b/src/views/OrderDetail.vue @@ -1041,7 +1041,10 @@ export default defineComponent({ // Getting all the shipmentIds from shipmentPackages for which label is missing const shipmentIds = order.shipmentPackages ?.filter((shipmentPackage: any) => !shipmentPackage.trackingCode) - .map((shipmentPackage: any) => shipmentPackage.shipmentId); + .reduce((uniqueIds: any[], shipmentPackage: any) => { + if(!uniqueIds.includes(shipmentPackage.shipmentId)) uniqueIds.push(shipmentPackage.shipmentId); + return uniqueIds; + }, []); if(!shipmentIds?.length) { showToast(translate("Failed to generate shipping label")) @@ -1075,7 +1078,10 @@ export default defineComponent({ return popover.present(); }, async printShippingLabel(order: any) { - const shipmentIds = order.shipmentIds ? order.shipmentIds : order.shipmentPackages?.map((shipmentPackage: any) => shipmentPackage.shipmentId); + const shipmentIds = order.shipmentIds ? order.shipmentIds : order.shipmentPackages?.reduce((uniqueIds: any[], shipmentPackage: any) => { + if(!uniqueIds.includes(shipmentPackage.shipmentId)) uniqueIds.push(shipmentPackage.shipmentId); + return uniqueIds; + }, []); const shippingLabelPdfUrls = order.shipmentPackages ?.filter((shipmentPackage: any) => shipmentPackage.labelPdfUrl) .map((shipmentPackage: any) => shipmentPackage.labelPdfUrl);