diff --git a/next/api/src/controller/ticket.ts b/next/api/src/controller/ticket.ts index ba5e4b465..74bc102dd 100644 --- a/next/api/src/controller/ticket.ts +++ b/next/api/src/controller/ticket.ts @@ -201,10 +201,11 @@ export class TicketController { }, }; - if (query.rootCategoryId) { - const categories = await categoryService.getSubCategories(query.rootCategoryId); + const rootCategoryId = query.product ?? query.rootCategoryId; + if (rootCategoryId) { + const categories = await categoryService.getSubCategories(rootCategoryId); let categoryIds = categories.map((c) => c.id); - categoryIds.push(query.rootCategoryId); + categoryIds.push(rootCategoryId); if (query.categoryId) { categoryIds.push(...query.categoryId); } @@ -250,6 +251,15 @@ export class TicketController { ]; } + if (query.fieldId && query.fieldValue) { + searchOptions.filters.fields = [ + { + id: query.fieldId, + value: query.fieldValue, + }, + ]; + } + if (query.orderBy) { const [sortField, order] = query.orderBy.endsWith('-asc') ? ([query.orderBy.slice(0, -4), 'asc'] as const)