Skip to content

Commit

Permalink
Implemented: Logic for the reroute fulfillment v2 (hotwax#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
amansinghbais committed Sep 19, 2024
1 parent 2c4651c commit b4b7a14
Show file tree
Hide file tree
Showing 3 changed files with 265 additions and 78 deletions.
75 changes: 13 additions & 62 deletions src/services/OrderService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,77 +61,28 @@ const fetchOrderFacilityChangeHistory = async (payload: any): Promise<any> => {
})
}

const fetchCustomerSavedAddress = async (orderId: any): Promise<any> => {
const releaseOrderItem = async (payload: any): Promise<any> => {
let baseURL = store.getters['user/getInstanceUrl'];
baseURL = baseURL && baseURL.startsWith('http') ? baseURL : `https://${baseURL}.hotwax.io/api/`;

let resp, contactMechId, address;
let params = {
entityName: "OrderContactMech",
inputFields: {
orderId: orderId,
contactMechPurposeTypeId: "SHIPPING_LOCATION"
},
fieldList: ["orderId", "contactMechId"],
viewSize: 1
} as any;

try {
resp = await client({
url: "performFind",
method: "POST",
data: params,
baseURL,
headers: {
Authorization: 'Bearer ' + process.env.VUE_APP_BASE,
'Content-Type': 'application/json'
}
})

if(!hasError(resp)) {
contactMechId = resp.data.docs[0]?.contactMechId;

params = {
entityName: "PostalAddress",
inputFields: {
contactMechId
},
viewSize: 1
};

resp = await client({
url: "performFind",
method: "POST",
data: params,
baseURL,
headers: {
Authorization: 'Bearer ' + process.env.VUE_APP_BASE,
'Content-Type': 'application/json'
}
})

if(!hasError(resp)) {
address = resp.data.docs[0]
} else {
throw resp.data;
}
} else {
throw resp.data;
return client({
url: "releaseOrderItem",
method: "POST",
data: payload,
baseURL,
headers: {
Authorization: 'Bearer ' + process.env.VUE_APP_BASE,
'Content-Type': 'application/json'
}
} catch(error: any) {
console.error(error);
}

return address;
}

});
}

export const OrderService = {
fetchCustomerSavedAddress,
fetchOrderFacilityChangeHistory,
getOrder,
updateShippingAddress,
updatePickupFacility,
cancelOrderItem,
getProductStoreSetting
getProductStoreSetting,
releaseOrderItem
}
6 changes: 3 additions & 3 deletions src/views/OldOrder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export default defineComponent({
cutomerAddress: {} as any,
nearbyStores: [] as any,
availableStores: [] as any,
storesWithInventory: [] as any
storesWithInventory: [] as any,
}
},
computed: {
Expand Down Expand Up @@ -211,7 +211,6 @@ export default defineComponent({
this.store.dispatch("user/setUserInstanceUrl", `${this.$route.query.oms}/api/`)
await this.getOrder();
this.fetchOrderFacilityChangeHistory()
this.cutomerAddress = await OrderService.fetchCustomerSavedAddress(this.order.id);
await this.getPickupStores();
if(!this.nearbyStores.length) this.selectedSegment = "separate"
}
Expand Down Expand Up @@ -247,7 +246,7 @@ export default defineComponent({
order = resp.data;
const productIds: any = new Set();
order.shipGroup = order.shipGroup.filter((group: any) => {
if(group.facilityId === 'PICKUP_REJECTED') {
if(group.facilityId === 'PICKUP_REJECTED' && group.shipmentMethodTypeId === 'STOREPICKUP') {
group.selectedShipmentMethodTypeId = group.shipmentMethodTypeId;
group.items = group.items.filter((item: any) => {
if (item.status == 'ITEM_CANCELLED') return false;
Expand All @@ -257,6 +256,7 @@ export default defineComponent({
return group.items.length > 0;
}
})
if (productIds.length) await this.fetchProducts([...productIds])
await this.store.dispatch("user/getConfiguration", { productStoreId: order.productStoreId, token: this.token});
this.order = order;
Expand Down
Loading

0 comments on commit b4b7a14

Please sign in to comment.