Improve product AI UX, category search, and card actions.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Alireza Hassani
2026-09-19 08:20:34 +03:30
co-authored by Cursor
parent d787a69195
commit b743c09e4d
15 changed files with 558 additions and 186 deletions
+19
View File
@@ -49,3 +49,22 @@ export function getAncestorIds(categories: Category[], id: string): string[] {
return ids
}
/** Client-side filter by FA/EN name; keeps ancestors so the tree stays intact. */
export function filterCategoriesByQuery(categories: Category[], query: string): Category[] {
const normalized = query.trim().toLowerCase()
if (!normalized) return categories
const matchedIds = new Set<string>()
for (const category of categories) {
const haystack = `${category.nameFa} ${category.nameEn}`.toLowerCase()
if (!haystack.includes(normalized)) continue
matchedIds.add(category.id)
for (const ancestorId of getAncestorIds(categories, category.id)) {
matchedIds.add(ancestorId)
}
}
return categories.filter((category) => matchedIds.has(category.id))
}