refactor(project-editor): toggles + remove as-any casts in features section

- checkboxes -> app-toggle, wrap in SectionCard
- toggleUserExperience/toggleProductFeature typed without 'as any' (optional
  chaining on the already-typed UserExperienceConfig/ProductPageConfig union)
- removed dead, broken toggleRecentViewed method (unused, not wired to the
  template; toggleUserExperience('recentlyViewed', ...) is the live path)

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
sdarbinyan
2026-07-16 02:12:25 +04:00
parent 0c9a855232
commit 058e2d571f
2 changed files with 16 additions and 19 deletions

View File

@@ -2,6 +2,8 @@ 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 { SectionCardComponent } from '../../../shared/ui/section-card/section-card.component';
import { ToggleComponent } from '../../../shared/ui/toggle/toggle.component';
export interface CatalogNavigationOption {
value: 'default' | 'left-category-navigation' | 'mega-category-layout' | 'top-category-carousel';
@@ -12,7 +14,7 @@ export interface CatalogNavigationOption {
@Component({
selector: 'app-project-editor-features-section',
standalone: true,
imports: [FormsModule, TranslatePipe],
imports: [FormsModule, TranslatePipe, SectionCardComponent, ToggleComponent],
templateUrl: './features-section.component.html',
styleUrls: ['./section.shared.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
@@ -43,17 +45,13 @@ export class ProjectEditorFeaturesSectionComponent {
this.facade.updateBootstrap(current => ({ ...current, featureFlags: { ...current.featureFlags, [key]: checked } }));
}
toggleRecentViewed(checked: boolean): void {
this.facade.updateBootstrap(current => ({ ...current, userExperience: { ...current.userExperience, recentlyViewed: { ...current.userExperience!, recentlyViewed: undefined } as any } }));
}
toggleUserExperience(path: 'recentlyViewed' | 'wishlist' | 'compare', checked: boolean): void {
this.facade.updateBootstrap(current => ({
...current,
userExperience: {
...current.userExperience,
[path]: {
...(current.userExperience as any)?.[path],
...current.userExperience?.[path],
enabled: checked
}
}
@@ -70,7 +68,7 @@ export class ProjectEditorFeaturesSectionComponent {
productPage: {
...current.productPage,
[section]: {
...(current.productPage as any)?.[section],
...current.productPage?.[section],
enabled: checked
}
}