@page "/settings/profile" @using Iceshrimp.Assets.PhosphorIcons @using Iceshrimp.Frontend.Components @using Iceshrimp.Frontend.Core.Miscellaneous @using Iceshrimp.Frontend.Core.Services @using Iceshrimp.Frontend.Localization @using Iceshrimp.Shared.Schemas.Web @using Microsoft.AspNetCore.Authorization @using Microsoft.Extensions.Localization @using Microsoft.AspNetCore.Components.Sections @attribute [Authorize] @layout SettingsLayout @inject ApiService Api; @inject ILogger Logger; @inject IStringLocalizer Loc; @Loc["Profile"]
@if (State is State.Loaded) {

@Loc["Profile Description"]

@Loc["Birthday"]

@Loc["Location"]

@Loc["Fields"]

@foreach (var entry in UserProfile.Fields) {
}
@Loc["Save"] @Loc["Error"] @Loc["Saved"]
} @if (State is State.Loading) {
Loading!
}
@code { private UserProfileEntity UserProfile { get; set; } = null!; private State State { get; set; } = State.Loading; private string FieldName { get; set; } = ""; private string FieldValue { get; set; } = ""; private StateButton SaveButton { get; set; } = null!; protected override async Task OnInitializedAsync() { try { UserProfile = await Api.Profile.GetProfileAsync(); State = State.Loaded; } catch (ApiException e) { Logger.LogError($"Profile load failed: {e.Message}"); State = State.Error; } } private void AddField() { UserProfile.Fields.Add(new UserProfileEntity.Field { Name = FieldName, Value = FieldValue }); FieldName = ""; FieldValue = ""; } private void DeleteField(UserProfileEntity.Field field) { UserProfile.Fields.Remove(field); } private async Task SaveChanges() { try { SaveButton.State = StateButton.StateEnum.Loading; await Api.Profile.UpdateProfileAsync(UserProfile); SaveButton.State = StateButton.StateEnum.Success; } catch (ApiException e) { Logger.LogError($"Failed to update profile: {e.Message}"); SaveButton.State = StateButton.StateEnum.Failed; } } }