nan error

This commit is contained in:
tonoyan
2026-04-13 15:10:40 +03:00
parent 6de461473e
commit 5b794cbf03
4 changed files with 23 additions and 2 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -40,7 +40,17 @@ export class CategoryComponent implements OnInit, OnDestroy {
ngOnInit(): void { ngOnInit(): void {
this.routeSubscription = this.route.params.subscribe(params => { 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.categoryID.set(id);
this.resetAndLoad(); this.resetAndLoad();
}); });

View File

@@ -41,7 +41,18 @@ export class SubcategoriesComponent implements OnInit, OnDestroy {
ngOnInit(): void { ngOnInit(): void {
this.routeSubscription = this.route.params.subscribe(params => { 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); this.loadForParent(id);
}); });
} }