From 2497cec1163ca298683e3b5435153cb13a0eed75 Mon Sep 17 00:00:00 2001 From: MeysamMoghaddam <65253484+MeysamMoghaddam@users.noreply.github.com> Date: Sun, 12 Oct 2025 18:16:59 +0330 Subject: [PATCH] u --- src/FrontOffice.Main/ConfigureServices.cs | 11 +- src/FrontOffice.Main/FrontOffice.Main.csproj | 1 + .../Pages/Profile/Index.razor | 474 +++++++++--------- .../Pages/Profile/Index.razor.cs | 33 +- src/FrontOffice.Main/_Imports.razor | 2 +- 5 files changed, 250 insertions(+), 271 deletions(-) diff --git a/src/FrontOffice.Main/ConfigureServices.cs b/src/FrontOffice.Main/ConfigureServices.cs index 4499cd4..9f07e21 100644 --- a/src/FrontOffice.Main/ConfigureServices.cs +++ b/src/FrontOffice.Main/ConfigureServices.cs @@ -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("auth:token"); + if (!string.IsNullOrWhiteSpace(token)) + { + metadata.Add("Authorization", $"Bearer {token}"); + } + } }); // SslCredentials is used here because this channel is using TLS. diff --git a/src/FrontOffice.Main/FrontOffice.Main.csproj b/src/FrontOffice.Main/FrontOffice.Main.csproj index de5e9d6..f268145 100644 --- a/src/FrontOffice.Main/FrontOffice.Main.csproj +++ b/src/FrontOffice.Main/FrontOffice.Main.csproj @@ -7,6 +7,7 @@ + diff --git a/src/FrontOffice.Main/Pages/Profile/Index.razor b/src/FrontOffice.Main/Pages/Profile/Index.razor index 57eb42f..7f2df06 100644 --- a/src/FrontOffice.Main/Pages/Profile/Index.razor +++ b/src/FrontOffice.Main/Pages/Profile/Index.razor @@ -14,268 +14,242 @@
@_userProfile.FirstName @_userProfile.LastName - @_userProfile.Email - عضو از @_userProfile.JoinDate -
- - - - - - - - - - -
- اطلاعات شخصی - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - لغو - - - ذخیره تغییرات - - - + @_userProfile.Mobile + عضو از @(_userProfile.MobileVerifiedAt?.ToDateTime().MiladiToJalali())
-
+ +
+
- - -
- تغییر رمز عبور + + + + + + +
+ اطلاعات شخصی - - - - - - - - - - - - - - - - - - لغو - - - تغییر رمز عبور - - - -
-
- - - -
- تنظیمات حساب - - - - - اعلان‌ها - - - - - - - - - - حریم خصوصی - - - - - - - - - زبان و تم + - - فارسی - English - + + - - روشن - تیره - خودکار - + + + + + + + + + - - - - لغو - - - ذخیره تنظیمات - - - -
-
- - - -
- آمار حساب کاربری - - - - - - @_userProfile.JoinDate - تاریخ عضویت - - - - - - - @_userProfile.LastLogin - آخرین ورود - - - - - - - @_userProfile.TotalReferrals - معرف‌ها - - - - - - - @_userProfile.Level - سطح کاربری - - - - - - - وضعیت حساب - - - - حساب تأیید شده + + + لغو + + + ذخیره تغییرات + - - - ایمیل تأیید شده + +
+
+ + + +
+ تغییر رمز عبور + + + + + + + + + + + + + + + + + + + لغو + + + تغییر رمز عبور + - - - شماره موبایل تأیید شده + +
+
+ + + +
+ تنظیمات حساب + + + + + اعلان‌ها + + + + + + + + + + حریم خصوصی + + + + + + + + + زبان و تم + + + + فارسی + English + + + + + روشن + تیره + خودکار + + + + + + + + لغو + + + ذخیره تنظیمات + - -
+
+
+ + + @* +
+ آمار حساب کاربری + + + + + + @_userProfile.JoinDate + تاریخ عضویت + + + + + + + @_userProfile.LastLogin + آخرین ورود + + + + + + + @_userProfile.TotalReferrals + معرف‌ها + + + + + + + @_userProfile.Level + سطح کاربری + + + + + + + وضعیت حساب + + + + حساب تأیید شده + + + + ایمیل تأیید شده + + + + شماره موبایل تأیید شده + + + +
- - - - - \ No newline at end of file + *@ + + + + + \ No newline at end of file diff --git a/src/FrontOffice.Main/Pages/Profile/Index.razor.cs b/src/FrontOffice.Main/Pages/Profile/Index.razor.cs index 7c2eb45..8e5e9f4 100644 --- a/src/FrontOffice.Main/Pages/Profile/Index.razor.cs +++ b/src/FrontOffice.Main/Pages/Profile/Index.razor.cs @@ -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 LoadUserProfile(); - await LoadAccountSettings(); + 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() diff --git a/src/FrontOffice.Main/_Imports.razor b/src/FrontOffice.Main/_Imports.razor index 50c7a9a..6a6ef6c 100644 --- a/src/FrontOffice.Main/_Imports.razor +++ b/src/FrontOffice.Main/_Imports.razor @@ -10,7 +10,7 @@ @using FrontOffice.Main.Shared @using MudBlazor @using FrontOffice.Main.Utilities - +@using DateTimeConverterCL @inject NavigationManager Navigation @inject IDialogService DialogService