refactor: update user address models and methods to use CustomerAddressModel across multiple components
Build and Deploy to Kubernetes / build-and-deploy (push) Failing after 3m8s
Build and Deploy to Kubernetes / build-and-deploy (push) Failing after 3m8s
This commit is contained in:
@@ -10,7 +10,7 @@ public partial class Addresses : ComponentBase
|
||||
{
|
||||
[Inject] private UserAddressContract.UserAddressContractClient UserAddressContract { get; set; } = default!;
|
||||
|
||||
private List<GetAllUserAddressByFilterResponseModel> _addresses = new();
|
||||
private List<CustomerAddressModel> _addresses = new();
|
||||
private bool _isLoadingAddresses;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
@@ -23,7 +23,7 @@ public partial class Addresses : ComponentBase
|
||||
_isLoadingAddresses = true;
|
||||
try
|
||||
{
|
||||
var response = await UserAddressContract.GetAllUserAddressByFilterAsync(new());
|
||||
var response = await UserAddressContract.GetCustomerAddressesAsync(new());
|
||||
_addresses = response?.Models?.ToList() ?? new();
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -45,7 +45,7 @@ public partial class Addresses : ComponentBase
|
||||
await LoadAddresses();
|
||||
}
|
||||
|
||||
private async Task OpenEditAddressDialog(GetAllUserAddressByFilterResponseModel address)
|
||||
private async Task OpenEditAddressDialog(CustomerAddressModel address)
|
||||
{
|
||||
var dialog = await DialogService.ShowAsync<EditAddressDialog>("ویرایش آدرس", new DialogParameters<EditAddressDialog>
|
||||
{
|
||||
@@ -60,7 +60,7 @@ public partial class Addresses : ComponentBase
|
||||
{
|
||||
try
|
||||
{
|
||||
await UserAddressContract.SetAddressAsDefaultAsync(new() { Id = id });
|
||||
await UserAddressContract.SetCustomerDefaultAddressAsync(new() { Id = id });
|
||||
Snackbar.Add("آدرس پیشفرض تغییر کرد.", Severity.Success);
|
||||
await LoadAddresses();
|
||||
}
|
||||
@@ -77,7 +77,7 @@ public partial class Addresses : ComponentBase
|
||||
{
|
||||
try
|
||||
{
|
||||
await UserAddressContract.DeleteUserAddressAsync(new() { Id = id });
|
||||
await UserAddressContract.DeleteCustomerAddressAsync(new() { Id = id });
|
||||
Snackbar.Add("آدرس حذف شد.", Severity.Success);
|
||||
await LoadAddresses();
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ public partial class AddAddressDialog : ComponentBase
|
||||
|
||||
private MudForm? _form;
|
||||
private bool _isSaving;
|
||||
private CreateNewUserAddressRequest _request = new();
|
||||
private CreateCustomerAddressRequest _request = new();
|
||||
private object? _selectedCity;
|
||||
|
||||
private async Task<IEnumerable<object>> SearchCities(string value, CancellationToken ct)
|
||||
@@ -56,7 +56,7 @@ public partial class AddAddressDialog : ComponentBase
|
||||
_isSaving = true;
|
||||
try
|
||||
{
|
||||
var response = await UserAddressContract.CreateNewUserAddressAsync(_request);
|
||||
var response = await UserAddressContract.CreateCustomerAddressAsync(_request);
|
||||
Snackbar.Add("آدرس با موفقیت اضافه شد.", Severity.Success);
|
||||
MudDialog.Close(DialogResult.Ok(true));
|
||||
}
|
||||
|
||||
@@ -13,11 +13,11 @@ public partial class EditAddressDialog : ComponentBase
|
||||
[Inject] private UserAddressContract.UserAddressContractClient UserAddressContract { get; set; } = default!;
|
||||
[Inject] private CityContract.CityContractClient CityContract { get; set; } = default!;
|
||||
|
||||
[Parameter] public GetAllUserAddressByFilterResponseModel? Model { get; set; }
|
||||
[Parameter] public CustomerAddressModel? Model { get; set; }
|
||||
|
||||
private MudForm? _form;
|
||||
private bool _isSaving;
|
||||
private UpdateUserAddressRequest _request = new();
|
||||
private UpdateCustomerAddressRequest _request = new();
|
||||
private object? _selectedCity;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
@@ -25,7 +25,7 @@ public partial class EditAddressDialog : ComponentBase
|
||||
await base.OnInitializedAsync();
|
||||
if (Model != null)
|
||||
{
|
||||
_request = Model.Adapt<UpdateUserAddressRequest>();
|
||||
_request = Model.Adapt<UpdateCustomerAddressRequest>();
|
||||
|
||||
// Load selected city if CityId exists
|
||||
if (Model.CityId > 0)
|
||||
@@ -90,7 +90,7 @@ public partial class EditAddressDialog : ComponentBase
|
||||
_isSaving = true;
|
||||
try
|
||||
{
|
||||
await UserAddressContract.UpdateUserAddressAsync(_request);
|
||||
await UserAddressContract.UpdateCustomerAddressAsync(_request);
|
||||
Snackbar.Add("آدرس با موفقیت ویرایش شد.", Severity.Success);
|
||||
MudDialog.Close(DialogResult.Ok(true));
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public partial class Index
|
||||
private bool _isProcessingPayment;
|
||||
|
||||
// Address management
|
||||
private List<GetAllUserAddressByFilterResponseModel> _addresses = new();
|
||||
private List<CustomerAddressModel> _addresses = new();
|
||||
private bool _isLoadingAddresses;
|
||||
private CreateNewUserAddressRequest _newAddressRequest = new();
|
||||
private UpdateUserAddressRequest _editAddressRequest = new();
|
||||
@@ -251,20 +251,20 @@ public partial class Index
|
||||
_isLoadingAddresses = true;
|
||||
try
|
||||
{
|
||||
var response = await UserAddressContract.GetAllUserAddressByFilterAsync(request: new());
|
||||
var response = await UserAddressContract.GetCustomerAddressesAsync(request: new());
|
||||
if (response?.Models?.Any() == true)
|
||||
{
|
||||
_addresses = response.Models.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
_addresses = new List<GetAllUserAddressByFilterResponseModel>();
|
||||
_addresses = new List<CustomerAddressModel>();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Snackbar.Add($"خطا در بارگذاری آدرسها: {ex.Message}", Severity.Error);
|
||||
_addresses = new List<GetAllUserAddressByFilterResponseModel>();
|
||||
_addresses = new List<CustomerAddressModel>();
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -284,7 +284,7 @@ public partial class Index
|
||||
}
|
||||
}
|
||||
|
||||
private async Task OpenEditAddressDialog(GetAllUserAddressByFilterResponseModel address)
|
||||
private async Task OpenEditAddressDialog(CustomerAddressModel address)
|
||||
{
|
||||
var dialog = await DialogService.ShowAsync<EditAddressDialog>("ویرایش آدرس", new DialogParameters<EditAddressDialog>
|
||||
{
|
||||
|
||||
@@ -12,20 +12,20 @@
|
||||
<MudGrid Spacing="2">
|
||||
<MudItem xs="12" sm="6" md="4">
|
||||
<MudPaper Elevation="2" Class="pa-4 rounded-lg">
|
||||
<MudText Typo="Typo.subtitle2" Class="mud-text-secondary">موجودی اعتباری</MudText>
|
||||
<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" md="4">
|
||||
<MudPaper Elevation="2" Class="pa-4 rounded-lg">
|
||||
<MudText Typo="Typo.subtitle2" Class="mud-text-secondary">موجودی فروشگاه تخفیفی</MudText>
|
||||
<MudText Typo="Typo.h4" Color="Color.Warning">@_balances.Discount</MudText>
|
||||
<MudText Typo="Typo.subtitle2" Class="mud-text-secondary">موجودی شبکه</MudText>
|
||||
<MudText Typo="Typo.h4" Color="Color.Success">@_balances.Network</MudText>
|
||||
</MudPaper>
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="6" md="4">
|
||||
<MudPaper Elevation="2" Class="pa-4 rounded-lg">
|
||||
<MudText Typo="Typo.subtitle2" Class="mud-text-secondary">موجودی پاداش تیمی</MudText>
|
||||
<MudText Typo="Typo.h4" Color="Color.Success">@_balances.Network</MudText>
|
||||
<MudText Typo="Typo.subtitle2" Class="mud-text-secondary">موجودی تخفیفی</MudText>
|
||||
<MudText Typo="Typo.h4" Color="Color.Warning">@_balances.Discount</MudText>
|
||||
</MudPaper>
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
@@ -71,18 +71,45 @@
|
||||
</MudGrid>
|
||||
|
||||
<MudHidden Breakpoint="Breakpoint.MdAndUp" Invert="true">
|
||||
<MudTable Items="_txs" Dense="true">
|
||||
<MudTable Items="_txs" Dense="true" Hover="true" Striped="true">
|
||||
<HeaderContent>
|
||||
<MudTh>تاریخ</MudTh>
|
||||
<MudTh>مبلغ</MudTh>
|
||||
<MudTh>مسیر</MudTh>
|
||||
<MudTh>عادی (تغییرات / مانده)</MudTh>
|
||||
<MudTh>شبکه (تغییرات / مانده)</MudTh>
|
||||
<MudTh>تخفیفی (تغییرات / مانده)</MudTh>
|
||||
<MudTh>شناسه ارجاع</MudTh>
|
||||
<MudTh>توضیحات</MudTh>
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd>@context.Date</MudTd>
|
||||
<MudTd Color="@(context.Amount > 0 ? Color.Success : Color.Error)">@FormatPrice(context.Amount)</MudTd>
|
||||
<MudTd>@context.Channel</MudTd>
|
||||
<MudTd>@context.Description</MudTd>
|
||||
<MudTd DataLabel="تاریخ">
|
||||
<MudText Typo="Typo.caption">@context.Date</MudText>
|
||||
</MudTd>
|
||||
<MudTd DataLabel="عادی">
|
||||
<MudStack Spacing="0">
|
||||
<MudText Color="@(context.CreditChange > 0 ? Color.Success : context.CreditChange < 0 ? Color.Error : Color.Default)" Typo="Typo.body2">
|
||||
@(context.CreditChange != 0 ? (context.CreditChange > 0 ? "+" : "") + FormatPrice(context.CreditChange) : "-")
|
||||
</MudText>
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">@FormatPrice(context.CreditBalance)</MudText>
|
||||
</MudStack>
|
||||
</MudTd>
|
||||
<MudTd DataLabel="شبکه">
|
||||
<MudStack Spacing="0">
|
||||
<MudText Color="@(context.NetworkChange > 0 ? Color.Success : context.NetworkChange < 0 ? Color.Error : Color.Default)" Typo="Typo.body2">
|
||||
@(context.NetworkChange != 0 ? (context.NetworkChange > 0 ? "+" : "") + FormatPrice(context.NetworkChange) : "-")
|
||||
</MudText>
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">@FormatPrice(context.NetworkBalance)</MudText>
|
||||
</MudStack>
|
||||
</MudTd>
|
||||
<MudTd DataLabel="تخفیفی">
|
||||
<MudStack Spacing="0">
|
||||
<MudText Color="@(context.DiscountChange > 0 ? Color.Success : context.DiscountChange < 0 ? Color.Error : Color.Default)" Typo="Typo.body2">
|
||||
@(context.DiscountChange != 0 ? (context.DiscountChange > 0 ? "+" : "") + FormatPrice(context.DiscountChange) : "-")
|
||||
</MudText>
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">@FormatPrice(context.DiscountBalance)</MudText>
|
||||
</MudStack>
|
||||
</MudTd>
|
||||
<MudTd DataLabel="شناسه">@context.Channel</MudTd>
|
||||
<MudTd DataLabel="توضیحات">@context.Description</MudTd>
|
||||
</RowTemplate>
|
||||
</MudTable>
|
||||
</MudHidden>
|
||||
@@ -91,13 +118,50 @@
|
||||
<MudStack Spacing="2">
|
||||
@foreach (var tx in _txs)
|
||||
{
|
||||
<MudPaper Class="pa-3 rounded-lg" Outlined="true">
|
||||
<MudStack Spacing="1">
|
||||
<MudPaper Class="pa-3 rounded-lg" Outlined="true" Elevation="1">
|
||||
<MudStack Spacing="2">
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center">
|
||||
<MudText>@tx.Date</MudText>
|
||||
<MudText Color="@(tx.Amount > 0 ? Color.Success : Color.Error)">@FormatPrice(tx.Amount)</MudText>
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">@tx.Date</MudText>
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">شناسه: @tx.Channel</MudText>
|
||||
</MudStack>
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">@tx.Channel</MudText>
|
||||
|
||||
<MudDivider />
|
||||
|
||||
<MudStack Row="true" Spacing="2" Justify="Justify.SpaceBetween">
|
||||
<!-- کیف پول عادی -->
|
||||
<MudPaper Class="pa-2 flex-grow-1" Outlined="true">
|
||||
<MudStack Spacing="1" AlignItems="AlignItems.Center">
|
||||
<MudText Typo="Typo.caption" Color="Color.Primary">عادی</MudText>
|
||||
<MudText Color="@(tx.CreditChange > 0 ? Color.Success : tx.CreditChange < 0 ? Color.Error : Color.Default)" Style="font-weight: 600; font-size: 0.75rem;">
|
||||
@(tx.CreditChange != 0 ? (tx.CreditChange > 0 ? "+" : "") + FormatPrice(tx.CreditChange) : "-")
|
||||
</MudText>
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary" Style="font-size: 0.7rem;">@FormatPrice(tx.CreditBalance)</MudText>
|
||||
</MudStack>
|
||||
</MudPaper>
|
||||
|
||||
<!-- کیف پول شبکه -->
|
||||
<MudPaper Class="pa-2 flex-grow-1" Outlined="true">
|
||||
<MudStack Spacing="1" AlignItems="AlignItems.Center">
|
||||
<MudText Typo="Typo.caption" Color="Color.Success">شبکه</MudText>
|
||||
<MudText Color="@(tx.NetworkChange > 0 ? Color.Success : tx.NetworkChange < 0 ? Color.Error : Color.Default)" Style="font-weight: 600; font-size: 0.75rem;">
|
||||
@(tx.NetworkChange != 0 ? (tx.NetworkChange > 0 ? "+" : "") + FormatPrice(tx.NetworkChange) : "-")
|
||||
</MudText>
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary" Style="font-size: 0.7rem;">@FormatPrice(tx.NetworkBalance)</MudText>
|
||||
</MudStack>
|
||||
</MudPaper>
|
||||
|
||||
<!-- کیف پول تخفیفی -->
|
||||
<MudPaper Class="pa-2 flex-grow-1" Outlined="true">
|
||||
<MudStack Spacing="1" AlignItems="AlignItems.Center">
|
||||
<MudText Typo="Typo.caption" Color="Color.Warning">تخفیفی</MudText>
|
||||
<MudText Color="@(tx.DiscountChange > 0 ? Color.Success : tx.DiscountChange < 0 ? Color.Error : Color.Default)" Style="font-weight: 600; font-size: 0.75rem;">
|
||||
@(tx.DiscountChange != 0 ? (tx.DiscountChange > 0 ? "+" : "") + FormatPrice(tx.DiscountChange) : "-")
|
||||
</MudText>
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary" Style="font-size: 0.7rem;">@FormatPrice(tx.DiscountBalance)</MudText>
|
||||
</MudStack>
|
||||
</MudPaper>
|
||||
</MudStack>
|
||||
|
||||
<MudText Typo="Typo.body2">@tx.Description</MudText>
|
||||
</MudStack>
|
||||
</MudPaper>
|
||||
|
||||
Reference in New Issue
Block a user