4
0
forked from crowetic/commerce

Re Sorting

This commit is contained in:
Belen Curcio 2020-10-26 21:06:36 -03:00
parent 2da59ba533
commit 969a8e78cc

View File

@ -61,10 +61,10 @@ export default function Home({
// 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
return { return {
featured: rangeMap( featured: rangeMap(6, (i) => featuredProducts[i] ?? products.shift())
6, .filter(nonNullable)
(i) => featuredProducts[i] ?? products.shift() .sort((a, b) => a.node.prices.price.value - b.node.prices.price.value)
).filter(nonNullable), .reverse(),
bestSelling: rangeMap( bestSelling: rangeMap(
6, 6,
(i) => bestSellingProducts[i] ?? products.shift() (i) => bestSellingProducts[i] ?? products.shift()
@ -87,7 +87,7 @@ export default function Home({
))} ))}
</Grid> </Grid>
<Marquee variant="secondary"> <Marquee variant="secondary">
{bestSelling.slice(0, 3).map(({ node }) => ( {bestSelling.slice(3, 6).map(({ node }) => (
<ProductCard <ProductCard
key={node.path} key={node.path}
product={node} product={node}
@ -119,7 +119,7 @@ export default function Home({
))} ))}
</Grid> </Grid>
<Marquee> <Marquee>
{bestSelling.slice(3, 6).map(({ node }) => ( {bestSelling.slice(0, 3).map(({ node }) => (
<ProductCard <ProductCard
key={node.path} key={node.path}
product={node} product={node}