Iceshrimp.NET/Iceshrimp.Frontend/Components/UserProfileCard.razor

75 lines
No EOL
2.5 KiB
Text

@using Iceshrimp.Frontend.Core.Services
@using Iceshrimp.Frontend.Localization
@using Iceshrimp.Shared.Schemas.Web
@using Microsoft.Extensions.Localization
@inject ApiService Api;
@inject NavigationManager NavigationManager;
@inject IStringLocalizer<Localization> Loc;
@if (UserProfile != null)
{
<div @onclick="Open" class="profile-card">
<div class="header">
<div>
<UserAvatar User="@User"/>
</div>
<div class="name-section">
<div class="name">
<UserDisplayName User="@User"/>
</div>
<div class="identifier">
@@@User.Username
@if (User.Host != null)
{
var host = $"@{User.Host}";
@host
}
</div>
<div class="metadata">
<div class="section">
<div class="field-data">
@UserProfile.Followers
</div>
<div class="field-text">
@Loc["Followers"]
</div>
</div>
<div class="section">
<div class="field-data">
@UserProfile.Following
</div>
<div class="field-text">
@Loc["Following"]
</div>
</div>
</div>
</div>
</div>
@if (ShowBio)
{
@if (UserProfile.Bio != null)
{
<div class="bio">
<MfmText Text="@UserProfile.Bio" Emoji="@User.Emojis"/>
</div>
}
}
</div>
}
@code {
[Parameter] [EditorRequired] public required UserResponse User { get; set; }
private UserProfileResponse? UserProfile { get; set; }
[Parameter] public bool ShowBio { get; set; } = true;
protected override async Task OnInitializedAsync()
{
UserProfile = await Api.Users.GetUserProfileAsync(User.Id);
}
private void Open()
{
var username = $"@{User.Username}";
if (User.Host != null) username += $"@{User.Host}";
NavigationManager.NavigateTo($"/{username}");
}
}