Skip to content

Commit c97ac64

Browse files
committed
Add profile page
1 parent ee94264 commit c97ac64

3 files changed

Lines changed: 59 additions & 0 deletions

File tree

MyApp.Client/src/app/app.routes.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { MarkdownPageComponent } from './markdown-page.component';
77
import { SignInComponent } from './signin/signin.component';
88
import { SignUpComponent } from './signup/signup.component';
99
import { SignupConfirmComponent } from './signup/signup-confirm.component';
10+
import { ProfileComponent } from './profile/profile.component';
11+
import { authGuard } from 'src/guards';
1012

1113
import { BOOKING_ROUTES } from './bookings/booking.routes';
1214

@@ -18,6 +20,7 @@ export const routes: Routes = [
1820
{ path:'signin', component: SignInComponent },
1921
{ path:'signup', component: SignUpComponent },
2022
{ path:'signup-confirm', component: SignupConfirmComponent },
23+
{ path:'profile', component: ProfileComponent, canActivate: [authGuard] },
2124
{ path:'about', component: MarkdownPageComponent, data: { page: 'about.md' } },
2225
{ path:'privacy', component: MarkdownPageComponent, data: { page: 'privacy.md' } },
2326
...BOOKING_ROUTES,
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<app-page title="Profile">
2+
3+
<div class="flex flex-col items-center justify-center gap-2">
4+
<img class="w-36 h-36 text-gray-700 rounded-full" [src]="user()!.profileUrl" alt=""
5+
(error)="onIconError($event)" />
6+
@if (user()!.displayName != user()!.userName) {
7+
<div>{{user()!.displayName}}</div>
8+
}
9+
<div>{{user()!.userName}}</div>
10+
<div class="mt-2">
11+
@for (role of user()!.roles || []; track $index) {
12+
<span class="ml-3 inline-flex items-center px-3 py-0.5 rounded-full text-xs font-medium leading-5 bg-indigo-100 text-indigo-800">
13+
{{role}}
14+
</span>
15+
}
16+
</div>
17+
<secondary-button mat-button class="mt-8" (click)="signout()">Sign Out</secondary-button>
18+
</div>
19+
20+
<div class="mt-8 flex justify-center gap-x-4">
21+
<src-page path="profile/profile.component.html"></src-page>
22+
</div>
23+
</app-page>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { Component, computed, inject } from "@angular/core";
2+
import { PageComponent } from "../page.component";
3+
import { SrcPageComponent } from "src/shared/src-page.component";
4+
import { tailwindComponents } from "src/components";
5+
import { AuthService } from "src/services/auth.service";
6+
import { MetadataService } from "src/components/services/metadata.service";
7+
import { svgToDataUri } from "src/components/files";
8+
9+
@Component({
10+
selector: 'app-profile',
11+
templateUrl: './profile.component.html',
12+
imports: [
13+
PageComponent,
14+
SrcPageComponent,
15+
...tailwindComponents(),
16+
],
17+
})
18+
export class ProfileComponent {
19+
authService = inject(AuthService);
20+
meta = inject(MetadataService);
21+
user = computed(() => this.authService.user());
22+
23+
signout(): void {
24+
this.authService.signOut();
25+
}
26+
27+
onIconError(event: Event): void {
28+
const svg = this.meta.ui().userIcon?.svg
29+
if (svg) {
30+
(event.currentTarget as HTMLImageElement).src = svgToDataUri(svg);
31+
}
32+
}
33+
}

0 commit comments

Comments
 (0)