Skip to content

Commit

Permalink
Merge pull request #203 from tanishqueSharma/inventoryCount/#201
Browse files Browse the repository at this point in the history
Implemented: empty state in search page(#201)
  • Loading branch information
ravilodhi authored Oct 11, 2023
2 parents ed1fc2c + 987c0ba commit 5f8d5a9
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 5 deletions.
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"));
}
// 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

0 comments on commit 5f8d5a9

Please sign in to comment.