Skip to content

Commit

Permalink
Improved: logic for managing previous queryState (#528)
Browse files Browse the repository at this point in the history
  • Loading branch information
amansinghbais committed Jan 13, 2025
1 parent 1a080cd commit ef31c04
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/components/MatchProductModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</ion-toolbar>
</ion-header>
<ion-content>
<ion-searchbar v-model="queryString" :placeholder="translate('Search product')" @keyup.enter="handleSearch" />
<ion-searchbar :value="queryString" :placeholder="translate('Search product')" @keyup.enter="queryString = $event.target.value; handleSearch()" />

<div v-if="isLoading" class="empty-state">
<ion-spinner name="crescent" />
Expand Down Expand Up @@ -41,8 +41,8 @@
</ion-radio-group>
</template>

<div v-else-if="prevSearchedQuery && isSearching && !products.length" class="empty-state">
<p>{{ translate("No results found for", { queryString: prevSearchedQuery }) }}</p>
<div v-else-if="queryString && isSearching && !products.length" class="empty-state">
<p>{{ translate("No results found for", { queryString }) }}</p>
</div>
<div v-else class="empty-state">
<img src="../assets/images/empty-state-add-product-modal.png" alt="empty-state" />
Expand Down Expand Up @@ -95,7 +95,6 @@ let queryString = ref('');
const isSearching = ref(false);
const selectedProductId = ref("") as Ref<string>;
const isLoading = ref(false);
const prevSearchedQuery = ref("");
async function handleSearch() {
if(!queryString.value.trim()) {
Expand All @@ -121,7 +120,6 @@ async function getProducts() {
logger.error("Failed to fetch products", err)
}
products.value = productsList
prevSearchedQuery.value = queryString.value
isLoading.value = false;
}
function closeModal(payload = {}) {
Expand Down

0 comments on commit ef31c04

Please sign in to comment.