Conectar dialog by kind of source; plain-language canvas; login page and guard; loading indicators as the old app; survival curves of her clinical scenarios in the CaMa record
This commit is contained in:
+14
-1
@@ -8,6 +8,7 @@ import { filter, map } from 'rxjs';
|
||||
import { Api } from './api/api';
|
||||
import { domains } from './api/fn/operations/domains';
|
||||
import { Domain } from './api/models/domain';
|
||||
import { Auth } from './auth/auth';
|
||||
|
||||
export const DOMAINS: Record<Domain, string> = {
|
||||
cacu: 'Cáncer cervicouterino',
|
||||
@@ -32,6 +33,7 @@ export const DOMAINS: Record<Domain, string> = {
|
||||
export class App {
|
||||
private readonly api = inject(Api);
|
||||
private readonly router = inject(Router);
|
||||
protected readonly auth = inject(Auth);
|
||||
protected readonly labels = DOMAINS;
|
||||
protected readonly domains = resource({ loader: () => this.api.invoke(domains) });
|
||||
private readonly url = toSignal(
|
||||
@@ -46,6 +48,17 @@ export class App {
|
||||
() => /^\/indicadores\/(\w+)/.exec(this.url())?.[1] as Domain | undefined,
|
||||
);
|
||||
protected readonly others = computed(() =>
|
||||
(this.domains.value() ?? []).filter((d) => d !== this.domain()),
|
||||
(this.domains.value() ?? []).filter((d) => d !== this.domain() && this.auth.canSee(d)),
|
||||
);
|
||||
/** The sign-in page shows only the brand. */
|
||||
protected readonly onLogin = computed(() => this.url().startsWith('/login'));
|
||||
/** Where "Indicadores" goes: the first domain this user may see. */
|
||||
protected readonly home = computed(
|
||||
() => `/indicadores/${this.auth.user()?.domains[0] ?? 'cacu'}`,
|
||||
);
|
||||
|
||||
protected async logout(): Promise<void> {
|
||||
await this.auth.logout();
|
||||
await this.router.navigateByUrl('/login');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user