arch(sprint1): move UI env reads behind runtime facade
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { Component, ChangeDetectionStrategy, inject } from '@angular/core';
|
||||
import { Location } from '@angular/common';
|
||||
import { environment } from '../../../environments/environment';
|
||||
import { TranslateService } from '../../i18n/translate.service';
|
||||
import { UiRuntimeFacade } from '../../facades/runtime/ui-runtime.facade';
|
||||
|
||||
@Component({
|
||||
selector: 'app-back-button',
|
||||
@@ -62,9 +62,13 @@ import { TranslateService } from '../../i18n/translate.service';
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
})
|
||||
export class BackButtonComponent {
|
||||
isnovo = environment.theme === 'novo';
|
||||
private readonly uiRuntime = inject(UiRuntimeFacade);
|
||||
i18n = inject(TranslateService);
|
||||
|
||||
get isnovo(): boolean {
|
||||
return this.uiRuntime.isNovo();
|
||||
}
|
||||
|
||||
constructor(private location: Location) {}
|
||||
|
||||
goBack(): void {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Component, ChangeDetectionStrategy } from '@angular/core';
|
||||
import { RouterLink } from '@angular/router';
|
||||
import { environment } from '../../../environments/environment';
|
||||
import { LangRoutePipe } from '../../pipes/lang-route.pipe';
|
||||
import { TranslatePipe } from '../../i18n/translate.pipe';
|
||||
import { LogoComponent } from '../logo/logo.component';
|
||||
import { UiRuntimeFacade } from '../../facades/runtime/ui-runtime.facade';
|
||||
|
||||
@Component({
|
||||
selector: 'app-footer',
|
||||
@@ -13,9 +13,23 @@ import { LogoComponent } from '../logo/logo.component';
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
})
|
||||
export class FooterComponent {
|
||||
constructor(private readonly uiRuntime: UiRuntimeFacade) {}
|
||||
|
||||
currentYear = new Date().getFullYear();
|
||||
brandName = environment.brandName;
|
||||
contactEmail = environment.contactEmail;
|
||||
isnovo = environment.theme === 'novo';
|
||||
islavero = environment.theme === 'lavero';
|
||||
|
||||
get brandName(): string {
|
||||
return this.uiRuntime.brandName();
|
||||
}
|
||||
|
||||
get contactEmail(): string {
|
||||
return this.uiRuntime.contactEmail();
|
||||
}
|
||||
|
||||
get isnovo(): boolean {
|
||||
return this.uiRuntime.isNovo();
|
||||
}
|
||||
|
||||
get islavero(): boolean {
|
||||
return this.uiRuntime.isLavero();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,12 @@ import { Component, ChangeDetectionStrategy, Renderer2, inject, DOCUMENT } from
|
||||
import { Router, RouterLink, RouterLinkActive } from '@angular/router';
|
||||
import { CartService } from '../../services/cart.service';
|
||||
import { LanguageService } from '../../services/language.service';
|
||||
import { environment } from '../../../environments/environment';
|
||||
import { LogoComponent } from '../logo/logo.component';
|
||||
import { LanguageSelectorComponent } from '../language-selector/language-selector.component';
|
||||
import { RegionSelectorComponent } from '../region-selector/region-selector.component';
|
||||
import { LangRoutePipe } from '../../pipes/lang-route.pipe';
|
||||
import { TranslatePipe } from '../../i18n/translate.pipe';
|
||||
import { UiRuntimeFacade } from '../../facades/runtime/ui-runtime.facade';
|
||||
|
||||
@Component({
|
||||
selector: 'app-header',
|
||||
@@ -20,19 +20,29 @@ export class HeaderComponent {
|
||||
cartItemCount;
|
||||
cartTotal;
|
||||
menuOpen = false;
|
||||
brandName = environment.brandFullName;
|
||||
logo = environment.logo;
|
||||
isnovo = environment.theme === 'novo';
|
||||
|
||||
private renderer = inject(Renderer2);
|
||||
private document = inject(DOCUMENT);
|
||||
private langService = inject(LanguageService);
|
||||
private uiRuntime = inject(UiRuntimeFacade);
|
||||
|
||||
constructor(private cartService: CartService, private router: Router) {
|
||||
this.cartItemCount = this.cartService.itemCount;
|
||||
this.cartTotal = this.cartService.totalPrice;
|
||||
}
|
||||
|
||||
get brandName(): string {
|
||||
return this.uiRuntime.brandFullName();
|
||||
}
|
||||
|
||||
get logo(): string {
|
||||
return this.uiRuntime.logoUrl();
|
||||
}
|
||||
|
||||
get isnovo(): boolean {
|
||||
return this.uiRuntime.isNovo();
|
||||
}
|
||||
|
||||
get homeUrl(): string {
|
||||
return `/${this.langService.currentLanguage()}`;
|
||||
}
|
||||
|
||||
@@ -6,11 +6,11 @@ import { ButtonModule } from 'primeng/button';
|
||||
import { TagModule } from 'primeng/tag';
|
||||
import { ApiService, CartService } from '../../services';
|
||||
import { Item } from '../../models';
|
||||
import { environment } from '../../../environments/environment';
|
||||
import { getDiscountedPrice, getMainImage, getBadgeClass, getTranslatedField } from '../../utils/item.utils';
|
||||
import { LanguageService } from '../../services/language.service';
|
||||
import { LangRoutePipe } from '../../pipes/lang-route.pipe';
|
||||
import { TranslatePipe } from '../../i18n/translate.pipe';
|
||||
import { UiRuntimeFacade } from '../../facades/runtime/ui-runtime.facade';
|
||||
|
||||
@Component({
|
||||
selector: 'app-items-carousel',
|
||||
@@ -22,7 +22,7 @@ import { TranslatePipe } from '../../i18n/translate.pipe';
|
||||
export class ItemsCarouselComponent implements OnInit {
|
||||
products = signal<Item[]>([]);
|
||||
loading = signal(true);
|
||||
isnovo = environment.theme === 'novo';
|
||||
private readonly uiRuntime = inject(UiRuntimeFacade);
|
||||
|
||||
responsiveOptions: { breakpoint: string; numVisible: number; numScroll: number }[] | undefined;
|
||||
|
||||
@@ -102,6 +102,7 @@ export class ItemsCarouselComponent implements OnInit {
|
||||
readonly getBadgeClass = getBadgeClass;
|
||||
|
||||
private langService = inject(LanguageService);
|
||||
get isnovo(): boolean { return this.uiRuntime.isNovo(); }
|
||||
itemName(product: Item): string { return getTranslatedField(product, 'name', this.langService.currentLanguage()); }
|
||||
|
||||
addToCart(event: Event, item: Item): void {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Component, ChangeDetectionStrategy } from '@angular/core';
|
||||
import { environment } from '../../../environments/environment';
|
||||
import { UiRuntimeFacade } from '../../facades/runtime/ui-runtime.facade';
|
||||
|
||||
@Component({
|
||||
selector: 'app-logo',
|
||||
@@ -17,6 +17,13 @@ import { environment } from '../../../environments/environment';
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
})
|
||||
export class LogoComponent {
|
||||
brandName = environment.brandName;
|
||||
logoPath = (environment as any).logo ?? `/assets/images/${environment.theme}-logo.svg`;
|
||||
constructor(private readonly uiRuntime: UiRuntimeFacade) {}
|
||||
|
||||
get brandName(): string {
|
||||
return this.uiRuntime.brandName();
|
||||
}
|
||||
|
||||
get logoPath(): string {
|
||||
return this.uiRuntime.logoUrl();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user