u
This commit is contained in:
@@ -9,8 +9,8 @@
|
||||
<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" />
|
||||
<PackageReference Include="Foursat.FrontOffice.BFF.User.Protobuf" Version="0.0.115" />
|
||||
<PackageReference Include="Foursat.FrontOffice.BFF.UserAddress.Protobuf" Version="0.0.114" />
|
||||
<PackageReference Include="Foursat.FrontOffice.BFF.UserOrder.Protobuf" Version="0.0.112" />
|
||||
<PackageReference Include="MudBlazor" Version="7.16.0" />
|
||||
<PackageReference Include="Blazored.LocalStorage" Version="4.5.0" />
|
||||
|
||||
@@ -70,18 +70,14 @@
|
||||
<MudTextField @bind-Value="_updateUserRequest.FirstName"
|
||||
For="@(() => _updateUserRequest.FirstName)"
|
||||
Label="نام"
|
||||
Variant="Variant.Outlined"
|
||||
Required="true"
|
||||
RequiredError="وارد کردن نام الزامی است." />
|
||||
Variant="Variant.Outlined" />
|
||||
</MudItem>
|
||||
|
||||
<MudItem xs="12" md="6">
|
||||
<MudTextField @bind-Value="_updateUserRequest.LastName"
|
||||
For="@(() => _updateUserRequest.LastName)"
|
||||
Label="نام خانوادگی"
|
||||
Variant="Variant.Outlined"
|
||||
Required="true"
|
||||
RequiredError="وارد کردن نام خانوادگی الزامی است." />
|
||||
Variant="Variant.Outlined" />
|
||||
</MudItem>
|
||||
|
||||
<MudItem xs="12" md="6">
|
||||
@@ -91,6 +87,15 @@
|
||||
Variant="Variant.Outlined"
|
||||
InputType="InputType.Text" />
|
||||
</MudItem>
|
||||
|
||||
<MudItem xs="12" md="6">
|
||||
<MudDatePicker Label="تاریخ تولد"
|
||||
@bind-Date="_date"
|
||||
OpenTo="OpenTo.Year"
|
||||
Variant="Variant.Outlined"
|
||||
Culture="@Extensions.GetPersianCulture()"
|
||||
TitleDateFormat="dddd, dd MMMM" />
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
|
||||
<MudStack Row="true" Spacing="2" Justify="Justify.FlexEnd" Class="mt-4">
|
||||
@@ -103,21 +108,29 @@
|
||||
</MudTabPanel>
|
||||
|
||||
<!-- Account Settings Tab -->
|
||||
@* <MudTabPanel Text="تنظیمات حساب" Icon="@Icons.Material.Filled.Settings">
|
||||
<MudTabPanel Text="تنظیمات حساب" Icon="@Icons.Material.Filled.Settings">
|
||||
<div class="pa-4">
|
||||
<MudText Typo="Typo.h6" Class="mb-4 mud-typography-subtitle1">تنظیمات حساب</MudText>
|
||||
|
||||
<MudStack Spacing="4">
|
||||
<!-- Notification Settings -->
|
||||
<MudPaper Outlined="true" Class="pa-4 rounded-lg">
|
||||
<MudText Typo="Typo.subtitle1" Class="mb-3 fw-600">اعلانها</MudText>
|
||||
<MudStack Spacing="2">
|
||||
<MudSwitch T="bool" @bind-Checked="_settings.EmailNotifications" Label="اعلانهای ایمیلی" />
|
||||
<MudSwitch T="bool" @bind-Checked="_settings.SmsNotifications" Label="اعلانهای پیامکی" />
|
||||
<MudSwitch T="bool" @bind-Checked="_settings.PushNotifications" Label="اعلانهای پوش" />
|
||||
<MudSwitch T="bool"
|
||||
@bind-Value="_updateUserRequest.EmailNotifications"
|
||||
Color="Color.Primary"
|
||||
Label="اعلانهای ایمیلی" />
|
||||
<MudSwitch T="bool"
|
||||
@bind-Value="_updateUserRequest.SmsNotifications"
|
||||
Color="Color.Primary"
|
||||
Label="اعلانهای پیامکی" />
|
||||
<MudSwitch T="bool"
|
||||
@bind-Value="_updateUserRequest.PushNotifications"
|
||||
Color="Color.Primary"
|
||||
Label="اعلانهای پوش" />
|
||||
</MudStack>
|
||||
</MudPaper>
|
||||
|
||||
@*
|
||||
<!-- Privacy Settings -->
|
||||
<MudPaper Outlined="true" Class="pa-4 rounded-lg">
|
||||
<MudText Typo="Typo.subtitle1" Class="mb-3 fw-600">حریم خصوصی</MudText>
|
||||
@@ -145,19 +158,16 @@
|
||||
</MudSelect>
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
</MudPaper>
|
||||
</MudPaper> *@
|
||||
|
||||
<MudStack Row="true" Spacing="2" Justify="Justify.FlexEnd">
|
||||
<MudButton Variant="Variant.Outlined" Color="Color.Secondary" OnClick="CancelSettingsChanges">
|
||||
لغو
|
||||
</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="SaveSettings" Disabled="_isSettingsSaving">
|
||||
ذخیره تنظیمات
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
</MudStack>
|
||||
</div>
|
||||
</MudTabPanel> *@
|
||||
</MudTabPanel>
|
||||
|
||||
<!-- Statistics Tab -->
|
||||
@* <MudTabPanel Text="آمار و اطلاعات" Icon="@Icons.Material.Filled.BarChart">
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using FluentValidation;
|
||||
using FrontOffice.BFF.User.Protobuf.Protos.User;
|
||||
using FrontOffice.Main.Utilities;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.JSInterop;
|
||||
@@ -24,14 +25,13 @@ public partial class Index
|
||||
private string _copyMessage = string.Empty;
|
||||
|
||||
private readonly UserProfileValidator _personalValidator = new();
|
||||
|
||||
private DateTime? _date;
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
await base.OnAfterRenderAsync(firstRender);
|
||||
if (firstRender)
|
||||
{
|
||||
await LoadUserProfile();
|
||||
await LoadAccountSettings();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,8 @@ public partial class Index
|
||||
{
|
||||
_userProfile = await UserContract.GetUserAsync(request: new());
|
||||
_updateUserRequest = _userProfile.Adapt<UpdateUserRequest>();
|
||||
if (_userProfile.BirthDate != null)
|
||||
_date = _userProfile.BirthDate.ToDateTime();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -51,21 +53,6 @@ public partial class Index
|
||||
}
|
||||
|
||||
|
||||
private async Task LoadAccountSettings()
|
||||
{
|
||||
// TODO: Load settings from API
|
||||
//_settings = new AccountSettings
|
||||
//{
|
||||
// EmailNotifications = true,
|
||||
// SmsNotifications = true,
|
||||
// PushNotifications = false,
|
||||
// ProfileVisibility = true,
|
||||
// ShowOnlineStatus = true,
|
||||
// Language = "fa",
|
||||
// Theme = "light"
|
||||
//};
|
||||
}
|
||||
|
||||
private async Task SavePersonalInfo()
|
||||
{
|
||||
if (_personalForm is null) return;
|
||||
@@ -77,6 +64,9 @@ public partial class Index
|
||||
|
||||
try
|
||||
{
|
||||
if (_date != null)
|
||||
_updateUserRequest.BirthDate = _date.Value.DateTimeToTimestamp();
|
||||
|
||||
await UserContract.UpdateUserAsync(request: _updateUserRequest);
|
||||
await LoadUserProfile();
|
||||
Snackbar.Add("اطلاعات شخصی با موفقیت ذخیره شد.", Severity.Success);
|
||||
@@ -105,8 +95,8 @@ public partial class Index
|
||||
|
||||
try
|
||||
{
|
||||
// TODO: Save settings to API
|
||||
await Task.Delay(1000); // Simulate API call
|
||||
|
||||
await SavePersonalInfo();
|
||||
|
||||
Snackbar.Add("تنظیمات با موفقیت ذخیره شد.", Severity.Success);
|
||||
}
|
||||
@@ -121,12 +111,6 @@ public partial class Index
|
||||
}
|
||||
}
|
||||
|
||||
private void CancelSettingsChanges()
|
||||
{
|
||||
// TODO: Reset settings to original values
|
||||
Snackbar.Add("تغییرات تنظیمات لغو شد.", Severity.Info);
|
||||
}
|
||||
|
||||
private async Task CopyReferralCode()
|
||||
{
|
||||
try
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Globalization;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
@@ -9,6 +10,38 @@ namespace FrontOffice.Main.Utilities;
|
||||
|
||||
public static class Extensions
|
||||
{
|
||||
public static CultureInfo GetPersianCulture()
|
||||
{
|
||||
var culture = new CultureInfo("fa-IR");
|
||||
DateTimeFormatInfo formatInfo = culture.DateTimeFormat;
|
||||
formatInfo.AbbreviatedDayNames = new[] { "ی", "د", "س", "چ", "پ", "ج", "ش" };
|
||||
formatInfo.DayNames = new[] { "یکشنبه", "دوشنبه", "سه شنبه", "چهار شنبه", "پنجشنبه", "جمعه", "شنبه" };
|
||||
var monthNames = new[]
|
||||
{
|
||||
"فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن",
|
||||
"اسفند",
|
||||
"",
|
||||
};
|
||||
formatInfo.AbbreviatedMonthNames =
|
||||
formatInfo.MonthNames =
|
||||
formatInfo.MonthGenitiveNames = formatInfo.AbbreviatedMonthGenitiveNames = monthNames;
|
||||
formatInfo.AMDesignator = "ق.ظ";
|
||||
formatInfo.PMDesignator = "ب.ظ";
|
||||
formatInfo.ShortDatePattern = "yyyy/MM/dd";
|
||||
formatInfo.LongDatePattern = "dddd, dd MMMM,yyyy";
|
||||
formatInfo.FirstDayOfWeek = DayOfWeek.Saturday;
|
||||
Calendar cal = new PersianCalendar();
|
||||
FieldInfo fieldInfo = culture.GetType().GetField("calendar", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
if (fieldInfo != null)
|
||||
fieldInfo.SetValue(culture, cal);
|
||||
FieldInfo info = formatInfo.GetType().GetField("calendar", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
if (info != null)
|
||||
info.SetValue(formatInfo, cal);
|
||||
culture.NumberFormat.NumberDecimalSeparator = "/";
|
||||
culture.NumberFormat.DigitSubstitution = DigitShapes.NativeNational;
|
||||
culture.NumberFormat.NumberNegativePattern = 0;
|
||||
return culture;
|
||||
}
|
||||
public static string ExtractUserFriendlyMessage(this string errorMessage)
|
||||
{
|
||||
// کلیدواژهای که بعد از آن بخش مورد نظر شروع میشود
|
||||
|
||||
Reference in New Issue
Block a user