Skip to content

Commit

Permalink
Fixed: Fetched shipping gateway error when retry shipping label faile…
Browse files Browse the repository at this point in the history
…d. Also reset the gateway error message on change of carrier/shipping method. (#725)
  • Loading branch information
ravilodhi committed Sep 6, 2024
1 parent f21dd8b commit 73f1181
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 9 deletions.
21 changes: 18 additions & 3 deletions src/components/GenerateTrackingCodeModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export default defineComponent({
isGeneratingShippingLabel: false
}
},
props: ["order", "updateCarrierShipmentDetails"],
props: ["order", "updateCarrierShipmentDetails", "shipmentLabelErrorMessages", "fetchShipmentLabelError"],
async mounted() {
this.isTrackingRequired = this.isTrackingRequiredForAnyShipmentPackage()
if(this.facilityCarriers) {
Expand Down Expand Up @@ -208,6 +208,7 @@ export default defineComponent({
throw resp.data;
}
} catch(error: any) {
this.fetchShipmentLabelError && this.fetchShipmentLabelError()
logger.error(error);
showToast(translate("Failed to generate shipping label"))
return false;
Expand Down Expand Up @@ -248,8 +249,22 @@ export default defineComponent({
"carrierPartyId": carrierPartyId,
"shipmentMethodTypeId" : shipmentMethodTypeId ? shipmentMethodTypeId : "",
}) as any;
if(hasError(resp)) {
throw resp.data;
if(!hasError(resp)) {
//on changing the shipment carrier/method, voiding the gatewayMessage and gatewayStatus
if (this.shipmentLabelErrorMessages) {
resp = await OrderService.updateShipmentPackageRouteSeg({
"shipmentId": shipmentPackage.shipmentId,
"shipmentRouteSegmentId": shipmentPackage.shipmentRouteSegmentId,
"shipmentPackageSeqId": shipmentPackage.shipmentPackageSeqId,
"gatewayMessage": "",
"gatewayStatus": ""
}) as any;
if (hasError(resp)) {
throw resp.data
}
}
} else {
throw resp.data
}
}
} else {
Expand Down
33 changes: 27 additions & 6 deletions src/views/OrderDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -532,13 +532,16 @@ export default defineComponent({
}
// Fetching shipment label errors
const shipmentIds = this.order?.shipmentIds?.length > 0 ? this.order?.shipmentIds : this.order.shipments?.map((shipment: any) => shipment.shipmentId);
if (shipmentIds && shipmentIds.length > 0) {
const labelErrors = await OrderService.fetchShipmentLabelError(shipmentIds);
this.shipmentLabelErrorMessages = labelErrors.join(', ');
}
await this.fetchShipmentLabelError()
},
methods: {
async fetchShipmentLabelError() {
const shipmentIds = this.order?.shipmentIds?.length > 0 ? this.order?.shipmentIds : this.order.shipments?.map((shipment: any) => shipment.shipmentId);
if (shipmentIds && shipmentIds.length > 0) {
const labelErrors = await OrderService.fetchShipmentLabelError(shipmentIds);
this.shipmentLabelErrorMessages = labelErrors.join(', ');
}
},
getCarrierName(carrierPartyId: string) {
const selectedCarrier = this.facilityCarriers.find((carrier: any) => carrier.partyId === carrierPartyId)
return selectedCarrier && selectedCarrier.groupName ? selectedCarrier.groupName : carrierPartyId
Expand Down Expand Up @@ -584,6 +587,22 @@ export default defineComponent({
"shipmentMethodTypeId": shipmentMethodTypeId ? shipmentMethodTypeId : ""
}) as any;
if (!hasError(resp)) {
//on changing the shipment carrier/method, voiding the gatewayMessage and gatewayStatus
if (this.shipmentLabelErrorMessages) {
resp = await OrderService.updateShipmentPackageRouteSeg({
"shipmentId": shipmentPackage.shipmentId,
"shipmentRouteSegmentId": shipmentPackage.shipmentRouteSegmentId,
"shipmentPackageSeqId": shipmentPackage.shipmentPackageSeqId,
"gatewayMessage": "",
"gatewayStatus": ""
}) as any;
if (!hasError(resp)) {
this.shipmentLabelErrorMessages = ""
} else {
throw resp.data
}
}
this.shipmentMethodTypeId = shipmentMethodTypeId
showToast(translate("Shipment method detail updated successfully."))
//fetching updated shipment packages
Expand All @@ -609,6 +628,7 @@ export default defineComponent({
updateCarrierShipmentDetails(carrierPartyId: string, shipmentMethodTypeId: string) {
this.carrierPartyId = carrierPartyId
this.shipmentMethodTypeId = shipmentMethodTypeId
this.shipmentLabelErrorMessages = ""
},
async fetchKitComponent(orderItem: any, isOtherShipment = false ) {
await this.store.dispatch('product/fetchProductComponents', { productId: orderItem.productId })
Expand Down Expand Up @@ -1009,6 +1029,7 @@ export default defineComponent({
order.isGeneratingShippingLabel = false
} else {
showToast(translate("Failed to generate shipping label"))
this.fetchShipmentLabelError()
}
},
async shippingPopover(ev: Event) {
Expand Down Expand Up @@ -1503,7 +1524,7 @@ export default defineComponent({
async generateTrackingCodeForPacking(order: any) {
const modal = await modalController.create({
component: GenerateTrackingCodeModal,
componentProps: { order, updateCarrierShipmentDetails: this.updateCarrierShipmentDetails }
componentProps: { order, updateCarrierShipmentDetails: this.updateCarrierShipmentDetails, shipmentLabelErrorMessages: this.shipmentLabelErrorMessages, fetchShipmentLabelError: this.fetchShipmentLabelError }
})
modal.onDidDismiss().then((result: any) => {
Expand Down

0 comments on commit 73f1181

Please sign in to comment.