From 990106cda4b2ded9763fa5f3974ac833bd333555 Mon Sep 17 00:00:00 2001 From: VaiTon Date: Mon, 20 Nov 2023 22:46:44 +0100 Subject: [PATCH] Display brands in homepage products --- src/lib/api/product.ts | 7 +++++-- src/routes/+layout.svelte | 2 +- src/routes/+page.svelte | 22 +++++++++++++++------- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/lib/api/product.ts b/src/lib/api/product.ts index 0ff2310..de33eb6 100644 --- a/src/lib/api/product.ts +++ b/src/lib/api/product.ts @@ -108,7 +108,10 @@ export type Product = { nutriments: Nutriments; }; -export type ProductReduced = Pick; +export type ProductReduced = Pick< + Product, + 'image_front_small_url' | 'code' | 'product_name' | 'brands' +>; export async function getProduct( barcode: string, fetch: (url: string) => Promise @@ -132,7 +135,7 @@ export async function getProductReducedForCard( PRODUCT_URL(barcode) + '?' + new URLSearchParams({ - fields: 'image_front_small_url,code,product_name', + fields: 'image_front_small_url,code,product_name,brands', lc: get(preferences).lang }); const res = await wrapFetch(fetch)(url); diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index ac8325c..f8f21e9 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -37,7 +37,7 @@ - + diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index ba5f09e..fab4797 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -18,7 +18,10 @@ Explorer! -

OpenFoodFacts Explorer is a tool to explore the OpenFoodFacts database.

+

+ OpenFoodFacts Explorer + is a tool to explore the OpenFoodFacts database. +

You can enter a product code in the search bar above to get started or click on one of the products below. @@ -28,15 +31,15 @@