Skip to content

Commit

Permalink
Fixed: issue when changing the order part id in url(#283)
Browse files Browse the repository at this point in the history
  • Loading branch information
ymaheshwari1 committed Oct 18, 2023
1 parent 96d4dc5 commit b98e9ba
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/store/modules/order/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ const actions: ActionTree<OrderState , RootState> ={
async getOrderDetail( { dispatch, state }, payload ) {
const current = state.current as any
const orders = JSON.parse(JSON.stringify(state.open.list)) as any
if(current.orderId === payload.orderId) {
// As one order can have multiple parts thus checking orderId and partSeq as well before making any api call
if(current.orderId === payload.orderId && current.part?.orderPartSeqId === payload.orderPartSeqId) {
this.dispatch('product/getProductInformation', { orders: [ current ] })
return current
}
Expand All @@ -127,7 +128,7 @@ const actions: ActionTree<OrderState , RootState> ={
try {
resp = await OrderService.getOrderDetails(orderQueryPayload)
if (resp.status === 200 && !hasError(resp) && resp.data.grouped?.orderId?.ngroups > 0) {
const orders = resp.data.grouped?.orderId?.groups.map((order: any) => {
let orders = resp.data.grouped?.orderId?.groups.map((order: any) => {
const orderItem = order.doclist.docs[0]
return {
orderId: orderItem.orderId,
Expand Down Expand Up @@ -169,6 +170,9 @@ const actions: ActionTree<OrderState , RootState> ={
}
})

// creating order part to render the items correctly on UI
orders = Object.keys(orders).length ? orders.flatMap((order: any) => order.parts.map((part: any) => ({ ...order, part }))) : [];

this.dispatch('product/getProductInformation', { orders })
currentOrder = orders[0]
} else {
Expand Down

0 comments on commit b98e9ba

Please sign in to comment.