-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Expand file tree
/
Copy pathlogin.component.ts
More file actions
39 lines (35 loc) · 1.31 KB
/
login.component.ts
File metadata and controls
39 lines (35 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { Component, inject } from '@angular/core';
import { RouterLink } from '@angular/router';
import { ButtonComponent } from './button.component';
import { InformationComponent } from './information.component';
import { USERS_MAP, UserType } from './user.model';
import { UserStore } from './user.store';
@Component({
imports: [InformationComponent, RouterLink, ButtonComponent],
selector: 'app-login',
template: `
<header class="flex items-center gap-3">
Log as :
<button app-button (click)="loginAs('admin')">Admin</button>
<button app-button (click)="loginAs('manager')">Manager</button>
<button app-button (click)="loginAs('reader')">Reader</button>
<button app-button (click)="loginAs('writer')">Writer</button>
<button app-button (click)="loginAs('readerAndWriter')">
Reader and Writer
</button>
<button app-button (click)="loginAs('client')">Client</button>
<button app-button (click)="loginAs('everyone')">Everyone</button>
</header>
<app-information />
<button app-button class="mt-10" routerLink="enter">
Enter application
</button>
`,
})
export class LoginComponent {
private readonly userStore = inject(UserStore);
loginAs(userType: UserType) {
const user = USERS_MAP[userType];
this.userStore.setUser(user);
}
}