Skip to content

Commit

Permalink
fix(next/api): add search v2 missing conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
sdjdd committed Jan 4, 2024
1 parent ad28385 commit d2e57fc
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions next/api/src/controller/ticket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit d2e57fc

Please sign in to comment.