Skip to content

Commit

Permalink
Merge pull request #570 from amansinghbais/#563
Browse files Browse the repository at this point in the history
Improved: showing spinner while searching product in matchProduct modal (#563)
  • Loading branch information
ymaheshwari1 authored Dec 30, 2024
2 parents 277db5d + 3fbdb39 commit fb0dd1a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/components/MatchProductModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
<ion-content>
<ion-searchbar v-model="queryString" :placeholder="translate('Search product')" @keyup.enter="handleSearch" />

<template v-if="products.length">
<div v-if="isLoading" class="empty-state">
<ion-spinner name="crescent" />
<ion-label>{{ translate("Searching for", { queryString }) }}</ion-label>
</div>

<template v-else-if="products.length">
<ion-radio-group v-model="selectedProductId">
<ion-item v-for="product in products" :key="product.productId">
<ion-thumbnail slot="start">
Expand All @@ -37,7 +42,7 @@
</template>

<div v-else-if="queryString && isSearching && !products.length" class="empty-state">
<p>{{ translate("No product found") }}</p>
<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 @@ -66,6 +71,7 @@ import {
IonRadio,
IonRadioGroup,
IonSearchbar,
IonSpinner,
IonThumbnail,
IonTitle,
IonToolbar,
Expand All @@ -88,6 +94,7 @@ const products = ref([]) as any;
let queryString = ref('');
const isSearching = ref(false);
const selectedProductId = ref("") as Ref<string>;
const isLoading = ref(false);
async function handleSearch() {
if(!queryString.value.trim()) {
Expand All @@ -98,6 +105,7 @@ async function handleSearch() {
isSearching.value = true;
}
async function getProducts() {
isLoading.value = true;
let productsList = [] as any;
try {
const resp = await ProductService.fetchProducts({
Expand All @@ -112,6 +120,7 @@ async function getProducts() {
logger.error("Failed to fetch products", err)
}
products.value = productsList
isLoading.value = false;
}
function closeModal(payload = {}) {
modalController.dismiss({ dismissed: true, ...payload });
Expand Down
2 changes: 2 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@
"No new file upload. Please try again": "No new file upload. Please try again",
"No rejection history": "No rejection history",
"No results found": "No results found",
"No results found for": "No results found for {queryString}",
"No time zone found": "No time zone found",
"NOT COUNTED": "NOT COUNTED",
"not counted": "not counted",
Expand Down Expand Up @@ -248,6 +249,7 @@
"Scanned item is not present in the count. To add new product move to All Segment.": "Scanned item is not present in the count. To add new product move to All Segment.",
"Scan or search products": "Scan or search products",
"Scanned quantity": "Scanned quantity",
"Searching for": "Searching for {queryString}",
"selected": "selected",
"Select": "Select",
"Search facilities": "Search facilities",
Expand Down

0 comments on commit fb0dd1a

Please sign in to comment.