From c764614d261406c8427dba730c70d1a8d7350ca5 Mon Sep 17 00:00:00 2001 From: masoodafar-web Date: Fri, 7 Aug 2026 17:35:05 +0330 Subject: [PATCH] feat(order-tracking): enhance tracking steps logic and delivery status handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Refactored the BuildTrackingSteps method to improve the logic for displaying order tracking steps based on various delivery statuses. - Added handling for new delivery statuses: "آماده تحویل در دفتر" and "مرجوع شده". - Updated the payment status step to consolidate descriptions based on payment completion. - Enhanced the overall user experience by providing clearer tracking information for different order states. These changes improve the clarity and functionality of the order tracking feature, ensuring users receive accurate updates on their order status. --- .../Pages/Store/OrderTracking.razor.cs | 121 ++++++++++++------ .../Utilities/DiscountOrderService.cs | 6 +- 2 files changed, 85 insertions(+), 42 deletions(-) diff --git a/src/FrontOffice.Main/Pages/Store/OrderTracking.razor.cs b/src/FrontOffice.Main/Pages/Store/OrderTracking.razor.cs index c15808c..585eae4 100644 --- a/src/FrontOffice.Main/Pages/Store/OrderTracking.razor.cs +++ b/src/FrontOffice.Main/Pages/Store/OrderTracking.razor.cs @@ -46,12 +46,19 @@ public partial class OrderTracking : ComponentBase private void BuildTrackingSteps() { if (_order is null) return; - - // Build tracking steps based on PaymentStatus + var isPaid = _order.PaymentStatus == Messages.PaymentStatus.Success; - - _trackingSteps = new List - { + // Domain/public_messages: None=0, Pending=1, InTransit=2, Delivered=3, Returned=4, Cancelled=5, ReadyForOfficePickup=6 + var delivery = (int)_order.DeliveryStatus; + var isCancelled = delivery == 5; + var isReturned = delivery == 4; + var isOfficePickup = delivery == 6; + var isInTransit = delivery == 2; + var isDelivered = delivery == 3; + var isPendingDelivery = delivery is 0 or 1; + + _trackingSteps = + [ new() { Title = "ثبت سفارش", @@ -61,45 +68,77 @@ public partial class OrderTracking : ComponentBase }, new() { - Title = "در انتظار پرداخت", - Description = "منتظر تایید پرداخت هستیم", + Title = "پرداخت", + Description = isPaid ? "پرداخت شما تایید شد" : "منتظر تایید پرداخت هستیم", IsCompleted = isPaid, - IsCurrent = !isPaid, + IsCurrent = !isPaid && !isCancelled, 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 = "" } - }; + ]; + + if (isCancelled) + { + _trackingSteps.Add(new() + { + Title = "لغو شده", + Description = "ارسال این سفارش لغو شده است", + IsCompleted = true, + IsCurrent = true, + Date = "" + }); + return; + } + + if (isReturned) + { + _trackingSteps.Add(new() + { + Title = "مرجوع شده", + Description = "سفارش مرجوع شده است", + IsCompleted = true, + IsCurrent = true, + Date = "" + }); + return; + } + + if (isOfficePickup) + { + _trackingSteps.Add(new() + { + Title = "آماده تحویل در دفتر", + Description = "سفارش برای تحویل حضوری در دفتر آماده است", + IsCompleted = true, + IsCurrent = true, + Date = "" + }); + return; + } + + _trackingSteps.Add(new() + { + Title = "در حال آماده‌سازی", + Description = "سفارش شما در حال آماده‌سازی است", + IsCompleted = isInTransit || isDelivered, + IsCurrent = isPaid && isPendingDelivery, + Date = "" + }); + _trackingSteps.Add(new() + { + Title = "ارسال شده", + Description = "سفارش شما به پست تحویل داده شد", + IsCompleted = isDelivered, + IsCurrent = isInTransit, + Date = "" + }); + _trackingSteps.Add(new() + { + Title = "تحویل داده شده", + Description = "سفارش به دست شما رسید", + IsCompleted = isDelivered, + IsCurrent = false, + Date = "" + }); } private static string FormatDate(Google.Protobuf.WellKnownTypes.Timestamp? timestamp) diff --git a/src/FrontOffice.Main/Utilities/DiscountOrderService.cs b/src/FrontOffice.Main/Utilities/DiscountOrderService.cs index 53c0d75..fe275d9 100644 --- a/src/FrontOffice.Main/Utilities/DiscountOrderService.cs +++ b/src/FrontOffice.Main/Utilities/DiscountOrderService.cs @@ -219,6 +219,8 @@ public class DiscountOrderService 2 => "ارسال شده", 3 => "تحویل داده شده", 4 => "لغو شده", + 5 => "آماده تحویل در دفتر", + 6 => "مرجوع شده", _ => "نامشخص" }; @@ -228,7 +230,9 @@ public class DiscountOrderService 1 => Color.Info, 2 => Color.Primary, 3 => Color.Success, - 4 => Color.Error, + 4 => Color.Dark, + 5 => Color.Primary, + 6 => Color.Error, _ => Color.Default };