Update index.tsx

Improved logic readability
This commit is contained in:
Leidison Siqueira Barbosa 2021-01-10 20:33:09 -03:00 committed by GitHub
parent 6ee207486d
commit 125d24792e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -45,10 +45,9 @@ export async function getStaticProps({
const { featured, bestSelling } = (() => { const { featured, bestSelling } = (() => {
// Create a copy of products that we can mutate // Create a copy of products that we can mutate
const products = [...newestProducts] const products = [...newestProducts]
.filter((product) => { .filter((product) => !featuredProducts
const featuredList = featuredProducts.map((product) => product.node.entityId) .map((product) => product.node.entityId)
return !featuredList.includes(product.node.entityId) .includes(product.node.entityId))
})
// If the lists of featured and best selling products don't have enough // If the lists of featured and best selling products don't have enough
// products, then fill them with products from the products list, this // products, then fill them with products from the products list, this
// is useful for new commerce sites that don't have a lot of products // is useful for new commerce sites that don't have a lot of products