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);