From 3eabe11464591026448b77508b64cc730007108b Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Tue, 28 Jan 2025 11:42:45 +0530 Subject: [PATCH] Improved: added optional check while fetching additional info of inprogress orders (#912) --- src/store/modules/order/actions.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/store/modules/order/actions.ts b/src/store/modules/order/actions.ts index 84da2fbf..710abc89 100644 --- a/src/store/modules/order/actions.ts +++ b/src/store/modules/order/actions.ts @@ -90,13 +90,13 @@ const actions: ActionTree = { item.shipmentItemSeqId = shipment.shipmentItemSeqId } - item.selectedBox = shipmentPackageContents[`${item.shipmentId}`].find((shipmentPackageContent: any) => shipmentPackageContent.shipmentItemSeqId === item.shipmentItemSeqId)?.packageName + item.selectedBox = shipmentPackageContents[`${item.shipmentId}`]?.find((shipmentPackageContent: any) => shipmentPackageContent.shipmentItemSeqId === item.shipmentItemSeqId)?.packageName }) const orderItem = order.items[0]; - const carrierPartyIds = [...new Set(orderShipmentIds.map((id: any) => carrierPartyIdsByShipment[id]?.map((carrierParty: any) => carrierParty.carrierPartyId)).flat())]; + const carrierPartyIds = [...new Set(orderShipmentIds?.map((id: any) => carrierPartyIdsByShipment[id]?.map((carrierParty: any) => carrierParty.carrierPartyId)).flat())]; - const shipmentBoxTypeByCarrierParty = carrierPartyIds.reduce((shipmentBoxType: any, carrierPartyId: any) => { + const shipmentBoxTypeByCarrierParty = carrierPartyIds?.reduce((shipmentBoxType: any, carrierPartyId: any) => { if (shipmentBoxType[carrierPartyId]) { shipmentBoxType[carrierPartyId].push(carrierShipmentBoxType[carrierPartyId]) } else { @@ -106,15 +106,15 @@ const actions: ActionTree = { return shipmentBoxType }, {}); - const shipmentPackages = shipmentPackagesByOrderAndPicklistBin[`${orderItem.orderId}_${orderItem.picklistBinId}`].map((shipmentPackage: any) => { + const shipmentPackages = shipmentPackagesByOrderAndPicklistBin[`${orderItem.orderId}_${orderItem.picklistBinId}`]?.map((shipmentPackage: any) => { return { ...shipmentPackage, shipmentBoxTypes: shipmentBoxTypeByCarrierParty[shipmentPackage.carrierPartyId] ? shipmentBoxTypeByCarrierParty[shipmentPackage.carrierPartyId] : [] } }); - const currentShipmentPackages = shipmentPackagesByOrderAndPicklistBin[`${orderItem.orderId}_${orderItem.picklistBinId}`].reduce((currentShipmentPackages: any, shipment: any) => { - currentShipmentPackages.push(...orderShipmentPackages.filter((shipmentPackage: any) => shipmentPackage.shipmentId === shipment.shipmentId)); + const currentShipmentPackages = shipmentPackagesByOrderAndPicklistBin[`${orderItem.orderId}_${orderItem.picklistBinId}`]?.reduce((currentShipmentPackages: any, shipment: any) => { + currentShipmentPackages.push(...orderShipmentPackages?.filter((shipmentPackage: any) => shipmentPackage.shipmentId === shipment.shipmentId)); return currentShipmentPackages; }, []);