This commit is contained in:
MeysamMoghaddam
2025-10-13 17:25:20 +03:30
parent 832fc18630
commit d68f0189f4
2 changed files with 25 additions and 2 deletions

View File

@@ -90,11 +90,20 @@
<MudStack Spacing="1">
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="2">
<MudRadio T="long" Value="address.Id" Checked="@(_selectedAddress?.Id == address.Id)" />
<MudText Typo="Typo.subtitle2" >@address.Title</MudText>
@if (address.IsDefault)
<MudText Typo="Typo.subtitle2">@address.Title</MudText>
@if (address.IsDefault)
{
<MudChip T="string" Color="Color.Success" Variant="Variant.Filled" Size="Size.Small">پیش‌فرض</MudChip>
}
@if (!address.IsDefault)
{
<MudButton Variant="Variant.Text"
Color="Color.Primary"
Size="Size.Small"
OnClick="() => SetAddressAsDefault(address.Id)">
تنظیم به عنوان پیش‌فرض
</MudButton>
}
</MudStack>
<MudText Typo="Typo.body2" Class="mud-text-secondary">@address.Address</MudText>
<MudText Typo="Typo.caption" Class="mud-text-secondary">کد پستی: @address.PostalCode</MudText>

View File

@@ -102,6 +102,20 @@ public partial class Checkout
StateHasChanged();
}
private async Task SetAddressAsDefault(long addressId)
{
try
{
await UserAddressContract.SetAddressAsDefaultAsync(new() { Id = addressId });
await LoadAddresses(); // Reload addresses to reflect the change
Snackbar.Add("آدرس پیش‌فرض با موفقیت تغییر یافت.", Severity.Success);
}
catch (Exception ex)
{
Snackbar.Add($"خطا در تغییر آدرس پیش‌فرض: {ex.Message}", Severity.Error);
}
}
private async Task ApplyDiscountCode()
{
if (string.IsNullOrWhiteSpace(_discountCode))