diff --git a/src/views/AddProductToPOModal.vue b/src/views/AddProductToPOModal.vue index a45a0065..5c8c03f9 100644 --- a/src/views/AddProductToPOModal.vue +++ b/src/views/AddProductToPOModal.vue @@ -10,7 +10,7 @@ - + -
- empty-state -

{{ translate("Enter a SKU, or product name to search a product") }}

-
+ +
@@ -85,6 +92,8 @@ export default defineComponent({ data() { return { queryString: this.selectedSKU ? this.selectedSKU : '', + products: [], + hasSearched: false, isScrollingEnabled: false } }, @@ -121,6 +130,30 @@ export default defineComponent({ showToast(translate("Enter product sku to search")) } }, + async searchProducts() { + this.hasSearched = true; + this.products = []; // Clear the products array before each search + + if (this.queryString) { + const viewSize = process.env.VUE_APP_VIEW_SIZE; + const payload = { + viewSize, + viewIndex: 0, + queryString: this.queryString, + }; + + try { + const response = await this.store.dispatch("product/findProduct", payload); + if (response && response.data && response.data.response && response.data.response.docs) { + this.products = response.data.response.docs; + } else { + console.error("Unexpected response structure:", response); + } + } catch (error) { + console.error("Error fetching products:", error); + } + } + }, enableScrolling() { const parentElement = (this as any).$refs.contentRef.$el const scrollEl = parentElement.shadowRoot.querySelector("main[part='scroll']")