Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved: showing spinner while searching product in matchProduct modal (#563) #570

Merged
merged 1 commit into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -30,7 +35,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 @@ -59,6 +64,7 @@ import {
IonRadio,
IonRadioGroup,
IonSearchbar,
IonSpinner,
IonThumbnail,
IonTitle,
IonToolbar,
Expand All @@ -81,6 +87,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 @@ -91,6 +98,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 @@ -104,6 +112,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 @@ -181,6 +181,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 @@ -250,6 +251,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
Loading