From accdf6501f4f56777881f170f5b12e9045f5a902 Mon Sep 17 00:00:00 2001 From: Marc Rutkowski Date: Mon, 7 Oct 2024 19:59:52 +0200 Subject: [PATCH] =?UTF-8?q?Corrige=20une=20erreur=20de=20typage=20qui=20fa?= =?UTF-8?q?it=20=C3=A9chouer=20le=20build?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/Landing/useFilteredCollectivites.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/panier/components/Landing/useFilteredCollectivites.ts b/packages/panier/components/Landing/useFilteredCollectivites.ts index 5a82ac43320..49d3d85560e 100644 --- a/packages/panier/components/Landing/useFilteredCollectivites.ts +++ b/packages/panier/components/Landing/useFilteredCollectivites.ts @@ -2,6 +2,13 @@ import { makeSearchString } from '@tet/api'; import useSWR from 'swr'; import { supabase } from '../../src/clientAPI'; +type Collectivite = { + collectivite_id: number; + nom: string; + departement_code?: number; + engagee?: boolean; +}; + /** Donne la liste des collectivités dont le nom inclus la chaîne recherchée */ export const useFilteredCollectivites = (search: string, limit = 10) => { const key = `site_labellisation-filtered-${search}`; @@ -9,15 +16,16 @@ export const useFilteredCollectivites = (search: string, limit = 10) => { const query = supabase .from('site_labellisation') .select('collectivite_id, nom, departement_code, engagee') - .order('nom') - .limit(limit); + .order('nom'); const processedSearch = makeSearchString(search, 'nom'); if (processedSearch) { query.or(processedSearch); } - const { error, data } = await query; + query.limit(limit); + + const { error, data } = await query.returns(); if (error) { throw new Error(key);