From f0dde50635f92bc6d8674f86a7381e312dbbbb97 Mon Sep 17 00:00:00 2001 From: Pierre Gauthier Date: Mon, 11 Mar 2024 11:26:23 +0100 Subject: [PATCH] [VectorSearch] #1279426 - Add description as tooltip in list --- .../src/components/VectorSearch/ProductList.tsx | 10 +++++++++- .../example-app/src/services/vectorSearchDocuments.ts | 5 +++++ front/example-app/src/types/product.ts | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/front/example-app/src/components/VectorSearch/ProductList.tsx b/front/example-app/src/components/VectorSearch/ProductList.tsx index ea4ccb4aa..89363825e 100644 --- a/front/example-app/src/components/VectorSearch/ProductList.tsx +++ b/front/example-app/src/components/VectorSearch/ProductList.tsx @@ -166,7 +166,15 @@ function ProductList(props: IProps): JSX.Element { return ( {item.sku} - {item.name} + ]+)>)/, '') + : '' + } + > + {item.name} + {item.score.toFixed(4)} ) diff --git a/front/example-app/src/services/vectorSearchDocuments.ts b/front/example-app/src/services/vectorSearchDocuments.ts index c367ff364..2f84390d5 100644 --- a/front/example-app/src/services/vectorSearchDocuments.ts +++ b/front/example-app/src/services/vectorSearchDocuments.ts @@ -23,6 +23,11 @@ export function transformVectorSearchDocumentsIntoProducts( document.source.name.length > 0 ? (document.source?.name[0] as string) : '', + description: + Array.isArray(document.source?.description) && + document.source.description.length > 0 + ? (document.source?.description[0] as string) + : '', score: Number(document.score), image: document.source?.image as string, stock: document.source?.stock ?? undefined, diff --git a/front/example-app/src/types/product.ts b/front/example-app/src/types/product.ts index a4681cba0..56f5aba80 100644 --- a/front/example-app/src/types/product.ts +++ b/front/example-app/src/types/product.ts @@ -14,6 +14,7 @@ export interface IProductsHook extends IEntitiesHook { export interface IProduct extends Omit { price?: number image?: string + description?: string } export interface IProductAutoComplete extends IProduct {