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

Implemented: empty state in search page(#201) #203

Merged
merged 8 commits into from
Oct 11, 2023
Binary file added src/assets/images/empty-state.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"Count": "Count",
"Cycle Count": "Cycle Count",
"eCom Store": "eCom Store",
"Enter a SKU, or use the barcode scanner to search a product": "Enter a SKU, or use the barcode scanner to search a product",
"Enter product sku to search": "Enter product sku to search",
"Enter the amount of stock that has changed.": "Enter the amount of stock that has changed.",
"Enter the count of stock on the shelf.": "Enter the count of stock on the shelf.",
Expand All @@ -29,12 +30,12 @@
"Logging in": "Logging in",
"Logout": "Logout",
"Make sure you've reviewed the products and their counts before uploading them for review": "Make sure you've reviewed the products and their counts before uploading them for review",
"No results found": "No results found",
"No time zone found": "No time zone found",
"Ok": "Ok",
"OMS": "OMS",
"OMS instance": "OMS instance",
"Password": "Password",
"Product not found": "Product not found",
"Quantity": "Quantity",
"Quantity on hand": "Quantity on hand",
"Remove": "Remove",
Expand Down
1 change: 0 additions & 1 deletion src/store/modules/product/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ const actions: ActionTree<ProductState, RootState> = {
commit(types.PRODUCT_SEARCH_UPDATED, { products: products, totalProductsCount: totalProductsCount })
} else if (payload.viewIndex == 0) {
dispatch('clearSearchProducts')
showToast(translate("Product not found"));
ymaheshwari1 marked this conversation as resolved.
Show resolved Hide resolved
}
// Remove added loader only when new query and not the infinite scroll
if (payload.viewIndex === 0) emitter.emit("dismissLoader");
Expand Down
2 changes: 1 addition & 1 deletion src/store/modules/product/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const productModule: Module<ProductState, RootState> = {
current: {},
uploadProducts: {},
products: {
list: {},
list: [],
total: 0
}
},
Expand Down
17 changes: 17 additions & 0 deletions src/theme/variables.css
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,23 @@ http://ionicframework.com/docs/theming/ */
--spacer-xs: 0.5rem;
}

.empty-state {
max-width: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 10px;
}

.empty-state > img {
object-fit: contain;
}

.empty-state > p {
text-align: center;
}

@media (prefers-color-scheme: dark) {
/*
* Dark Colors
Expand Down
16 changes: 14 additions & 2 deletions src/views/Search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
</ion-header>
<ion-content>
<ion-searchbar @ionFocus="selectSearchBarText($event)" v-model="queryString" :placeholder="$t('Search')" @keyup.enter="queryString = $event.target.value; searchProducts()"/>

<!-- Empty state -->
<div class="empty-state" v-if="!products.length && !fetchingProducts">
<p v-if="showErrorMessage">{{ $t("No results found")}}</p>
<img src="../assets/images/empty-state.png" alt="No results found"/>
<p>{{ $t("Enter a SKU, or use the barcode scanner to search a product")}}</p>
</div>

<ion-list v-if="products.length > 0">
<ion-list-header>{{ $t("Results") }}</ion-list-header>
Expand Down Expand Up @@ -81,7 +88,9 @@ export default defineComponent({
},
data (){
return {
queryString: ''
queryString: '',
showErrorMessage: false,
fetchingProducts: false
}
},
computed: {
Expand Down Expand Up @@ -130,10 +139,13 @@ export default defineComponent({
})
},
async searchProducts(vSize?: any, vIndex?: any) {
this.queryString ? this.showErrorMessage = true : this.showErrorMessage = false;
this.fetchingProducts = true;
const viewSize = vSize ? vSize : process.env.VUE_APP_VIEW_SIZE;
const viewIndex = vIndex ? vIndex : 0;
const queryString = '*' + this.queryString + '*';
this.getProducts(viewSize, viewIndex, queryString);
await this.getProducts(viewSize, viewIndex, queryString);
this.fetchingProducts = false;
},
async getProducts(vSize?: any, vIndex?: any, queryString?: string) {
const payload = {
Expand Down