product preview en index

This commit is contained in:
Cat /dev/Nulo 2023-12-30 00:02:02 -03:00
parent f20203cac8
commit d59b4283bc
2 changed files with 8 additions and 5 deletions

View file

@ -6,7 +6,11 @@ import { sql } from "drizzle-orm";
export const load: PageServerLoad = async ({ params }) => {
const q = db
.select({ ean: precios.ean, name: precios.name })
.select({
ean: precios.ean,
name: precios.name,
imageUrl: precios.imageUrl,
})
.from(precios)
.groupBy(precios.ean)
.having(sql`max(length(name))`)

View file

@ -1,4 +1,5 @@
<script lang="ts">
import ProductPreview from "$lib/ProductPreview.svelte";
import type { PageData } from "./$types";
export let data: PageData;
@ -30,12 +31,10 @@
<section>
<h2 class="text-lg font-bold">Random</h2>
<ul>
<ul class="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3">
{#each data.precios as product}
<li>
<a href={`/ean/${product.ean}`}>
{product.name}
</a>
<ProductPreview {product} />
</li>
{/each}
</ul>