Files
marketplaces/src/app/features/project-editor/sections/header-section.component.ts

43 lines
2.1 KiB
TypeScript
Raw Normal View History

2026-07-10 13:43:53 +04:00
import { ChangeDetectionStrategy, Component, inject } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { ProjectEditorFacade } from '../facade/project-editor.facade';
import { TranslatePipe } from '../../../i18n/translate.pipe';
import { HeaderConfig } from '../../../shared/models/config';
import { SectionCardComponent } from '../../../shared/ui/section-card/section-card.component';
import { ToggleComponent } from '../../../shared/ui/toggle/toggle.component';
2026-07-10 13:43:53 +04:00
@Component({
selector: 'app-project-editor-header-section',
standalone: true,
imports: [FormsModule, TranslatePipe, SectionCardComponent, ToggleComponent],
2026-07-10 13:43:53 +04:00
templateUrl: './header-section.component.html',
styleUrls: ['./section.shared.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class ProjectEditorHeaderSectionComponent {
private readonly facade = inject(ProjectEditorFacade);
readonly bootstrap = this.facade.bootstrap;
readonly items: Array<{ key: keyof HeaderConfig; label: string; descKey: string }> = [
{ key: 'showLogo', label: 'builder.showLogo', descKey: 'builder.showLogoDesc' },
{ key: 'showSearch', label: 'builder.showSearch', descKey: 'builder.showSearchDesc' },
{ key: 'showCategories', label: 'builder.showCategories', descKey: 'builder.showCategoriesDesc' },
{ key: 'showLanguages', label: 'builder.showLanguages', descKey: 'builder.showLanguagesDesc' },
{ key: 'showCart', label: 'builder.showCart', descKey: 'builder.showCartDesc' },
{ key: 'showProfile', label: 'builder.showProfile', descKey: 'builder.showProfileDesc' },
{ key: 'showWishlist', label: 'builder.showWishlist', descKey: 'builder.showWishlistDesc' },
{ key: 'showCompare', label: 'builder.showCompare', descKey: 'builder.showCompareDesc' },
{ key: 'showRegion', label: 'builder.showRegion', descKey: 'builder.showRegionDesc' },
2026-07-10 13:43:53 +04:00
];
toggle(key: keyof HeaderConfig, checked: boolean): void {
this.facade.updateBootstrap(current => ({
...current,
header: { ...(current.header ?? {}), [key]: checked }
}));
}
isChecked(key: keyof HeaderConfig): boolean {
return !!this.bootstrap()?.header?.[key];
}
}