fix local bootstrap startup and catalog widget UX
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
|
||||
import { ChangeDetectionStrategy, Component, Input, inject } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { SectionConfig } from '../../shared/models/config';
|
||||
import { CatalogCategoryGridComponent } from '../../features/website/catalog/components/category-grid/category-grid.component';
|
||||
import { CategoriesWidgetData } from '../contracts/widget-data.contract';
|
||||
import { Category } from '../../core/categories/models/category-domain.model';
|
||||
import { LanguageService } from '../../services/language.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-categories-widget',
|
||||
@@ -16,7 +19,10 @@ import { CategoriesWidgetData } from '../contracts/widget-data.contract';
|
||||
}
|
||||
|
||||
@if (widgetData.categories.length) {
|
||||
<app-catalog-category-grid [categories]="widgetData.categories" />
|
||||
<app-catalog-category-grid
|
||||
[categories]="widgetData.categories"
|
||||
(categorySelected)="onCategorySelected($event)"
|
||||
/>
|
||||
} @else if (widgetData.emptyMessage) {
|
||||
<p class="categories-widget__empty">{{ widgetData.emptyMessage }}</p>
|
||||
}
|
||||
@@ -32,6 +38,13 @@ import { CategoriesWidgetData } from '../contracts/widget-data.contract';
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
})
|
||||
export class CategoriesWidgetComponent {
|
||||
private readonly router = inject(Router);
|
||||
private readonly languageService = inject(LanguageService);
|
||||
|
||||
@Input() section: SectionConfig | null = null;
|
||||
@Input() data: CategoriesWidgetData | null = null;
|
||||
|
||||
onCategorySelected(category: Category): void {
|
||||
this.router.navigate([`/${this.languageService.currentLanguage()}/catalog`, category.id]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user