[frontend] Add display name to profile settings
This commit is contained in:
parent
6605997e80
commit
95cd3d2d33
2 changed files with 12 additions and 0 deletions
|
@ -10,4 +10,10 @@ internal class ProfileControllerModel(ApiClient api)
|
||||||
|
|
||||||
public Task UpdateProfileAsync(UserProfileEntity request) =>
|
public Task UpdateProfileAsync(UserProfileEntity request) =>
|
||||||
api.CallAsync(HttpMethod.Put, "/profile", data: request);
|
api.CallAsync(HttpMethod.Put, "/profile", data: request);
|
||||||
|
|
||||||
|
public Task<string?> GetDisplayNameAsync() =>
|
||||||
|
api.CallNullableAsync<string>(HttpMethod.Get, "/profile/display_name");
|
||||||
|
|
||||||
|
public Task<string?> UpdateDisplayNameAsync(string displayName) =>
|
||||||
|
api.CallNullableAsync<string>(HttpMethod.Post, "/profile/display_name", data: displayName);
|
||||||
}
|
}
|
|
@ -22,6 +22,9 @@
|
||||||
<div class="body">
|
<div class="body">
|
||||||
@if (State is State.Loaded)
|
@if (State is State.Loaded)
|
||||||
{
|
{
|
||||||
|
<div class="section">
|
||||||
|
<h3>@Loc["Display Name"]</h3><input class="input" @bind="@DisplayName"></input>
|
||||||
|
</div>
|
||||||
<div class="section">
|
<div class="section">
|
||||||
<h3>@Loc["Profile Description"]</h3><textarea class="input" @bind="@UserProfile.Description"></textarea>
|
<h3>@Loc["Profile Description"]</h3><textarea class="input" @bind="@UserProfile.Description"></textarea>
|
||||||
</div>
|
</div>
|
||||||
|
@ -84,6 +87,7 @@
|
||||||
private string FieldName { get; set; } = "";
|
private string FieldName { get; set; } = "";
|
||||||
private string FieldValue { get; set; } = "";
|
private string FieldValue { get; set; } = "";
|
||||||
private StateButton SaveButton { get; set; } = null!;
|
private StateButton SaveButton { get; set; } = null!;
|
||||||
|
private string DisplayName { get; set; } = "";
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
|
@ -91,6 +95,7 @@
|
||||||
{
|
{
|
||||||
UserProfile = await Api.Profile.GetProfileAsync();
|
UserProfile = await Api.Profile.GetProfileAsync();
|
||||||
State = State.Loaded;
|
State = State.Loaded;
|
||||||
|
DisplayName = await Api.Profile.GetDisplayNameAsync() ?? "";
|
||||||
}
|
}
|
||||||
catch (ApiException e)
|
catch (ApiException e)
|
||||||
{
|
{
|
||||||
|
@ -117,6 +122,7 @@
|
||||||
{
|
{
|
||||||
SaveButton.State = StateButton.StateEnum.Loading;
|
SaveButton.State = StateButton.StateEnum.Loading;
|
||||||
await Api.Profile.UpdateProfileAsync(UserProfile);
|
await Api.Profile.UpdateProfileAsync(UserProfile);
|
||||||
|
await Api.Profile.UpdateDisplayNameAsync(DisplayName);
|
||||||
SaveButton.State = StateButton.StateEnum.Success;
|
SaveButton.State = StateButton.StateEnum.Success;
|
||||||
}
|
}
|
||||||
catch (ApiException e)
|
catch (ApiException e)
|
||||||
|
|
Loading…
Add table
Reference in a new issue