Add OtpDialogService for mobile-friendly OTP authentication dialog
This commit is contained in:
73
src/FrontOffice.Main/Pages/Profile/Addresses.razor
Normal file
73
src/FrontOffice.Main/Pages/Profile/Addresses.razor
Normal file
@@ -0,0 +1,73 @@
|
||||
@attribute [Route(RouteConstants.Profile.Addresses)]
|
||||
|
||||
<PageTitle>آدرسها</PageTitle>
|
||||
|
||||
<MudContainer MaxWidth="MaxWidth.Large" Class="py-6">
|
||||
<MudStack Spacing="3">
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center">
|
||||
<MudText Typo="Typo.h5">مدیریت آدرسها</MudText>
|
||||
<MudButton Variant="Variant.Text" StartIcon="@Icons.Material.Filled.ArrowBack" Href="@RouteConstants.Profile.Index">بازگشت</MudButton>
|
||||
</MudStack>
|
||||
|
||||
<MudPaper Elevation="2" Class="pa-4 rounded-lg">
|
||||
<MudStack Spacing="4">
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center">
|
||||
<MudText Typo="Typo.subtitle1">آدرسهای شما</MudText>
|
||||
<MudButton Variant="Variant.Filled"
|
||||
Color="Color.Primary"
|
||||
StartIcon="@Icons.Material.Filled.Add"
|
||||
OnClick="OpenAddAddressDialog">افزودن آدرس جدید</MudButton>
|
||||
</MudStack>
|
||||
|
||||
@if (_isLoadingAddresses)
|
||||
{
|
||||
<MudStack AlignItems="AlignItems.Center" Class="py-8">
|
||||
<MudProgressCircular Color="Color.Primary" Indeterminate="true" Size="Size.Large" />
|
||||
<MudText Typo="Typo.body1" Class="mud-text-secondary mt-2">در حال بارگذاری آدرسها...</MudText>
|
||||
</MudStack>
|
||||
}
|
||||
else if (_addresses.Any())
|
||||
{
|
||||
<MudStack Spacing="3">
|
||||
@foreach (var address in _addresses)
|
||||
{
|
||||
<MudPaper Elevation="1" Class="pa-4 rounded-xl" Outlined="true">
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Start">
|
||||
<MudStack Spacing="1">
|
||||
<MudStack Row="true" Spacing="2" AlignItems="AlignItems.Center">
|
||||
<MudText Typo="Typo.h6">@address.Title</MudText>
|
||||
@if (address.IsDefault)
|
||||
{
|
||||
<MudChip T="string" Color="Color.Success" Variant="Variant.Filled" Size="Size.Small">پیشفرض</MudChip>
|
||||
}
|
||||
</MudStack>
|
||||
<MudText Typo="Typo.body2" Class="mud-text-secondary">@address.Address</MudText>
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">کد پستی: @address.PostalCode</MudText>
|
||||
</MudStack>
|
||||
|
||||
<MudMenu Icon="@Icons.Material.Filled.MoreVert" Size="Size.Small" AnchorOrigin="Origin.TopRight">
|
||||
<MudMenuItem OnClick="@(() => OpenEditAddressDialog(address))">ویرایش</MudMenuItem>
|
||||
@if (!address.IsDefault)
|
||||
{
|
||||
<MudMenuItem OnClick="@(() => SetAsDefaultAddress(address.Id))">تنظیم به عنوان پیشفرض</MudMenuItem>
|
||||
}
|
||||
<MudDivider />
|
||||
<MudMenuItem OnClick="@(() => DeleteAddress(address.Id))" Class="mud-text-error">حذف</MudMenuItem>
|
||||
</MudMenu>
|
||||
</MudStack>
|
||||
</MudPaper>
|
||||
}
|
||||
</MudStack>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudStack AlignItems="AlignItems.Center" Class="py-8">
|
||||
<MudIcon Icon="@Icons.Material.Filled.LocationOff" Size="Size.Large" Color="Color.Default" />
|
||||
<MudText Typo="Typo.body1" Class="mud-text-secondary mt-2">هنوز آدرسی ثبت نکردهاید.</MudText>
|
||||
<MudButton Variant="Variant.Outlined" Color="Color.Primary" StartIcon="@Icons.Material.Filled.Add" OnClick="OpenAddAddressDialog" Class="mt-2">افزودن اولین آدرس</MudButton>
|
||||
</MudStack>
|
||||
}
|
||||
</MudStack>
|
||||
</MudPaper>
|
||||
</MudStack>
|
||||
</MudContainer>
|
||||
90
src/FrontOffice.Main/Pages/Profile/Addresses.razor.cs
Normal file
90
src/FrontOffice.Main/Pages/Profile/Addresses.razor.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
using FrontOffice.BFF.UserAddress.Protobuf.Protos.UserAddress;
|
||||
using FrontOffice.Main.Pages.Profile.Components;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
|
||||
namespace FrontOffice.Main.Pages.Profile;
|
||||
|
||||
public partial class Addresses : ComponentBase
|
||||
{
|
||||
[Inject] private UserAddressContract.UserAddressContractClient UserAddressContract { get; set; } = default!;
|
||||
|
||||
private List<GetAllUserAddressByFilterResponseModel> _addresses = new();
|
||||
private bool _isLoadingAddresses;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await LoadAddresses();
|
||||
}
|
||||
|
||||
private async Task LoadAddresses()
|
||||
{
|
||||
_isLoadingAddresses = true;
|
||||
try
|
||||
{
|
||||
var response = await UserAddressContract.GetAllUserAddressByFilterAsync(new());
|
||||
_addresses = response?.Models?.ToList() ?? new();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Snackbar.Add($"خطا در بارگذاری آدرسها: {ex.Message}", Severity.Error);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_isLoadingAddresses = false;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task OpenAddAddressDialog()
|
||||
{
|
||||
var dialog = await DialogService.ShowAsync<AddAddressDialog>("افزودن آدرس جدید");
|
||||
var result = await dialog.Result;
|
||||
if (!result.Canceled)
|
||||
await LoadAddresses();
|
||||
}
|
||||
|
||||
private async Task OpenEditAddressDialog(GetAllUserAddressByFilterResponseModel address)
|
||||
{
|
||||
var dialog = await DialogService.ShowAsync<EditAddressDialog>("ویرایش آدرس", new DialogParameters<EditAddressDialog>
|
||||
{
|
||||
{ x => x.Model, address }
|
||||
});
|
||||
var result = await dialog.Result;
|
||||
if (!result.Canceled)
|
||||
await LoadAddresses();
|
||||
}
|
||||
|
||||
private async Task SetAsDefaultAddress(long id)
|
||||
{
|
||||
try
|
||||
{
|
||||
await UserAddressContract.SetAddressAsDefaultAsync(new() { Id = id });
|
||||
Snackbar.Add("آدرس پیشفرض تغییر کرد.", Severity.Success);
|
||||
await LoadAddresses();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Snackbar.Add($"خطا در تغییر آدرس پیشفرض: {ex.Message}", Severity.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task DeleteAddress(long id)
|
||||
{
|
||||
var confirm = await DialogService.ShowMessageBox("تأیید حذف", "آیا از حذف این آدرس مطمئن هستید؟", yesText: "حذف", cancelText: "لغو");
|
||||
if (confirm == true)
|
||||
{
|
||||
try
|
||||
{
|
||||
await UserAddressContract.DeleteUserAddressAsync(new() { Id = id });
|
||||
Snackbar.Add("آدرس حذف شد.", Severity.Success);
|
||||
await LoadAddresses();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Snackbar.Add($"خطا در حذف آدرس: {ex.Message}", Severity.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,263 +62,101 @@
|
||||
</MudPaper>
|
||||
</MudItem>
|
||||
|
||||
<!-- Profile Content -->
|
||||
<!-- Wallet Highlight Row -->
|
||||
<MudItem xs="12">
|
||||
<MudPaper Elevation="4" Class=" ">
|
||||
<MudTabs Elevation="0" Rounded="true" ApplyEffectsToContainer="true" Class="px-4 pt-4">
|
||||
<!-- Personal Information Tab -->
|
||||
<MudTabPanel Text="اطلاعات شخصی" Icon="@Icons.Material.Filled.Person">
|
||||
<div class="pa-4">
|
||||
<MudForm @ref="_personalForm" Model="_updateUserRequest" Validation="@(_personalValidator.ValidateValue)">
|
||||
<MudGrid Spacing="3">
|
||||
<MudItem xs="12" md="6">
|
||||
<MudTextField @bind-Value="_updateUserRequest.FirstName"
|
||||
For="@(() => _updateUserRequest.FirstName)"
|
||||
Label="نام"
|
||||
Variant="Variant.Outlined" />
|
||||
</MudItem>
|
||||
|
||||
<MudItem xs="12" md="6">
|
||||
<MudTextField @bind-Value="_updateUserRequest.LastName"
|
||||
For="@(() => _updateUserRequest.LastName)"
|
||||
Label="نام خانوادگی"
|
||||
Variant="Variant.Outlined" />
|
||||
</MudItem>
|
||||
|
||||
<MudItem xs="12" md="6">
|
||||
<MudTextField @bind-Value="_updateUserRequest.NationalCode"
|
||||
For="@(() => _updateUserRequest.NationalCode)"
|
||||
Label="کد ملی"
|
||||
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">
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="SavePersonalInfo" Disabled="_isPersonalSaving">
|
||||
ذخیره تغییرات
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
</MudForm>
|
||||
</div>
|
||||
</MudTabPanel>
|
||||
|
||||
<!-- Address Management Tab -->
|
||||
<MudTabPanel Text="آدرسها" Icon="@Icons.Material.Filled.LocationOn">
|
||||
<div class="pa-4">
|
||||
<MudStack Spacing="4">
|
||||
<!-- Add New Address Button -->
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center">
|
||||
<MudText Typo="Typo.subtitle1" >آدرسهای شما</MudText>
|
||||
<MudButton Variant="Variant.Filled"
|
||||
Color="Color.Primary"
|
||||
StartIcon="@Icons.Material.Filled.Add"
|
||||
OnClick="OpenAddAddressDialog">
|
||||
افزودن آدرس جدید
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
|
||||
<!-- Address List -->
|
||||
@if (_isLoadingAddresses)
|
||||
{
|
||||
<MudStack AlignItems="AlignItems.Center" Class="py-8">
|
||||
<MudProgressCircular Color="Color.Primary" Indeterminate="true" Size="Size.Large" />
|
||||
<MudText Typo="Typo.body1" Class="mud-text-secondary mt-2">در حال بارگذاری آدرسها...</MudText>
|
||||
</MudStack>
|
||||
}
|
||||
else if (_addresses.Any())
|
||||
{
|
||||
<MudStack Spacing="3">
|
||||
@foreach (var address in _addresses)
|
||||
{
|
||||
<MudPaper Elevation="2" Class="pa-4 rounded-xl " Outlined="true">
|
||||
<MudStack Spacing="3">
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Start">
|
||||
<MudStack Spacing="1">
|
||||
<MudStack Row="true" Spacing="2" AlignItems="AlignItems.Center">
|
||||
<MudText Typo="Typo.h6" >@address.Title</MudText>
|
||||
@if (address.IsDefault)
|
||||
{
|
||||
<MudChip T="string" Color="Color.Success" Variant="Variant.Filled" Size="Size.Small">پیشفرض</MudChip>
|
||||
}
|
||||
</MudStack>
|
||||
<MudText Typo="Typo.body2" Class="mud-text-secondary">@(address.Address)</MudText>
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">کد پستی: @(address.PostalCode)</MudText>
|
||||
</MudStack>
|
||||
|
||||
<MudMenu Icon="@Icons.Material.Filled.MoreVert" Size="Size.Small" AnchorOrigin="Origin.TopRight">
|
||||
<MudMenuItem OnClick="@(() => OpenEditAddressDialog(address))">ویرایش</MudMenuItem>
|
||||
@if (!address.IsDefault)
|
||||
{
|
||||
<MudMenuItem OnClick="@(() => SetAsDefaultAddress(address.Id))">تنظیم به عنوان پیشفرض</MudMenuItem>
|
||||
}
|
||||
<MudDivider />
|
||||
<MudMenuItem OnClick="@(() => DeleteAddress(address.Id))" Class="mud-text-error">حذف</MudMenuItem>
|
||||
</MudMenu>
|
||||
</MudStack>
|
||||
</MudStack>
|
||||
</MudPaper>
|
||||
}
|
||||
</MudStack>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudStack AlignItems="AlignItems.Center" Class="py-8">
|
||||
<MudIcon Icon="@Icons.Material.Filled.LocationOff" Size="Size.Large" Color="Color.Default" />
|
||||
<MudText Typo="Typo.body1" Class="mud-text-secondary mt-2">هنوز آدرسی ثبت نکردهاید.</MudText>
|
||||
<MudButton Variant="Variant.Outlined"
|
||||
Color="Color.Primary"
|
||||
StartIcon="@Icons.Material.Filled.Add"
|
||||
OnClick="OpenAddAddressDialog"
|
||||
Class="mt-2">
|
||||
افزودن اولین آدرس
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
}
|
||||
</MudStack>
|
||||
</div>
|
||||
</MudTabPanel>
|
||||
|
||||
<!-- Organization Chart Tab -->
|
||||
<MudTabPanel Text="شجرهنامه" Icon="@Icons.Material.Filled.AccountTree">
|
||||
<div class="pa-4">
|
||||
<OrganizationChart />
|
||||
</div>
|
||||
</MudTabPanel>
|
||||
|
||||
<!-- Account Settings Tab -->
|
||||
<MudTabPanel Text="تنظیمات حساب" Icon="@Icons.Material.Filled.Settings">
|
||||
<div class="pa-4">
|
||||
|
||||
<MudStack Spacing="4">
|
||||
<!-- Notification Settings -->
|
||||
<MudPaper Outlined="true" Class="pa-4 rounded-lg">
|
||||
<MudText Typo="Typo.subtitle1" Class="mb-3">اعلانها</MudText>
|
||||
<MudStack Spacing="2">
|
||||
<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">حریم خصوصی</MudText>
|
||||
<MudStack Spacing="2">
|
||||
<MudSwitch T="bool" @bind-Checked="_settings.ProfileVisibility" Label="نمایش پروفایل عمومی" />
|
||||
<MudSwitch T="bool" @bind-Checked="_settings.ShowOnlineStatus" Label="نمایش وضعیت آنلاین" />
|
||||
</MudStack>
|
||||
</MudPaper>
|
||||
|
||||
<!-- Language & Theme -->
|
||||
<MudPaper Outlined="true" Class="pa-4 rounded-lg">
|
||||
<MudText Typo="Typo.subtitle1" Class="mb-3">زبان و تم</MudText>
|
||||
<MudGrid Spacing="3">
|
||||
<MudItem xs="12" md="6">
|
||||
<MudSelect @bind-Value="_settings.Language" Label="زبان" Variant="Variant.Outlined">
|
||||
<MudSelectItem Value="@("fa")">فارسی</MudSelectItem>
|
||||
<MudSelectItem Value="@("en")">English</MudSelectItem>
|
||||
</MudSelect>
|
||||
</MudItem>
|
||||
<MudItem xs="12" md="6">
|
||||
<MudSelect @bind-Value="_settings.Theme" Label="تم" Variant="Variant.Outlined">
|
||||
<MudSelectItem Value="@("light")">روشن</MudSelectItem>
|
||||
<MudSelectItem Value="@("dark")">تیره</MudSelectItem>
|
||||
<MudSelectItem Value="@("auto")">خودکار</MudSelectItem>
|
||||
</MudSelect>
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
</MudPaper> *@
|
||||
|
||||
<MudStack Row="true" Spacing="2" Justify="Justify.FlexEnd">
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="SaveSettings" Disabled="_isSettingsSaving">
|
||||
ذخیره تنظیمات
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
</MudStack>
|
||||
</div>
|
||||
</MudTabPanel>
|
||||
|
||||
<!-- Statistics Tab -->
|
||||
@* <MudTabPanel Text="آمار و اطلاعات" Icon="@Icons.Material.Filled.BarChart">
|
||||
<div class="pa-4">
|
||||
<MudText Typo="Typo.h6" Class="mb-4">آمار حساب کاربری</MudText>
|
||||
|
||||
<MudGrid Spacing="3">
|
||||
<MudItem xs="12" md="6" lg="3">
|
||||
<MudPaper Elevation="3" Class="pa-4 text-center rounded-xl ">
|
||||
<MudIcon Icon="@Icons.Material.Filled.DateRange" Size="Size.Large" Color="Color.Primary" Class="mb-2" />
|
||||
<MudText Typo="Typo.h4">@_userProfile.JoinDate</MudText>
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">تاریخ عضویت</MudText>
|
||||
</MudPaper>
|
||||
<MudPaper Elevation="3" Class="pa-4 rounded-lg gradient-border">
|
||||
<MudGrid Spacing="2" AlignItems="AlignItems.Center">
|
||||
<MudItem xs="12" sm="6" md="4">
|
||||
<MudStack>
|
||||
<MudText Typo="Typo.subtitle2" Class="mud-text-secondary">موجودی اعتباری</MudText>
|
||||
<MudText Typo="Typo.h5" Color="Color.Primary">@_walletCredit</MudText>
|
||||
</MudStack>
|
||||
</MudItem>
|
||||
|
||||
<MudItem xs="12" md="6" lg="3">
|
||||
<MudPaper Elevation="3" Class="pa-4 text-center rounded-xl ">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Login" Size="Size.Large" Color="Color.Success" Class="mb-2" />
|
||||
<MudText Typo="Typo.h4">@_userProfile.LastLogin</MudText>
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">آخرین ورود</MudText>
|
||||
</MudPaper>
|
||||
<MudItem xs="12" sm="6" md="4">
|
||||
<MudStack>
|
||||
<MudText Typo="Typo.subtitle2" Class="mud-text-secondary">موجودی شبکه</MudText>
|
||||
<MudText Typo="Typo.h5" Color="Color.Primary">@_walletNetwork</MudText>
|
||||
</MudStack>
|
||||
</MudItem>
|
||||
|
||||
<MudItem xs="12" md="6" lg="3">
|
||||
<MudPaper Elevation="3" Class="pa-4 text-center rounded-xl ">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Group" Size="Size.Large" Color="Color.Info" Class="mb-2" />
|
||||
<MudText Typo="Typo.h4">@_userProfile.TotalReferrals</MudText>
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">معرفها</MudText>
|
||||
</MudPaper>
|
||||
<MudItem xs="12" md="4" Class="d-flex justify-end">
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" StartIcon="@Icons.Material.Filled.AccountBalanceWallet" Href="@RouteConstants.Profile.Wallet">جزئیات کیف پول</MudButton>
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
</MudPaper>
|
||||
</MudItem>
|
||||
|
||||
<MudItem xs="12" md="6" lg="3">
|
||||
<MudPaper Elevation="3" Class="pa-4 text-center rounded-xl ">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Star" Size="Size.Large" Color="Color.Warning" Class="mb-2" />
|
||||
<MudText Typo="Typo.h4">@_userProfile.Level</MudText>
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">سطح کاربری</MudText>
|
||||
</MudPaper>
|
||||
<!-- Profile Content as tiles -->
|
||||
<MudItem xs="12">
|
||||
<MudPaper Elevation="4" Class="pa-4">
|
||||
<MudGrid Spacing="3">
|
||||
<MudItem xs="6" sm="6" md="3">
|
||||
<MudLink Href="@RouteConstants.Profile.Personal" Underline="Underline.None" Class="tile-link">
|
||||
<MudCard Elevation="1" Class="rounded-lg profile-tile">
|
||||
<MudCardContent Class="d-flex flex-column align-center pa-4">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Person" Size="Size.Large" Color="Color.Primary" />
|
||||
<MudText Typo="Typo.subtitle1" Class="mt-2">اطلاعات شخصی</MudText>
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">نمایش و ویرایش اطلاعات</MudText>
|
||||
</MudCardContent>
|
||||
</MudCard>
|
||||
</MudLink>
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
|
||||
<!-- Account Status -->
|
||||
<MudPaper Elevation="2" Class="pa-4 mt-4 rounded-xl ">
|
||||
<MudText Typo="Typo.subtitle1" Class="mb-3">وضعیت حساب</MudText>
|
||||
<MudStack Spacing="2">
|
||||
<MudStack Row="true" Spacing="2" AlignItems="AlignItems.Center">
|
||||
<MudIcon Icon="@Icons.Material.Filled.CheckCircle" Size="Size.Small" Color="Color.Success" />
|
||||
<MudText Typo="Typo.body2">حساب تأیید شده</MudText>
|
||||
</MudStack>
|
||||
<MudStack Row="true" Spacing="2" AlignItems="AlignItems.Center">
|
||||
<MudIcon Icon="@Icons.Material.Filled.CheckCircle" Size="Size.Small" Color="Color.Success" />
|
||||
<MudText Typo="Typo.body2">ایمیل تأیید شده</MudText>
|
||||
</MudStack>
|
||||
<MudStack Row="true" Spacing="2" AlignItems="AlignItems.Center">
|
||||
<MudIcon Icon="@Icons.Material.Filled.CheckCircle" Size="Size.Small" Color="Color.Success" />
|
||||
<MudText Typo="Typo.body2">شماره موبایل تأیید شده</MudText>
|
||||
</MudStack>
|
||||
</MudStack>
|
||||
</MudPaper>
|
||||
</div>
|
||||
</MudTabPanel>
|
||||
*@
|
||||
</MudTabs>
|
||||
<MudItem xs="6" sm="6" md="3">
|
||||
<MudLink Href="@RouteConstants.Profile.Addresses" Underline="Underline.None" Class="tile-link">
|
||||
<MudCard Elevation="1" Class="rounded-lg profile-tile">
|
||||
<MudCardContent Class="d-flex flex-column align-center pa-4">
|
||||
<MudIcon Icon="@Icons.Material.Filled.LocationOn" Size="Size.Large" Color="Color.Primary" />
|
||||
<MudText Typo="Typo.subtitle1" Class="mt-2">آدرسها</MudText>
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">مدیریت آدرسهای شما</MudText>
|
||||
</MudCardContent>
|
||||
</MudCard>
|
||||
</MudLink>
|
||||
</MudItem>
|
||||
<MudItem xs="6" sm="6" md="3">
|
||||
<MudLink Href="@RouteConstants.Profile.Tree" Underline="Underline.None" Class="tile-link">
|
||||
<MudCard Elevation="1" Class="rounded-lg profile-tile">
|
||||
<MudCardContent Class="d-flex flex-column align-center pa-4">
|
||||
<MudIcon Icon="@Icons.Material.Filled.AccountTree" Size="Size.Large" Color="Color.Primary" />
|
||||
<MudText Typo="Typo.subtitle1" Class="mt-2">شجرهنامه</MudText>
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">ساختار شبکه</MudText>
|
||||
</MudCardContent>
|
||||
</MudCard>
|
||||
</MudLink>
|
||||
</MudItem>
|
||||
<MudItem xs="6" sm="6" md="3">
|
||||
<MudLink Href="@RouteConstants.Profile.Settings" Underline="Underline.None" Class="tile-link">
|
||||
<MudCard Elevation="1" Class="rounded-lg profile-tile">
|
||||
<MudCardContent Class="d-flex flex-column align-center pa-4">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Settings" Size="Size.Large" Color="Color.Primary" />
|
||||
<MudText Typo="Typo.subtitle1" Class="mt-2">تنظیمات حساب</MudText>
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">اعلانها و تنظیمات</MudText>
|
||||
</MudCardContent>
|
||||
</MudCard>
|
||||
</MudLink>
|
||||
</MudItem>
|
||||
<MudItem xs="6" sm="6" md="3">
|
||||
<MudLink Href="@RouteConstants.Store.Products" Underline="Underline.None" Class="tile-link">
|
||||
<MudCard Elevation="1" Class="rounded-lg profile-tile">
|
||||
<MudCardContent Class="d-flex flex-column align-center pa-4">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Storefront" Size="Size.Large" Color="Color.Primary" />
|
||||
<MudText Typo="Typo.subtitle1" Class="mt-2">فروشگاه</MudText>
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">مشاهده و خرید محصولات</MudText>
|
||||
</MudCardContent>
|
||||
</MudCard>
|
||||
</MudLink>
|
||||
</MudItem>
|
||||
<MudItem xs="6" sm="6" md="3">
|
||||
<MudLink Href="@RouteConstants.Profile.Wallet" Underline="Underline.None" Class="tile-link">
|
||||
<MudCard Elevation="1" Class="rounded-lg profile-tile">
|
||||
<MudCardContent Class="d-flex flex-column align-center pa-4">
|
||||
<MudIcon Icon="@Icons.Material.Filled.AccountBalanceWallet" Size="Size.Large" Color="Color.Primary" />
|
||||
<MudText Typo="Typo.subtitle1" Class="mt-2">کیف پول</MudText>
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">مدیریت و تاریخچه</MudText>
|
||||
</MudCardContent>
|
||||
</MudCard>
|
||||
</MudLink>
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
</MudPaper>
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
</MudContainer>
|
||||
</MudContainer>
|
||||
|
||||
@@ -18,6 +18,7 @@ public partial class Index
|
||||
{
|
||||
[Inject] private UserContract.UserContractClient UserContract { get; set; } = default!;
|
||||
[Inject] private UserAddressContract.UserAddressContractClient UserAddressContract { get; set; } = default!;
|
||||
[Inject] private WalletService WalletService { get; set; } = default!;
|
||||
|
||||
private GetUserResponse _userProfile = new();
|
||||
private UpdateUserRequest _updateUserRequest = new();
|
||||
@@ -46,9 +47,22 @@ public partial class Index
|
||||
{
|
||||
await LoadUserProfile();
|
||||
await LoadAddresses();
|
||||
await LoadWallet();
|
||||
}
|
||||
}
|
||||
|
||||
private string _walletCredit = "-";
|
||||
private string _walletNetwork = "-";
|
||||
private async Task LoadWallet()
|
||||
{
|
||||
var b = await WalletService.GetBalancesAsync();
|
||||
_walletCredit = FormatPrice(b.CreditBalance);
|
||||
_walletNetwork = FormatPrice(b.NetworkBalance);
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private static string FormatPrice(long price) => string.Format("{0:N0} تومان", price);
|
||||
|
||||
private async Task LoadUserProfile()
|
||||
{
|
||||
try
|
||||
@@ -286,4 +300,4 @@ public partial class Index
|
||||
var url = "https://dayadiamond.ir/profile/creditpurchase/?merchantcode=56146364";
|
||||
await JSRuntime.InvokeVoidAsync("open", url, "_blank");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
52
src/FrontOffice.Main/Pages/Profile/Personal.razor
Normal file
52
src/FrontOffice.Main/Pages/Profile/Personal.razor
Normal file
@@ -0,0 +1,52 @@
|
||||
@attribute [Route(RouteConstants.Profile.Personal)]
|
||||
|
||||
<PageTitle>اطلاعات شخصی</PageTitle>
|
||||
|
||||
<MudContainer MaxWidth="MaxWidth.Medium" Class="py-6">
|
||||
<MudStack Spacing="3">
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center">
|
||||
<MudText Typo="Typo.h5">اطلاعات شخصی</MudText>
|
||||
<MudButton Variant="Variant.Text" StartIcon="@Icons.Material.Filled.ArrowBack" Href="@RouteConstants.Profile.Index">بازگشت</MudButton>
|
||||
</MudStack>
|
||||
|
||||
<MudPaper Elevation="2" Class="pa-4 rounded-lg">
|
||||
<MudForm @ref="_personalForm" Model="_updateUserRequest" Validation="@(_personalValidator.ValidateValue)">
|
||||
<MudGrid Spacing="3">
|
||||
<MudItem xs="12" md="6">
|
||||
<MudTextField @bind-Value="_updateUserRequest.FirstName"
|
||||
For="@(() => _updateUserRequest.FirstName)"
|
||||
Label="نام"
|
||||
Variant="Variant.Outlined" />
|
||||
</MudItem>
|
||||
<MudItem xs="12" md="6">
|
||||
<MudTextField @bind-Value="_updateUserRequest.LastName"
|
||||
For="@(() => _updateUserRequest.LastName)"
|
||||
Label="نام خانوادگی"
|
||||
Variant="Variant.Outlined" />
|
||||
</MudItem>
|
||||
<MudItem xs="12" md="6">
|
||||
<MudTextField @bind-Value="_updateUserRequest.NationalCode"
|
||||
For="@(() => _updateUserRequest.NationalCode)"
|
||||
Disabled="@(!string.IsNullOrWhiteSpace(_updateUserRequest.NationalCode))"
|
||||
Label="کد ملی"
|
||||
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">
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="SavePersonalInfo" Disabled="_isPersonalSaving">
|
||||
ذخیره تغییرات
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
</MudForm>
|
||||
</MudPaper>
|
||||
</MudStack>
|
||||
</MudContainer>
|
||||
73
src/FrontOffice.Main/Pages/Profile/Personal.razor.cs
Normal file
73
src/FrontOffice.Main/Pages/Profile/Personal.razor.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
using FluentValidation;
|
||||
using FrontOffice.BFF.User.Protobuf.Protos.User;
|
||||
using FrontOffice.BFF.User.Protobuf.Validator;
|
||||
using FrontOffice.Main.Utilities;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
using Severity = MudBlazor.Severity;
|
||||
|
||||
namespace FrontOffice.Main.Pages.Profile;
|
||||
|
||||
public partial class Personal : ComponentBase
|
||||
{
|
||||
[Inject] private UserContract.UserContractClient UserContract { get; set; } = default!;
|
||||
|
||||
private GetUserResponse _userProfile = new();
|
||||
private UpdateUserRequest _updateUserRequest = new();
|
||||
private readonly UpdateUserRequestValidator _personalValidator = new();
|
||||
|
||||
private MudForm? _personalForm;
|
||||
private DateTime? _date;
|
||||
private bool _isPersonalSaving;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await LoadUserProfile();
|
||||
}
|
||||
|
||||
private async Task LoadUserProfile()
|
||||
{
|
||||
try
|
||||
{
|
||||
_userProfile = await UserContract.GetUserAsync(new());
|
||||
_updateUserRequest = _userProfile.Adapt<UpdateUserRequest>();
|
||||
if (_userProfile.BirthDate != null)
|
||||
_date = _userProfile.BirthDate.ToDateTime();
|
||||
}
|
||||
catch
|
||||
{
|
||||
_userProfile = new();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SavePersonalInfo()
|
||||
{
|
||||
if (_personalForm is null) return;
|
||||
await _personalForm.Validate();
|
||||
if (!_personalForm.IsValid) return;
|
||||
|
||||
_isPersonalSaving = true;
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(_updateUserRequest.NationalCode))
|
||||
_updateUserRequest.NationalCode = _updateUserRequest.NationalCode.PersianToEnglish();
|
||||
|
||||
if (_date != null)
|
||||
_updateUserRequest.BirthDate = _date.Value.DateTimeToTimestamp();
|
||||
|
||||
await UserContract.UpdateUserAsync(_updateUserRequest);
|
||||
Snackbar.Add("اطلاعات شخصی با موفقیت ذخیره شد.", Severity.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Snackbar.Add($"خطا در ذخیره اطلاعات: {ex.Message}", Severity.Error);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_isPersonalSaving = false;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
25
src/FrontOffice.Main/Pages/Profile/Settings.razor
Normal file
25
src/FrontOffice.Main/Pages/Profile/Settings.razor
Normal file
@@ -0,0 +1,25 @@
|
||||
@attribute [Route(RouteConstants.Profile.Settings)]
|
||||
|
||||
<PageTitle>تنظیمات حساب</PageTitle>
|
||||
|
||||
<MudContainer MaxWidth="MaxWidth.Medium" Class="py-6">
|
||||
<MudStack Spacing="3">
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center">
|
||||
<MudText Typo="Typo.h5">تنظیمات حساب</MudText>
|
||||
<MudButton Variant="Variant.Text" StartIcon="@Icons.Material.Filled.ArrowBack" Href="@RouteConstants.Profile.Index">بازگشت</MudButton>
|
||||
</MudStack>
|
||||
|
||||
<MudPaper Elevation="2" Class="pa-4 rounded-lg">
|
||||
<MudStack Spacing="4">
|
||||
<MudText Typo="Typo.subtitle1" Class="mb-1">اعلانها</MudText>
|
||||
<MudSwitch T="bool" @bind-Value="_request.EmailNotifications" Color="Color.Primary" Label="اعلانهای ایمیلی" />
|
||||
<MudSwitch T="bool" @bind-Value="_request.SmsNotifications" Color="Color.Primary" Label="اعلانهای پیامکی" />
|
||||
<MudSwitch T="bool" @bind-Value="_request.PushNotifications" Color="Color.Primary" Label="اعلانهای پوش" />
|
||||
|
||||
<MudStack Row="true" Justify="Justify.FlexEnd">
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="SaveSettings" Disabled="_saving">ذخیره تنظیمات</MudButton>
|
||||
</MudStack>
|
||||
</MudStack>
|
||||
</MudPaper>
|
||||
</MudStack>
|
||||
</MudContainer>
|
||||
46
src/FrontOffice.Main/Pages/Profile/Settings.razor.cs
Normal file
46
src/FrontOffice.Main/Pages/Profile/Settings.razor.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using FrontOffice.BFF.User.Protobuf.Protos.User;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
|
||||
namespace FrontOffice.Main.Pages.Profile;
|
||||
|
||||
public partial class Settings : ComponentBase
|
||||
{
|
||||
[Inject] private UserContract.UserContractClient UserContract { get; set; } = default!;
|
||||
|
||||
private UpdateUserRequest _request = new();
|
||||
private bool _saving;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
var user = await UserContract.GetUserAsync(new());
|
||||
_request = user.Adapt<UpdateUserRequest>();
|
||||
}
|
||||
catch
|
||||
{
|
||||
_request = new();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SaveSettings()
|
||||
{
|
||||
_saving = true;
|
||||
try
|
||||
{
|
||||
await UserContract.UpdateUserAsync(_request);
|
||||
Snackbar.Add("تنظیمات ذخیره شد.", Severity.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Snackbar.Add($"خطا در ذخیره تنظیمات: {ex.Message}", Severity.Error);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_saving = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
17
src/FrontOffice.Main/Pages/Profile/Tree.razor
Normal file
17
src/FrontOffice.Main/Pages/Profile/Tree.razor
Normal file
@@ -0,0 +1,17 @@
|
||||
@attribute [Route(RouteConstants.Profile.Tree)]
|
||||
@using FrontOffice.Main.Pages.Profile.Components
|
||||
|
||||
<PageTitle>شجرهنامه</PageTitle>
|
||||
|
||||
<MudContainer MaxWidth="MaxWidth.Large" Class="py-6">
|
||||
<MudStack Spacing="3">
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center">
|
||||
<MudText Typo="Typo.h5">شجرهنامه</MudText>
|
||||
<MudButton Variant="Variant.Text" StartIcon="@Icons.Material.Filled.ArrowBack" Href="@RouteConstants.Profile.Index">بازگشت</MudButton>
|
||||
</MudStack>
|
||||
|
||||
<MudPaper Elevation="2" Class="pa-4 rounded-lg">
|
||||
<OrganizationChart />
|
||||
</MudPaper>
|
||||
</MudStack>
|
||||
</MudContainer>
|
||||
66
src/FrontOffice.Main/Pages/Profile/Wallet.razor
Normal file
66
src/FrontOffice.Main/Pages/Profile/Wallet.razor
Normal file
@@ -0,0 +1,66 @@
|
||||
@attribute [Route(RouteConstants.Profile.Wallet)]
|
||||
|
||||
<PageTitle>کیف پول</PageTitle>
|
||||
|
||||
<MudContainer MaxWidth="MaxWidth.Large" Class="py-6">
|
||||
<MudStack Spacing="3">
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center">
|
||||
<MudText Typo="Typo.h5">کیف پول</MudText>
|
||||
<MudButton Variant="Variant.Text" StartIcon="@Icons.Material.Filled.ArrowBack" Href="@RouteConstants.Profile.Index">بازگشت</MudButton>
|
||||
</MudStack>
|
||||
|
||||
<MudGrid Spacing="2">
|
||||
<MudItem xs="12" sm="6">
|
||||
<MudPaper Elevation="2" Class="pa-4 rounded-lg">
|
||||
<MudText Typo="Typo.subtitle2" Class="mud-text-secondary">موجودی اعتباری</MudText>
|
||||
<MudText Typo="Typo.h4" Color="Color.Primary">@_balances.Credit</MudText>
|
||||
</MudPaper>
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="6">
|
||||
<MudPaper Elevation="2" Class="pa-4 rounded-lg">
|
||||
<MudText Typo="Typo.subtitle2" Class="mud-text-secondary">موجودی شبکه</MudText>
|
||||
<MudText Typo="Typo.h4" Color="Color.Primary">@_balances.Network</MudText>
|
||||
</MudPaper>
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
|
||||
<MudPaper Elevation="2" Class="pa-4 rounded-lg">
|
||||
<MudText Typo="Typo.h6" Class="mb-2">تراکنشها و مسیرهای شارژ</MudText>
|
||||
|
||||
<MudHidden Breakpoint="Breakpoint.MdAndUp" Invert="true">
|
||||
<MudTable Items="_txs" Dense="true">
|
||||
<HeaderContent>
|
||||
<MudTh>تاریخ</MudTh>
|
||||
<MudTh>مبلغ</MudTh>
|
||||
<MudTh>مسیر</MudTh>
|
||||
<MudTh>توضیحات</MudTh>
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd>@context.Date.ToString("yyyy/MM/dd HH:mm")</MudTd>
|
||||
<MudTd Color="@(context.Amount > 0 ? Color.Success : Color.Error)">@FormatPrice(context.Amount)</MudTd>
|
||||
<MudTd>@context.Channel</MudTd>
|
||||
<MudTd>@context.Description</MudTd>
|
||||
</RowTemplate>
|
||||
</MudTable>
|
||||
</MudHidden>
|
||||
|
||||
<MudHidden Breakpoint="Breakpoint.MdAndUp">
|
||||
<MudStack Spacing="2">
|
||||
@foreach (var tx in _txs)
|
||||
{
|
||||
<MudPaper Class="pa-3 rounded-lg" Outlined="true">
|
||||
<MudStack Spacing="1">
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center">
|
||||
<MudText>@tx.Date.ToString("yy/MM/dd HH:mm")</MudText>
|
||||
<MudText Color="@(tx.Amount > 0 ? Color.Success : Color.Error)">@FormatPrice(tx.Amount)</MudText>
|
||||
</MudStack>
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">@tx.Channel</MudText>
|
||||
<MudText Typo="Typo.body2">@tx.Description</MudText>
|
||||
</MudStack>
|
||||
</MudPaper>
|
||||
}
|
||||
</MudStack>
|
||||
</MudHidden>
|
||||
</MudPaper>
|
||||
</MudStack>
|
||||
</MudContainer>
|
||||
22
src/FrontOffice.Main/Pages/Profile/Wallet.razor.cs
Normal file
22
src/FrontOffice.Main/Pages/Profile/Wallet.razor.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using FrontOffice.Main.Utilities;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace FrontOffice.Main.Pages.Profile;
|
||||
|
||||
public partial class Wallet : ComponentBase
|
||||
{
|
||||
[Inject] private WalletService WalletService { get; set; } = default!;
|
||||
|
||||
private (string Credit, string Network) _balances = ("-", "-");
|
||||
private List<WalletTransaction> _txs = new();
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
var b = await WalletService.GetBalancesAsync();
|
||||
_balances = (FormatPrice(b.CreditBalance), FormatPrice(b.NetworkBalance));
|
||||
_txs = await WalletService.GetTransactionsAsync();
|
||||
}
|
||||
|
||||
private static string FormatPrice(long price) => string.Format("{0:N0} تومان", price);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user