feat: enhance TagInput component with popular tags loading

- Added `loadPopularTags` function to fetch and display popular tags when the input is empty.
- Updated `TagInput` to show suggestions based on input focus and improved suggestion display with a grid layout.
- Adjusted styles for better visual clarity and user experience.
This commit is contained in:
Julien Froidefond
2025-09-14 21:49:52 +02:00
parent 3cca0fe1dc
commit 7927b0aec2
2 changed files with 50 additions and 23 deletions

View File

@@ -214,10 +214,24 @@ export function useTagsAutocomplete() {
setSuggestions([]);
}, []);
const loadPopularTags = useCallback(async (limit: number = 20) => {
setLoading(true);
try {
const response = await tagsClient.getPopularTags(limit);
setSuggestions(response.data);
} catch (error) {
console.error('Erreur lors du chargement des tags populaires:', error);
setSuggestions([]);
} finally {
setLoading(false);
}
}, []);
return {
suggestions,
loading,
searchTags,
clearSuggestions
clearSuggestions,
loadPopularTags
};
}