refactor: revew all design of services, clients, deadcode, ...

This commit is contained in:
Julien Froidefond
2025-08-24 22:03:15 +02:00
parent f4dcc89c11
commit 6fba622003
63 changed files with 969 additions and 1846 deletions

View File

@@ -16,7 +16,9 @@ export function useTreeView<T>({
onSearchChange,
}: UseTreeViewOptions<T>) {
// État pour les catégories ouvertes/fermées
const [expandedCategories, setExpandedCategories] = useState<Set<string>>(new Set());
const [expandedCategories, setExpandedCategories] = useState<Set<string>>(
new Set()
);
// Grouper les données par catégorie et filtrer en fonction de la recherche
const filteredDataByCategory = useMemo(() => {
@@ -31,23 +33,26 @@ export function useTreeView<T>({
}, {} as Record<string, T[]>);
// Filtrer les données en fonction de la recherche
return Object.entries(dataByCategory).reduce((acc, [category, categoryItems]) => {
const filteredItems = categoryItems.filter((item) => {
const matchesSearch = searchFields.some((field) => {
const value = item[field];
if (typeof value === 'string') {
return value.toLowerCase().includes(searchTerm.toLowerCase());
}
return false;
return Object.entries(dataByCategory).reduce(
(acc, [category, categoryItems]) => {
const filteredItems = categoryItems.filter((item) => {
const matchesSearch = searchFields.some((field) => {
const value = item[field];
if (typeof value === "string") {
return value.toLowerCase().includes(searchTerm.toLowerCase());
}
return false;
});
return matchesSearch;
});
return matchesSearch;
});
if (filteredItems.length > 0) {
acc[category] = filteredItems;
}
return acc;
}, {} as Record<string, T[]>);
if (filteredItems.length > 0) {
acc[category] = filteredItems;
}
return acc;
},
{} as Record<string, T[]>
);
}, [data, searchFields, groupBy, searchTerm]);
// Fonctions pour gérer l'expansion des catégories