arch(sprint1): move UI env reads behind runtime facade

This commit is contained in:
sdarbinyan
2026-07-03 01:58:08 +04:00
parent 3cbb28a116
commit ae258382e1
9 changed files with 144 additions and 24 deletions

View File

@@ -0,0 +1,65 @@
import { Injectable, signal } from '@angular/core';
import { take } from 'rxjs/operators';
import { ConfigService } from '../../core/config/config.service';
import { environment } from '../../../environments/environment';
interface UiRuntimeState {
brandName: string;
brandFullName: string;
logoUrl: string;
contactEmail: string;
themeId: string;
}
@Injectable({ providedIn: 'root' })
export class UiRuntimeFacade {
private readonly state = signal<UiRuntimeState>({
brandName: environment.brandName,
brandFullName: environment.brandFullName,
logoUrl: environment.logo,
contactEmail: environment.contactEmail,
themeId: environment.theme
});
constructor(private readonly configService: ConfigService) {
this.configService.loadBootstrap().pipe(take(1)).subscribe({
next: (bootstrap) => {
this.state.set({
brandName: bootstrap.branding.brandName,
brandFullName: bootstrap.branding.brandName,
logoUrl: bootstrap.branding.logoUrl,
contactEmail: bootstrap.branding.supportEmail ?? environment.contactEmail,
themeId: bootstrap.theme.themeId
});
}
});
}
brandName(): string {
return this.state().brandName;
}
brandFullName(): string {
return this.state().brandFullName;
}
logoUrl(): string {
return this.state().logoUrl;
}
contactEmail(): string {
return this.state().contactEmail;
}
themeId(): string {
return this.state().themeId;
}
isNovo(): boolean {
return this.themeId().includes('novo');
}
isLavero(): boolean {
return this.themeId().includes('lavero');
}
}