-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update user settings component for profile editing
- Loading branch information
Showing
5 changed files
with
62 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export interface UserUpdateRequest { | ||
description: string | undefined; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,15 @@ | ||
<page-header class="text-3xl">Settings</page-header> | ||
<page-header class="text-3xl">Profile Settings</page-header> | ||
|
||
<div class="w-28 text-center"> | ||
<secondary-button text="Log out" routerLink="/logout"></secondary-button> | ||
</div> | ||
<form-input [icon]="faPencil" [name]="'Biography'" [id]="descriptionId"></form-input> | ||
|
||
<div class="w-44 text-center inline-block pr-2.5"> | ||
<primary-button text="Save changes" (click)="saveChanges()"></primary-button> | ||
</div> | ||
|
||
<div class="w-28 text-center inline-block pr-2.5"> | ||
<secondary-button text="Cancel" onclick="window.history.back()"></secondary-button> | ||
</div> | ||
|
||
<div class="w-28 text-center inline-block pr-2.5"> | ||
<dangerous-button text="Log out" routerLink="/logout"></dangerous-button> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,41 @@ | ||
import { Component } from '@angular/core'; | ||
import {Component, OnInit} from '@angular/core'; | ||
import {faPencil} from "@fortawesome/free-solid-svg-icons/faPencil"; | ||
import {ApiClient} from "../../api/api-client"; | ||
import {User} from "../../api/types/user"; | ||
import {UserUpdateRequest} from "../../api/types/user-update-request"; | ||
|
||
@Component({ | ||
selector: 'app-settings', | ||
templateUrl: './settings.component.html', | ||
}) | ||
export class SettingsComponent { | ||
export class SettingsComponent implements OnInit { | ||
descriptionId: string = "settings-description"; | ||
|
||
protected readonly faPencil = faPencil; | ||
|
||
constructor(private apiClient: ApiClient) { | ||
} | ||
|
||
ngOnInit(): void { | ||
this.apiClient.userWatcher.subscribe((data) => { | ||
this.updateInputs(data); | ||
}) | ||
// FIXME: this is stupid | ||
setTimeout(() => {this.updateInputs(this.apiClient.user);}, 0); | ||
} | ||
|
||
updateInputs(data: User | undefined) { | ||
const descriptionInput: HTMLInputElement = (<HTMLInputElement>document.getElementById(this.descriptionId)); | ||
descriptionInput.value = data?.description ?? ""; | ||
} | ||
|
||
saveChanges() { | ||
const descriptionInput: HTMLInputElement = (<HTMLInputElement>document.getElementById(this.descriptionId)); | ||
|
||
let request: UserUpdateRequest = { | ||
description: descriptionInput.value | ||
}; | ||
|
||
this.apiClient.UpdateUser(request); | ||
} | ||
} |