From 74ae56bbf5323f8ea110194dad21f34536d42128 Mon Sep 17 00:00:00 2001 From: k2maan Date: Tue, 17 Oct 2023 14:53:38 +0530 Subject: [PATCH] Improved: experience by adding toast messages if tracking is required for some or all orders (#281) --- src/locales/en.json | 2 ++ src/locales/es.json | 2 ++ src/views/Completed.vue | 16 ++++++++++++---- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/locales/en.json b/src/locales/en.json index 8e444ed1..5ceba440 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -129,6 +129,7 @@ "No capacity sets the fulfillment capacity to 0, preventing any new orders from being allocated to this facility. Use the \"Reject all orders\" option in the fulfillment pages to clear your facilities fulfillment queue. To add a fulfillment capacity to this facility, use the custom option.": "No capacity sets the fulfillment capacity to 0, preventing any new orders from being allocated to this facility. Use the \"Reject all orders\" option in the fulfillment pages to clear your facilities fulfillment queue. {space}To add a fulfillment capacity to this facility, use the custom option.", "No new file upload. Please try again": "No new file upload. Please try again", "No fulfillment capacity": "No fulfillment capacity", + "No orders are currently able to be shipped due to missing tracking codes.": "No orders are currently able to be shipped due to missing tracking codes.", "No reason": "No reason", "No results found for . Try searching Open or Completed tab instead. If you still can't find what you're looking for, try switching stores.": "No results found for { searchedQuery }. Try searching Open or Completed tab instead.{ lineBreak } If you still can't find what you're looking for, try switching stores.", "No results found for . Try searching In Progress or Open tab instead. If you still can't find what you're looking for, try switching stores.": "No results found for { searchedQuery }. Try searching In Progress or Open tab instead.{ lineBreak } If you still can't find what you're looking for, try switching stores.", @@ -160,6 +161,7 @@ "Order updated successfully": "Order updated successfully", "orders": "orders", "Out of stock": "Out of stock", + "out of cannot be shipped due to missing tracking codes.": "{remainingOrders} out of {totalOrders} cannot be shipped due to missing tracking codes.", "package": "package", "packages": "packages", "Pack": "Pack", diff --git a/src/locales/es.json b/src/locales/es.json index f1170dcf..4d4ef3bb 100644 --- a/src/locales/es.json +++ b/src/locales/es.json @@ -129,6 +129,7 @@ "No data available!": "No data available!", "No data Found.": "No data Found.", "No new file upload. Please try again": "No se cargó ningún archivo nuevo. Por favor, inténtalo nuevamente.", + "No orders are currently able to be shipped due to missing tracking codes.": "No orders are currently able to be shipped due to missing tracking codes.", "No reason": "Sin motivo", "No results found for . Try searching Open or Completed tab instead. If you still can't find what you're looking for, try switching stores.": "No results found for { searchedQuery }. Try searching Open or Completed tab instead.{ lineBreak }If you still can't find what you're looking for, try switching stores.", "No results found for . Try searching In Progress or Open tab instead. If you still can't find what you're looking for, try switching stores.": "No results found for { searchedQuery }. Try searching In Progress or Open tab instead.{ lineBreak } If you still can't find what you're looking for, try switching stores.", @@ -160,6 +161,7 @@ "Order updated successfully": "Pedido actualizado exitosamente", "orders": "pedidos", "Out of stock": "Agotado", + "out of cannot be shipped due to missing tracking codes.": "{remainingOrders} out of {totalOrders} cannot be shipped due to missing tracking codes.", "package": "paquete", "packages": "paquetes", "Pack": "Empacar", diff --git a/src/views/Completed.vue b/src/views/Completed.vue index 53e1ea0b..436c19ca 100644 --- a/src/views/Completed.vue +++ b/src/views/Completed.vue @@ -41,7 +41,7 @@
- {{ translate("Ship") }} + {{ translate("Ship") }}
@@ -331,14 +331,20 @@ export default defineComponent({ let orderList = JSON.parse(JSON.stringify(this.completedOrders.list)) // orders with tracking required and missing label must be excluded const trackingRequiredOrders = orderList.filter((order: any) => this.isTrackingRequiredForAnyShipmentPackage(order)) + let trackingRequiredAndMissingLabelOrders: any if (trackingRequiredOrders.length) { // filtering and excluding orders having missing label image with tracking required - const trackingRequiredAndMissingLabelOrders = trackingRequiredOrders.filter((order: any) => order.missingLabelImage).map((order: any) => order.orderId) + trackingRequiredAndMissingLabelOrders = trackingRequiredOrders.filter((order: any) => order.missingLabelImage).map((order: any) => order.orderId) if (trackingRequiredAndMissingLabelOrders.length) { orderList = orderList.filter((order: any) => !trackingRequiredAndMissingLabelOrders.includes(order.orderId)) } } + if (!orderList.length) { + showToast(translate("No orders are currently able to be shipped due to missing tracking codes.")) + return; + } + let shipmentIds = orderList.reduce((shipmentIds: any, order: any) => { if (order.shipments) { order.shipments.reduce((shipmentIds: any, shipment: any) => { @@ -366,8 +372,10 @@ export default defineComponent({ try { const resp = await OrderService.bulkShipOrders(payload) - if(resp.status == 200 && !hasError(resp)) { - showToast(translate('Orders shipped successfully')) + if (resp.status == 200 && !hasError(resp)) { + !trackingRequiredAndMissingLabelOrders.length + ? showToast(translate('Orders shipped successfully')) + : showToast(translate('out of cannot be shipped due to missing tracking codes.', { remainingOrders: trackingRequiredAndMissingLabelOrders.length, totalOrders: packedOrdersCount })) // TODO: handle the case of data not updated correctly await Promise.all([this.initialiseOrderQuery(), this.fetchShipmentMethods(), this.fetchCarrierPartyIds()]); } else {