diff --git a/src/app/pages/category/._category.component.ts b/src/app/pages/category/._category.component.ts new file mode 100644 index 0000000..707ba9b Binary files /dev/null and b/src/app/pages/category/._category.component.ts differ diff --git a/src/app/pages/category/._subcategories.component.ts b/src/app/pages/category/._subcategories.component.ts new file mode 100644 index 0000000..707ba9b Binary files /dev/null and b/src/app/pages/category/._subcategories.component.ts differ diff --git a/src/app/pages/category/category.component.ts b/src/app/pages/category/category.component.ts index e3b51ba..e7c13dd 100644 --- a/src/app/pages/category/category.component.ts +++ b/src/app/pages/category/category.component.ts @@ -40,7 +40,17 @@ export class CategoryComponent implements OnInit, OnDestroy { ngOnInit(): void { this.routeSubscription = this.route.params.subscribe(params => { - const id = parseInt(params['id'], 10); + const id = Number.parseInt(params['id'], 10); + + if (!Number.isFinite(id) || id <= 0) { + this.error.set('Invalid category ID'); + this.items.set([]); + this.hasMore.set(false); + this.loading.set(false); + this.isLoadingMore = false; + return; + } + this.categoryID.set(id); this.resetAndLoad(); }); diff --git a/src/app/pages/category/subcategories.component.ts b/src/app/pages/category/subcategories.component.ts index 1146b10..805963f 100644 --- a/src/app/pages/category/subcategories.component.ts +++ b/src/app/pages/category/subcategories.component.ts @@ -41,7 +41,18 @@ export class SubcategoriesComponent implements OnInit, OnDestroy { ngOnInit(): void { this.routeSubscription = this.route.params.subscribe(params => { - const id = parseInt(params['id'], 10); + const id = Number.parseInt(params['id'], 10); + + if (!Number.isFinite(id) || id <= 0) { + this.error.set('Invalid category ID'); + this.categories.set([]); + this.subcategories.set([]); + this.nestedSubcategories.set([]); + this.categoryItems.set([]); + this.loading.set(false); + return; + } + this.loadForParent(id); }); }