feat: Add package management features and update checkout summary
- Added PackageService to handle package-related operations. - Introduced MyPackages and Packages pages for user package management. - Updated CheckoutSummary to display VAT calculations. - Enhanced OrderDetail to show financial details including VAT. - Added ChangePassword page for user profile management. - Implemented OrderTracking page for tracking order status. - Updated RouteConstants to include new routes for packages and password change.
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
@attribute [Route(RouteConstants.Profile.ChangePassword)]
|
||||
|
||||
<PageTitle>تغییر رمز عبور</PageTitle>
|
||||
|
||||
<MudContainer MaxWidth="MaxWidth.Small" 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.Settings">بازگشت</MudButton>
|
||||
</MudStack>
|
||||
|
||||
<MudPaper Elevation="2" Class="pa-4 rounded-lg">
|
||||
<MudStack Spacing="3">
|
||||
@if (_success)
|
||||
{
|
||||
<MudAlert Severity="Severity.Success" Variant="Variant.Filled">
|
||||
رمز عبور با موفقیت تغییر کرد
|
||||
</MudAlert>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudTextField T="string" @bind-Value="_currentPassword"
|
||||
Label="رمز عبور فعلی"
|
||||
InputType="InputType.Password"
|
||||
Required="true"
|
||||
RequiredError="رمز عبور فعلی الزامی است"
|
||||
Variant="Variant.Outlined" />
|
||||
|
||||
<MudTextField T="string" @bind-Value="_newPassword"
|
||||
Label="رمز عبور جدید"
|
||||
InputType="InputType.Password"
|
||||
Required="true"
|
||||
RequiredError="رمز عبور جدید الزامی است"
|
||||
HelperText="حداقل 8 کاراکتر شامل حروف و اعداد"
|
||||
Variant="Variant.Outlined" />
|
||||
|
||||
<MudTextField T="string" @bind-Value="_confirmPassword"
|
||||
Label="تکرار رمز عبور جدید"
|
||||
InputType="InputType.Password"
|
||||
Required="true"
|
||||
RequiredError="تکرار رمز عبور الزامی است"
|
||||
Variant="Variant.Outlined" />
|
||||
|
||||
@if (!string.IsNullOrEmpty(_error))
|
||||
{
|
||||
<MudAlert Severity="Severity.Error" Variant="Variant.Outlined">@_error</MudAlert>
|
||||
}
|
||||
|
||||
<MudStack Row="true" Justify="Justify.FlexEnd" Class="mt-2">
|
||||
<MudButton Variant="Variant.Filled"
|
||||
Color="Color.Primary"
|
||||
OnClick="ChangePasswordAsync"
|
||||
Disabled="_saving"
|
||||
StartIcon="@Icons.Material.Filled.Lock">
|
||||
@if (_saving)
|
||||
{
|
||||
<MudProgressCircular Size="Size.Small" Indeterminate="true" Class="me-2" />
|
||||
<span>در حال ذخیره...</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span>تغییر رمز عبور</span>
|
||||
}
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
}
|
||||
</MudStack>
|
||||
</MudPaper>
|
||||
</MudStack>
|
||||
</MudContainer>
|
||||
@@ -0,0 +1,77 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
|
||||
namespace FrontOffice.Main.Pages.Profile;
|
||||
|
||||
public partial class ChangePassword : ComponentBase
|
||||
{
|
||||
private string _currentPassword = string.Empty;
|
||||
private string _newPassword = string.Empty;
|
||||
private string _confirmPassword = string.Empty;
|
||||
private string _error = string.Empty;
|
||||
private bool _saving;
|
||||
private bool _success;
|
||||
|
||||
private async Task ChangePasswordAsync()
|
||||
{
|
||||
_error = string.Empty;
|
||||
|
||||
// Validation
|
||||
if (string.IsNullOrWhiteSpace(_currentPassword))
|
||||
{
|
||||
_error = "رمز عبور فعلی را وارد کنید";
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(_newPassword))
|
||||
{
|
||||
_error = "رمز عبور جدید را وارد کنید";
|
||||
return;
|
||||
}
|
||||
|
||||
if (_newPassword.Length < 8)
|
||||
{
|
||||
_error = "رمز عبور جدید باید حداقل 8 کاراکتر باشد";
|
||||
return;
|
||||
}
|
||||
|
||||
if (_newPassword != _confirmPassword)
|
||||
{
|
||||
_error = "رمز عبور جدید و تکرار آن یکسان نیستند";
|
||||
return;
|
||||
}
|
||||
|
||||
if (_currentPassword == _newPassword)
|
||||
{
|
||||
_error = "رمز عبور جدید باید متفاوت از رمز فعلی باشد";
|
||||
return;
|
||||
}
|
||||
|
||||
_saving = true;
|
||||
try
|
||||
{
|
||||
// TODO: Call UserContract.ChangePasswordAsync when available
|
||||
// var request = new ChangePasswordRequest
|
||||
// {
|
||||
// CurrentPassword = _currentPassword,
|
||||
// NewPassword = _newPassword
|
||||
// };
|
||||
// await UserContract.ChangePasswordAsync(request);
|
||||
|
||||
// Simulate API call
|
||||
await Task.Delay(500);
|
||||
|
||||
_success = true;
|
||||
Snackbar.Add("رمز عبور با موفقیت تغییر کرد", Severity.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_error = ex.Message;
|
||||
Snackbar.Add($"خطا در تغییر رمز عبور: {ex.Message}", Severity.Error);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_saving = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user