Skip to content

Commit

Permalink
Improved: experience by adding toast messages if tracking is required…
Browse files Browse the repository at this point in the history
… for some or all orders (#281)
  • Loading branch information
k2maan committed Oct 17, 2023
1 parent 0515ff0 commit 74ae56b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions src/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -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",
Expand Down
16 changes: 12 additions & 4 deletions src/views/Completed.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
</ion-item>
</div>
<div class="results">
<ion-button :disabled="!hasAnyPackedShipment() || hasAnyMissingInfo() || !hasPermission(Actions.APP_FORCE_SHIP_ORDER)" expand="block" class="bulk-action desktop-only" fill="outline" size="large" @click="bulkShipOrders()">{{ translate("Ship") }}</ion-button>
<ion-button :disabled="!hasPermission(Actions.APP_FORCE_SHIP_ORDER)" expand="block" class="bulk-action desktop-only" fill="outline" size="large" @click="bulkShipOrders()">{{ translate("Ship") }}</ion-button>
<ion-card class="order" v-for="(order, index) in getCompletedOrders()" :key="index">
<div class="order-header">
<div class="order-primary-info">
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 74ae56b

Please sign in to comment.