Skip to content

Commit 88875bf

Browse files
committed
Improved: deliverShipment method to display an alert before completing the action and updated the fab icon for mobile view(hotwax#472)
1 parent 41a193c commit 88875bf

File tree

1 file changed

+34
-13
lines changed

1 file changed

+34
-13
lines changed

src/views/OrderDetailUpdated.vue

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@
270270
</ion-label>
271271
</ion-item>
272272

273-
<ion-item lines="none" v-for="item in shipGroup.items" :key="item">
273+
<ion-item lines="none" v-for="item in shipGroup?.items" :key="item">
274274
<ion-thumbnail slot="start">
275275
<DxpShopifyImg :src="getProduct(item.productId).mainImageUrl" size="small"/>
276276
</ion-thumbnail>
@@ -305,7 +305,7 @@
305305
</ion-fab>
306306
<ion-fab v-else-if="orderType === 'packed' && order?.orderId" class="ion-hide-md-up" vertical="bottom" horizontal="end" slot="fixed" >
307307
<ion-fab-button :disabled="!hasPermission(Actions.APP_ORDER_UPDATE) || order.handovered || order.shipped || order.cancelled" @click="deliverShipment(order)">
308-
<ion-icon :icon="order.part?.shipmentMethodEnum?.shipmentMethodEnumId === 'STOREPICKUP' ? accessibilityOutline : checkmarkOutline" />
308+
<ion-icon :icon="checkmarkDoneOutline" />
309309
</ion-fab-button>
310310
</ion-fab>
311311
</ion-content>
@@ -345,15 +345,13 @@ import {
345345
import { computed, defineComponent } from "vue";
346346
import { mapGetters, useStore } from "vuex";
347347
import {
348-
accessibilityOutline,
349348
callOutline,
350349
cashOutline,
351350
copyOutline,
352351
closeOutline,
353352
closeCircleOutline,
354353
checkmarkCircleOutline,
355354
checkmarkDoneOutline,
356-
checkmarkOutline,
357355
cubeOutline,
358356
giftOutline,
359357
informationCircleOutline,
@@ -478,9 +476,31 @@ export default defineComponent({
478476
return assignPickerModal.present();
479477
},
480478
async deliverShipment(order: any) {
481-
await this.store.dispatch('order/deliverShipment', order)
482-
// Update the order timeline once the order is delivered/handovered
483-
this.prepareOrderTimeline();
479+
const pickup = order.part?.shipmentMethodEnum?.shipmentMethodEnumId === 'STOREPICKUP';
480+
const header = pickup ? translate("Handover") : translate("Ship");
481+
const message = pickup ? translate("Verify that the items in the package are valid and the customer has received their order. Once the order is handed over to the customer it cannot be undone.", { space: '<br/><br/>' }) : '';
482+
483+
const alert = await alertController
484+
.create({
485+
header,
486+
message,
487+
buttons: [{
488+
text: translate('Cancel'),
489+
role: 'cancel'
490+
}, {
491+
text: translate(header),
492+
handler: async () => {
493+
await this.store.dispatch('order/deliverShipment', order).then((resp: any) => {
494+
if(!hasError(resp)) {
495+
// Update order timeline once the order is completed
496+
// Sending statusId explicitly as we do not fetch the order info again on handover
497+
this.prepareOrderTimeline({ statusId: "ORDER_COMPLETED" });
498+
}
499+
})
500+
}
501+
}]
502+
});
503+
return alert.present();
484504
},
485505
async openOrderItemRejHistoryModal() {
486506
const orderItemRejHistoryModal = await modalController.create({
@@ -1005,13 +1025,16 @@ export default defineComponent({
10051025
return a[sortOnField] - b[sortOnField]
10061026
})
10071027
},
1008-
async prepareOrderTimeline() {
1028+
async prepareOrderTimeline(paramsToUpdate ?: any) {
10091029
const timeline = []
10101030
10111031
const {orderRouteSegment, shipmentStatusInfo} = await this.fetchOrderRouteSegmentInfo();
10121032
10131033
// Get order status using utility method
1014-
this.orderStatus = this.getOrderStatus(this.order, this.order.part, orderRouteSegment)
1034+
this.orderStatus = this.getOrderStatus({
1035+
...this.order,
1036+
...paramsToUpdate
1037+
}, this.order.part, orderRouteSegment)
10151038
10161039
let orderChangeHistory = await this.fetchOrderChangeHistory();
10171040
const orderPickupEmailCommnicationEvent = await this.fetchOrderCommunicationEvent();
@@ -1186,9 +1209,9 @@ export default defineComponent({
11861209
11871210
if(this.orderType === "packed") {
11881211
this.fetchJobs();
1189-
this.hasCancelledItems = this.order.part.items.some((item: any) => item.cancelReason);
1212+
this.hasCancelledItems = this.order.part?.items.some((item: any) => item.cancelReason);
11901213
} else if(this.orderType === "open") {
1191-
this.hasRejectedItems = this.order.part.items.some((item: any) => item.rejectReason);
1214+
this.hasRejectedItems = this.order.part?.items.some((item: any) => item.rejectReason);
11921215
}
11931216
11941217
await this.prepareOrderTimeline();
@@ -1205,7 +1228,6 @@ export default defineComponent({
12051228
12061229
return {
12071230
Actions,
1208-
accessibilityOutline,
12091231
bagCheckOutline,
12101232
bagHandleOutline,
12111233
bagRemoveOutline,
@@ -1218,7 +1240,6 @@ export default defineComponent({
12181240
closeOutline,
12191241
checkmarkCircleOutline,
12201242
checkmarkDoneOutline,
1221-
checkmarkOutline,
12221243
chevronUpOutline,
12231244
cubeOutline,
12241245
currentFacility,

0 commit comments

Comments
 (0)