Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved: added handling on order details page for the order with picklist already created (#430) #431

Merged
merged 2 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/services/UserService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,17 @@ const isEnumExists = async (enumId: string): Promise<any> => {
}
}

const ensurePartyRole = async (payload: any): Promise <any> => {
return api({
url: "service/ensurePartyRole",
method: "post",
data: payload
});
}

export const UserService = {
createEnumeration,
ensurePartyRole,
login,
getCurrentEComStore,
getRerouteFulfillmentConfig,
Expand Down
29 changes: 26 additions & 3 deletions src/views/OrderDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ export default defineComponent({
});

assignPickerModal.onDidDismiss().then(async(result: any) => {
if(result.data.dismissed) {
if(result.data.selectedPicker) {
await this.store.dispatch('order/packShipGroupItems', { order, part, facilityId, selectedPicker: result.data.selectedPicker })
}
})
Expand Down Expand Up @@ -395,7 +395,7 @@ export default defineComponent({
return rejectOrderModal.present();
},
async readyForPickup(order: any, part: any) {
if (this.configurePicker) return this.assignPicker(order, part, this.currentFacility.facilityId);
if(this.configurePicker && order.isPicked !== 'Y') return this.assignPicker(order, part, this.currentFacility.facilityId);
const pickup = part?.shipmentMethodEnum?.shipmentMethodEnumId === 'STOREPICKUP';
const header = pickup ? translate('Ready for pickup') : translate('Ready to ship');
const message = pickup ? translate('An email notification will be sent to that their order is ready for pickup. This order will also be moved to the packed orders tab.', { customerName: order.customer.name, space: '<br/><br/>' }) : '';
Expand All @@ -410,12 +410,35 @@ export default defineComponent({
}, {
text: header,
handler: async () => {
await this.store.dispatch('order/packShipGroupItems', { order: order, part: part, facilityId: this.currentFacility.facilityId })
if(!pickup) {
this.packShippingOrders(order, part);
} else {
this.store.dispatch('order/packShipGroupItems', {order, part, facilityId: this.currentFacility.facilityId})
}
}
}]
});
return alert.present();
},
async packShippingOrders(currentOrder: any, part: any) {
try {
const resp = await OrderService.packOrder({
'picklistBinId': currentOrder.picklistBinId,
'orderId': currentOrder.orderId
})

if(!hasError(resp)) {
showToast(translate("Order packed and ready for delivery"));
this.store.dispatch("order/updateCurrent", { order: { ...currentOrder, readyToShip: true } })
this.store.dispatch("order/removeOpenOrder", { order: currentOrder, part })
} else {
throw resp.data;
}
} catch(error: any) {
logger.error(error);
showToast(translate("Something went wrong"))
}
},
async fetchRejectReasons() {
await this.store.dispatch('util/fetchRejectReasons');
},
Expand Down
19 changes: 17 additions & 2 deletions src/views/Orders.vue
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ import { api, hasError } from '@/adapter';
import { translate } from "@hotwax/dxp-components";
import AssignPickerModal from "./AssignPickerModal.vue";
import { OrderService } from "@/services/OrderService";
import { UserService } from "@/services/UserService";
import { Actions, hasPermission } from '@/authorization'
import logger from "@/logger";

Expand Down Expand Up @@ -276,7 +277,7 @@ export default defineComponent({
});

assignPickerModal.onDidDismiss().then(async(result: any) => {
if(result.data?.dismissed) {
if(result.data?.selectedPicker) {
await this.store.dispatch('order/packShipGroupItems', { order, part, facilityId, selectedPicker: result.data.selectedPicker })
}
})
Expand Down Expand Up @@ -516,6 +517,20 @@ export default defineComponent({
}

if(!this.configurePicker) {
try {
const resp = await UserService.ensurePartyRole({
partyId: "_NA_",
roleTypeId: "WAREHOUSE_PICKER",
})

if(hasError(resp)) {
throw resp.data;
}
} catch (error) {
showToast(translate("Something went wrong. Picklist can not be created."));
logger.error(error)
return;
}
await this.createPicklist(order, "_NA_");
return;
}
Expand All @@ -526,7 +541,7 @@ export default defineComponent({
});

assignPickerModal.onDidDismiss().then(async(result: any) => {
if(result.data?.dismissed) {
if(result.data?.selectedPicker) {
this.createPicklist(order, result.data.selectedPicker)
}
})
Expand Down
Loading