arch(sprint1): move UI env reads behind runtime facade
This commit is contained in:
65
src/app/facades/runtime/ui-runtime.facade.ts
Normal file
65
src/app/facades/runtime/ui-runtime.facade.ts
Normal 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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user