Skip to content

Commit

Permalink
Fix category service
Browse files Browse the repository at this point in the history
* handle empty categories
  • Loading branch information
alexander-kiriliuk committed Sep 18, 2024
1 parent 72d150d commit e9ee39c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/shared/modules/category/category.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,17 @@ export class CategoryService {
where: { code },
relations: CATEGORY_RELATIONS,
});
if (!cat) {
return null;
}
const res = await this.catRep.findDescendantsTree(cat, {
depth,
relations: CATEGORY_RELATIONS,
});
res.children?.forEach((cat) => this.sort(cat));
if (!res.children?.length) {
return res;
}
res.children.forEach((cat) => this.sort(cat));
this.sort(res);
return res;
}
Expand Down

0 comments on commit e9ee39c

Please sign in to comment.