From 42f38832e6d5ea97f13a78a335b2148c654abe3a Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Wed, 6 Nov 2024 16:24:54 +0530 Subject: [PATCH] Fixed: undefined passing in object error in count details page --- src/views/CountDetail.vue | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/views/CountDetail.vue b/src/views/CountDetail.vue index b799fd2b..be6e7baa 100644 --- a/src/views/CountDetail.vue +++ b/src/views/CountDetail.vue @@ -434,8 +434,13 @@ function updateFilteredItems() { // As we want to get the index of the product, if we directly store the product in the updatedProduct variable it does not return the index // as both the object becomes different because of the reference, so if we have a product, then first finding it in the filtered list to have a common reference and then getting the index const updatedProduct = Object.keys(product.value)?.length ? filteredItems.value.find((item) => item.productId === product.value.productId && item.importItemSeqId === product.value.importItemSeqId) : filteredItems.value[0] - store.dispatch("product/currentProduct", updatedProduct); - updateNavigationState(filteredItems.value.indexOf(updatedProduct)); + if (updatedProduct) { + store.dispatch("product/currentProduct", updatedProduct); + updateNavigationState(filteredItems.value.indexOf(updatedProduct)); + } else { + store.dispatch("product/currentProduct", product.value); + updateNavigationState(0); + } } else { store.dispatch("product/currentProduct", {}); isFirstItem.value = true