feat: Implement dynamic filtering for agent search by adding a filters parameter to the search service and utilizing it in the profiles page.

This commit is contained in:
pradeepkumar
2026-02-01 18:30:21 +05:30
parent 09cf44f418
commit 58a1918fa8
2 changed files with 17 additions and 1 deletions

View File

@@ -326,6 +326,18 @@ function ProfilesPageContent() {
params.city = location;
}
// Add dynamic profile field filters
const activeFilters = Object.entries(filters).reduce((acc, [key, values]) => {
if (values && values.length > 0) {
acc[key] = values;
}
return acc;
}, {} as Record<string, string[]>);
if (Object.keys(activeFilters).length > 0) {
params.filters = activeFilters;
}
const response = await agentsService.searchAgents(params);
setAgents(response.data);
setTotalPages(response.totalPages);
@@ -336,7 +348,7 @@ function ProfilesPageContent() {
} finally {
setLoading(false);
}
}, [currentPage, searchQuery, activeTypeId, searchParams]);
}, [currentPage, searchQuery, activeTypeId, searchParams, filters]);
// Fetch agents when filters change (only after initialization)
useEffect(() => {