From b98e9baf037c78ecbb5b9bbe3001695f506d2f9e Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Wed, 18 Oct 2023 16:34:31 +0530 Subject: [PATCH] Fixed: issue when changing the order part id in url(#283) --- src/store/modules/order/actions.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/store/modules/order/actions.ts b/src/store/modules/order/actions.ts index 09b763b6e..80ba12817 100644 --- a/src/store/modules/order/actions.ts +++ b/src/store/modules/order/actions.ts @@ -100,7 +100,8 @@ const actions: ActionTree ={ 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 } @@ -127,7 +128,7 @@ const actions: ActionTree ={ 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, @@ -169,6 +170,9 @@ const actions: ActionTree ={ } }) + // 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 {