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) => 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. // SslCredentials is used here because this channel is using TLS.

View File

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

View File

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

View File

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

View File

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