This commit is contained in:
MeysamMoghaddam
2025-10-12 18:16:59 +03:30
parent 707eac088a
commit 2497cec116
5 changed files with 250 additions and 271 deletions

View File

@@ -50,7 +50,16 @@ public static class ConfigureServices
{
var credentials = CallCredentials.FromInterceptor(async (context, metadata) =>
{
await Task.CompletedTask;
// Get token from local storage if available
var localStorage = serviceProvider.GetService(typeof(ILocalStorageService)) as ILocalStorageService;
if (localStorage != null)
{
var token = await localStorage.GetItemAsync<string>("auth:token");
if (!string.IsNullOrWhiteSpace(token))
{
metadata.Add("Authorization", $"Bearer {token}");
}
}
});
// SslCredentials is used here because this channel is using TLS.

View File

@@ -7,6 +7,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DateTimeConverterCL" Version="1.0.0" />
<PackageReference Include="Foursat.FrontOffice.BFF.Package.Protobuf" Version="0.0.112" />
<PackageReference Include="Foursat.FrontOffice.BFF.User.Protobuf" Version="0.0.113" />
<PackageReference Include="Foursat.FrontOffice.BFF.UserAddress.Protobuf" Version="0.0.112" />

View File

@@ -14,8 +14,8 @@
</MudAvatar>
<div>
<MudText Typo="Typo.h5" Class="mud-typography-subtitle1">@_userProfile.FirstName @_userProfile.LastName</MudText>
<MudText Typo="Typo.body2" Class="mud-text-secondary">@_userProfile.Email</MudText>
<MudText Typo="Typo.caption" Class="mud-text-secondary">عضو از @_userProfile.JoinDate</MudText>
<MudText Typo="Typo.body2" Class="mud-text-secondary">@_userProfile.Mobile</MudText>
<MudText Typo="Typo.caption" Class="mud-text-secondary">عضو از @(_userProfile.MobileVerifiedAt?.ToDateTime().MiladiToJalali())</MudText>
</div>
</MudStack>
</MudPaper>
@@ -51,18 +51,8 @@
</MudItem>
<MudItem xs="12" md="6">
<MudTextField @bind-Value="_userProfile.Email"
For="@(() => _userProfile.Email)"
Label="ایمیل"
Variant="Variant.Outlined"
InputType="InputType.Email"
Required="true"
RequiredError="وارد کردن ایمیل الزامی است." />
</MudItem>
<MudItem xs="12" md="6">
<MudTextField @bind-Value="_userProfile.PhoneNumber"
For="@(() => _userProfile.PhoneNumber)"
<MudTextField @bind-Value="_userProfile.Mobile"
For="@(() => _userProfile.Mobile)"
Label="شماره موبایل"
Variant="Variant.Outlined"
InputType="InputType.Text"
@@ -77,23 +67,6 @@
Variant="Variant.Outlined"
InputType="InputType.Text" />
</MudItem>
<MudItem xs="12" md="6">
<MudTextField @bind-Value="_userProfile.BirthDate"
For="@(() => _userProfile.BirthDate)"
Label="تاریخ تولد"
Variant="Variant.Outlined"
InputType="InputType.Date" />
</MudItem>
<MudItem xs="12">
<MudTextField @bind-Value="_userProfile.Address"
For="@(() => _userProfile.Address)"
Label="آدرس"
Variant="Variant.Outlined"
Lines="3"
InputType="InputType.Text" />
</MudItem>
</MudGrid>
<MudStack Row="true" Spacing="2" Justify="Justify.FlexEnd" Class="mt-4">
@@ -216,7 +189,7 @@
</MudTabPanel>
<!-- Statistics Tab -->
<MudTabPanel Text="آمار و اطلاعات" Icon="@Icons.Material.Filled.BarChart">
@* <MudTabPanel Text="آمار و اطلاعات" Icon="@Icons.Material.Filled.BarChart">
<div class="pa-4">
<MudText Typo="Typo.h6" Class="mb-4 mud-typography-subtitle1">آمار حساب کاربری</MudText>
@@ -274,8 +247,9 @@
</MudPaper>
</div>
</MudTabPanel>
*@
</MudTabs>
</MudPaper>
</MudItem>
</MudGrid>
</MudContainer>
</MudContainer>

View File

@@ -1,4 +1,6 @@
using FluentValidation;
using FrontOffice.BFF.Package.Protobuf.Protos.Package;
using FrontOffice.BFF.User.Protobuf.Protos.User;
using FrontOffice.Main.Utilities;
using Microsoft.AspNetCore.Components;
using MudBlazor;
@@ -9,7 +11,9 @@ namespace FrontOffice.Main.Pages.Profile;
public partial class Index
{
private UserProfile _userProfile = new();
[Inject] private UserContract.UserContractClient UserContract { get; set; } = default!;
private GetUserResponse _userProfile = new();
private PasswordChangeModel _passwordModel = new();
private AccountSettings _settings = new();
@@ -23,29 +27,20 @@ public partial class Index
private readonly UserProfileValidator _personalValidator = new();
private readonly PasswordChangeValidator _passwordValidator = new();
protected override async Task OnInitializedAsync()
protected override async Task OnAfterRenderAsync(bool firstRender)
{
await base.OnAfterRenderAsync(firstRender);
if(firstRender)
{
await LoadUserProfile();
await LoadAccountSettings();
}
}
private async Task LoadUserProfile()
{
// TODO: Load user profile from API
_userProfile = new UserProfile
{
FirstName = "علی",
LastName = "احمدی",
Email = "ali.ahmad@example.com",
PhoneNumber = "09123456789",
NationalCode = "0123456789",
BirthDate = "1370/01/01",
Address = "تهران، خیابان ولیعصر",
JoinDate = "۱۴۰۲/۰۱/۱۵",
LastLogin = "۱۴۰۲/۱۰/۰۶",
TotalReferrals = 25,
Level = "طلایی"
};
_userProfile = await UserContract.GetUserAsync(request: new());
StateHasChanged();
}
private async Task LoadAccountSettings()

View File

@@ -10,7 +10,7 @@
@using FrontOffice.Main.Shared
@using MudBlazor
@using FrontOffice.Main.Utilities
@using DateTimeConverterCL
@inject NavigationManager Navigation
@inject IDialogService DialogService