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 };