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:
masoodafar-web
2025-12-05 17:27:04 +03:30
parent feaaeada47
commit 68c114e43e
14 changed files with 1011 additions and 4 deletions
@@ -0,0 +1,125 @@
using FrontOffice.BFF.UserOrder.Protobuf.Protos.UserOrder;
using FrontOffice.Main.Utilities;
using Microsoft.AspNetCore.Components;
namespace FrontOffice.Main.Pages.Store;
public partial class OrderTracking : ComponentBase
{
[Inject] private OrderService OrderService { get; set; } = default!;
[Parameter] public long id { get; set; }
private GetUserOrderResponse? _order;
private bool _loading = true;
private List<TrackingStep> _trackingSteps = new();
protected override async Task OnInitializedAsync()
{
await LoadOrderAsync();
}
private async Task LoadOrderAsync()
{
_loading = true;
StateHasChanged();
try
{
var response = await OrderService.GetOrderAsync(id);
if (response is not null)
{
_order = response;
BuildTrackingSteps();
}
}
finally
{
_loading = false;
StateHasChanged();
}
}
private void BuildTrackingSteps()
{
if (_order is null) return;
// Build tracking steps based on PaymentStatus
var isPaid = _order.PaymentStatus == PaymentStatus.Success;
_trackingSteps = new List<TrackingStep>
{
new()
{
Title = "ثبت سفارش",
Description = "سفارش شما با موفقیت ثبت شد",
IsCompleted = true,
Date = FormatDate(_order.PaymentDate)
},
new()
{
Title = "در انتظار پرداخت",
Description = "منتظر تایید پرداخت هستیم",
IsCompleted = isPaid,
IsCurrent = !isPaid,
Date = isPaid ? FormatDate(_order.PaymentDate) : ""
},
new()
{
Title = "تایید پرداخت",
Description = "پرداخت شما تایید شد",
IsCompleted = isPaid,
IsCurrent = false,
Date = isPaid ? FormatDate(_order.PaymentDate) : ""
},
new()
{
Title = "در حال پردازش",
Description = "سفارش شما در حال آماده‌سازی است",
IsCompleted = false,
IsCurrent = isPaid,
Date = ""
},
new()
{
Title = "ارسال شده",
Description = "سفارش شما به پست تحویل داده شد",
IsCompleted = false,
IsCurrent = false,
Date = ""
},
new()
{
Title = "تحویل داده شده",
Description = "سفارش به دست شما رسید",
IsCompleted = false,
IsCurrent = false,
Date = ""
}
};
}
private static string FormatDate(Google.Protobuf.WellKnownTypes.Timestamp? timestamp)
{
if (timestamp is null) return "";
var date = timestamp.ToDateTime();
var persianCalendar = new System.Globalization.PersianCalendar();
return $"{persianCalendar.GetYear(date)}/{persianCalendar.GetMonth(date):00}/{persianCalendar.GetDayOfMonth(date):00}";
}
private static string GetPaymentMethodText(PaymentMethod method) => method switch
{
PaymentMethod.Ipg => "پرداخت آنلاین",
PaymentMethod.Wallet => "کیف پول",
_ => "نامشخص"
};
private class TrackingStep
{
public string Title { get; set; } = "";
public string Description { get; set; } = "";
public bool IsCompleted { get; set; }
public bool IsCurrent { get; set; }
public string Date { get; set; } = "";
}
}