-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
89b3772
commit b26a261
Showing
7 changed files
with
98 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<template> | ||
<div> | ||
<productList :items="searched ? filteredBySearch:products" /> | ||
<div v-if="Object.keys(filteredBySearch).length === 0" class="alert alert-warning"> | ||
Nothing found | ||
</div> | ||
</div> | ||
</template> | ||
<script> | ||
import productList from "@/components/productList.vue"; | ||
export default { | ||
data() { | ||
return { | ||
}; | ||
}, | ||
components: { | ||
productList, | ||
}, | ||
watchQuery: true, | ||
asyncData({ store,query }) { | ||
const products = {}; | ||
const allCategories={ | ||
Digital:store.state.Digital.Products, | ||
Fashion:store.state.Fashion.Products, | ||
Beauty:store.state.Beauty.Products, | ||
House:store.state.House.Products | ||
}; | ||
for (let key in allCategories) { | ||
pushToProducts(allCategories[key]); | ||
} | ||
function pushToProducts(Product) { | ||
for (let key in Product) { | ||
products[key] = Product[key]; | ||
} | ||
} | ||
const filteredBySearch={} | ||
let searched=false | ||
if(query.search){ | ||
searched=true | ||
for (let key in products) { | ||
const filtered=products[key].filter(item=>item.name.toLowerCase().includes(query.search.toLowerCase())); | ||
if(filtered.length>0){ | ||
filteredBySearch[key]=filtered | ||
} | ||
} | ||
store.commit('changeSearchValue',query.search); | ||
} | ||
return { | ||
products, | ||
filteredBySearch, | ||
searched | ||
}; | ||
}, | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters