Compare commits
2 Commits
c764614d26
...
acad1a719f
| Author | SHA1 | Date | |
|---|---|---|---|
| acad1a719f | |||
| c7e6d01c11 |
@@ -429,6 +429,8 @@ else
|
|||||||
@* ═══════════════════════════════════════════════
|
@* ═══════════════════════════════════════════════
|
||||||
6. TESTIMONIALS
|
6. TESTIMONIALS
|
||||||
═══════════════════════════════════════════════ *@
|
═══════════════════════════════════════════════ *@
|
||||||
|
@if (_testimonials.Count > 0)
|
||||||
|
{
|
||||||
<section class="section-landing">
|
<section class="section-landing">
|
||||||
<MudContainer MaxWidth="MaxWidth.Large">
|
<MudContainer MaxWidth="MaxWidth.Large">
|
||||||
<div class="text-center mb-8 fade-in-up">
|
<div class="text-center mb-8 fade-in-up">
|
||||||
@@ -465,6 +467,7 @@ else
|
|||||||
</MudGrid>
|
</MudGrid>
|
||||||
</MudContainer>
|
</MudContainer>
|
||||||
</section>
|
</section>
|
||||||
|
}
|
||||||
|
|
||||||
@* ═══════════════════════════════════════════════
|
@* ═══════════════════════════════════════════════
|
||||||
7. FAQ
|
7. FAQ
|
||||||
|
|||||||
@@ -193,9 +193,10 @@ public partial class Index : IDisposable
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ── Testimonials ──
|
// ── Testimonials ──
|
||||||
if (_settings?.Testimonials?.Any() == true)
|
// اگر تنظیمات از CMS لود شده، لیست خالی یعنی ادمین عمداً حذف کرده — بدون fallback hardcode
|
||||||
|
if (_settings is not null)
|
||||||
{
|
{
|
||||||
_testimonials = _settings.Testimonials
|
_testimonials = (_settings.Testimonials ?? [])
|
||||||
.Select((t, i) => new TestimonialItem(t.Quote ?? "", t.Name ?? "", t.Role ?? "", i * 150))
|
.Select((t, i) => new TestimonialItem(t.Quote ?? "", t.Name ?? "", t.Role ?? "", i * 150))
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,75 +1,96 @@
|
|||||||
@attribute [Route(RouteConstants.Store.Orders)]
|
@attribute [Route(RouteConstants.Store.Orders)]
|
||||||
@* Injection is handled in code-behind *@
|
|
||||||
|
|
||||||
<PageTitle>سفارشات من</PageTitle>
|
<PageTitle>سفارشات من</PageTitle>
|
||||||
|
|
||||||
<MudContainer MaxWidth="MaxWidth.Large" Class="py-6">
|
<MudContainer MaxWidth="MaxWidth.Large" Class="py-6">
|
||||||
|
<MudStack Spacing="3">
|
||||||
<PageHeader Title="سفارشات من" BackHref="@RouteConstants.Store.Products" />
|
<PageHeader Title="سفارشات من" BackHref="@RouteConstants.Store.Products" />
|
||||||
|
|
||||||
@if (_loading)
|
@if (_loading)
|
||||||
{
|
{
|
||||||
<LoadingState />
|
<LoadingState />
|
||||||
}
|
}
|
||||||
else if (_orders.Count == 0)
|
else if (_orders.Count == 0)
|
||||||
{
|
{
|
||||||
<MudAlert Severity="Severity.Info">هنوز سفارشی ثبت نکردهاید.</MudAlert>
|
<MudAlert Severity="Severity.Info">هنوز سفارشی ثبت نشده است.</MudAlert>
|
||||||
|
<MudButton Variant="Variant.Outlined" StartIcon="@Icons.Material.Filled.Store"
|
||||||
|
Href="@RouteConstants.Store.Products">
|
||||||
|
مشاهده فروشگاه
|
||||||
|
</MudButton>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
<!-- Desktop Table -->
|
||||||
<MudHidden Breakpoint="Breakpoint.MdAndUp" Invert="true">
|
<MudHidden Breakpoint="Breakpoint.MdAndUp" Invert="true">
|
||||||
<MudTable Items="_orders" Dense="true">
|
<MudPaper Elevation="1" Class="pa-4 rounded-lg">
|
||||||
|
<MudTable Items="_orders">
|
||||||
<HeaderContent>
|
<HeaderContent>
|
||||||
<MudTh>شناسه</MudTh>
|
<MudTh>شماره سفارش</MudTh>
|
||||||
|
<MudTh>تعداد اقلام</MudTh>
|
||||||
|
<MudTh>مبلغ کل</MudTh>
|
||||||
|
<MudTh>وضعیت پرداخت</MudTh>
|
||||||
|
<MudTh>وضعیت ارسال</MudTh>
|
||||||
<MudTh>تاریخ</MudTh>
|
<MudTh>تاریخ</MudTh>
|
||||||
<MudTh>وضعیت</MudTh>
|
|
||||||
<MudTh>مبلغ</MudTh>
|
|
||||||
<MudTh></MudTh>
|
<MudTh></MudTh>
|
||||||
</HeaderContent>
|
</HeaderContent>
|
||||||
<RowTemplate>
|
<RowTemplate>
|
||||||
<MudTd>@context.Id</MudTd>
|
<MudTd>@context.Id</MudTd>
|
||||||
|
<MudTd>@GetItemsCount(context)</MudTd>
|
||||||
|
<MudTd>@FormatPrice(GetTotalAmount(context))</MudTd>
|
||||||
<MudTd>
|
<MudTd>
|
||||||
@if (context.PaymentDate != null)
|
<MudChip T="string" Size="Size.Small"
|
||||||
{
|
Color="@GetPaymentStatusColor(context.PaymentStatus)"
|
||||||
@context.PaymentDate.ToDateTime().MiladiToJalaliWithTime()
|
Variant="Variant.Filled">
|
||||||
}
|
@GetPaymentStatusText(context.PaymentStatus)
|
||||||
else
|
</MudChip>
|
||||||
{
|
|
||||||
<text>در انتظار پرداخت</text>
|
|
||||||
}
|
|
||||||
</MudTd>
|
</MudTd>
|
||||||
<MudTd>@GetStatusText(context.PaymentStatus)</MudTd>
|
|
||||||
<MudTd>@FormatPrice(context.FactorDetails.Sum(s=>(s.UnitPrice ?? 0) * (s.Count ?? 0)))</MudTd>
|
|
||||||
<MudTd>
|
<MudTd>
|
||||||
<MudButton Variant="Variant.Text" Href="@($"{RouteConstants.Store.OrderDetail}{context.Id}")" StartIcon="@Icons.Material.Filled.Receipt">جزئیات</MudButton>
|
<MudChip T="string" Size="Size.Small"
|
||||||
|
Color="@GetDeliveryStatusColor((int)context.DeliveryStatus)"
|
||||||
|
Variant="Variant.Outlined">
|
||||||
|
@GetDeliveryStatusText((int)context.DeliveryStatus)
|
||||||
|
</MudChip>
|
||||||
|
</MudTd>
|
||||||
|
<MudTd>@FormatDate(context)</MudTd>
|
||||||
|
<MudTd>
|
||||||
|
<MudButton Size="Size.Small" Variant="Variant.Outlined" Color="Color.Primary"
|
||||||
|
OnClick="() => ViewOrder(context.Id)">
|
||||||
|
جزئیات
|
||||||
|
</MudButton>
|
||||||
</MudTd>
|
</MudTd>
|
||||||
</RowTemplate>
|
</RowTemplate>
|
||||||
</MudTable>
|
</MudTable>
|
||||||
|
</MudPaper>
|
||||||
</MudHidden>
|
</MudHidden>
|
||||||
|
|
||||||
|
<!-- Mobile Cards -->
|
||||||
<MudHidden Breakpoint="Breakpoint.MdAndUp">
|
<MudHidden Breakpoint="Breakpoint.MdAndUp">
|
||||||
<MudStack Spacing="2">
|
<MudStack Spacing="2">
|
||||||
@foreach (var o in _orders)
|
@foreach (var order in _orders)
|
||||||
{
|
{
|
||||||
<MudPaper Class="pa-3 rounded-lg" Outlined="true">
|
<MudPaper Class="pa-3 rounded-lg cursor-pointer" Outlined="true"
|
||||||
|
@onclick="() => ViewOrder(order.Id)">
|
||||||
<MudStack Spacing="1">
|
<MudStack Spacing="1">
|
||||||
<MudStack Row="true" Justify="Justify.SpaceBetween">
|
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center">
|
||||||
<MudText>سفارش #@o.Id</MudText>
|
<MudText Typo="Typo.subtitle2">سفارش #@order.Id</MudText>
|
||||||
<MudText Class="mud-text-secondary">
|
<MudChip T="string" Size="Size.Small"
|
||||||
@if (o.PaymentDate != null)
|
Color="@GetPaymentStatusColor(order.PaymentStatus)"
|
||||||
{
|
Variant="Variant.Filled">
|
||||||
@o.PaymentDate.ToDateTime().MiladiToJalaliWithTime()
|
@GetPaymentStatusText(order.PaymentStatus)
|
||||||
}
|
</MudChip>
|
||||||
else
|
|
||||||
{
|
|
||||||
<text>در انتظار پرداخت</text>
|
|
||||||
}
|
|
||||||
</MudText>
|
|
||||||
</MudStack>
|
</MudStack>
|
||||||
<MudStack Row="true" Justify="Justify.SpaceBetween">
|
<MudStack Row="true" Justify="Justify.SpaceBetween">
|
||||||
<MudText>وضعیت: @GetStatusText(o.PaymentStatus)</MudText>
|
<MudText Typo="Typo.caption" Class="mud-text-secondary">@FormatDate(order)</MudText>
|
||||||
<MudText Color="Color.Primary">@FormatPrice(o.FactorDetails.Sum(s=>(s.UnitPrice ?? 0) * (s.Count ?? 0)))</MudText>
|
<MudChip T="string" Size="Size.Small"
|
||||||
|
Color="@GetDeliveryStatusColor((int)order.DeliveryStatus)"
|
||||||
|
Variant="Variant.Outlined">
|
||||||
|
@GetDeliveryStatusText((int)order.DeliveryStatus)
|
||||||
|
</MudChip>
|
||||||
</MudStack>
|
</MudStack>
|
||||||
<MudStack Row="true" Justify="Justify.FlexEnd">
|
<MudDivider />
|
||||||
<MudButton Size="Size.Small" Variant="Variant.Outlined" Href="@($"{RouteConstants.Store.OrderDetail}{o.Id}")" StartIcon="@Icons.Material.Filled.Receipt">جزئیات</MudButton>
|
<MudStack Row="true" Justify="Justify.SpaceBetween">
|
||||||
|
<MudText Typo="Typo.body2">@GetItemsCount(order) قلم</MudText>
|
||||||
|
<MudText Typo="Typo.body2" Class="fw-semibold">@FormatPrice(GetTotalAmount(order)) تومان</MudText>
|
||||||
</MudStack>
|
</MudStack>
|
||||||
</MudStack>
|
</MudStack>
|
||||||
</MudPaper>
|
</MudPaper>
|
||||||
@@ -77,4 +98,5 @@
|
|||||||
</MudStack>
|
</MudStack>
|
||||||
</MudHidden>
|
</MudHidden>
|
||||||
}
|
}
|
||||||
|
</MudStack>
|
||||||
</MudContainer>
|
</MudContainer>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using System;
|
|
||||||
using CMSMicroservice.Protobuf.Protos.UserOrder;
|
using CMSMicroservice.Protobuf.Protos.UserOrder;
|
||||||
|
using DateTimeConverterCL;
|
||||||
using FrontOffice.Main.Utilities;
|
using FrontOffice.Main.Utilities;
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
using Messages = CMSMicroservice.Protobuf.Protos;
|
using Messages = CMSMicroservice.Protobuf.Protos;
|
||||||
@@ -10,7 +10,6 @@ namespace FrontOffice.Main.Pages.Store;
|
|||||||
public partial class Orders : ComponentBase
|
public partial class Orders : ComponentBase
|
||||||
{
|
{
|
||||||
[Inject] private OrderService OrderService { get; set; } = default!;
|
[Inject] private OrderService OrderService { get; set; } = default!;
|
||||||
[Inject] private VATService VAT { get; set; } = default!;
|
|
||||||
|
|
||||||
private List<GetUserOrderResponse> _orders = new();
|
private List<GetUserOrderResponse> _orders = new();
|
||||||
private bool _loading;
|
private bool _loading;
|
||||||
@@ -33,28 +32,81 @@ public partial class Orders : ComponentBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
private void ViewOrder(long orderId)
|
||||||
{
|
{
|
||||||
if (firstRender)
|
Navigation.NavigateTo($"{RouteConstants.Store.OrderDetail}{orderId}");
|
||||||
{
|
|
||||||
// بارگذاری نرخ VAT
|
|
||||||
await VAT.LoadAsync();
|
|
||||||
}
|
|
||||||
await base.OnAfterRenderAsync(firstRender);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string FormatPrice(long price) => string.Format("{0:N0} تومان", price);
|
private static string FormatPrice(long price) => $"{price:N0}";
|
||||||
|
|
||||||
|
private static string FormatDate(GetUserOrderResponse order)
|
||||||
private string GetStatusText(Messages.PaymentStatus contextPaymentStatus)
|
|
||||||
{
|
{
|
||||||
return contextPaymentStatus switch
|
try
|
||||||
|
{
|
||||||
|
var timestamp = order.PaymentDate;
|
||||||
|
if (timestamp is null)
|
||||||
|
return "در انتظار پرداخت";
|
||||||
|
|
||||||
|
return timestamp.ToDateTime().ToLocalTime().MiladiToJalaliWithTime();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return "—";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int GetItemsCount(GetUserOrderResponse order) =>
|
||||||
|
order.FactorDetails.Sum(f => f.Count ?? 0);
|
||||||
|
|
||||||
|
private static long GetTotalAmount(GetUserOrderResponse order)
|
||||||
|
{
|
||||||
|
if (order.VatInfo is not null && order.VatInfo.TotalAmount > 0)
|
||||||
|
return order.VatInfo.TotalAmount;
|
||||||
|
|
||||||
|
if (order.Amount > 0)
|
||||||
|
return order.Amount;
|
||||||
|
|
||||||
|
return order.FactorDetails.Sum(f => (f.UnitPrice ?? 0) * (f.Count ?? 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetPaymentStatusText(Messages.PaymentStatus status) => status switch
|
||||||
{
|
{
|
||||||
Messages.PaymentStatus.Pending => "در انتظار پرداخت",
|
Messages.PaymentStatus.Pending => "در انتظار پرداخت",
|
||||||
Messages.PaymentStatus.Success => "پرداخت شده",
|
Messages.PaymentStatus.Success => "پرداخت شده",
|
||||||
Messages.PaymentStatus.Reject => "پرداخت ناموفق",
|
Messages.PaymentStatus.Reject => "پرداخت ناموفق",
|
||||||
_ => "نامشخص",
|
_ => "نامشخص"
|
||||||
|
};
|
||||||
|
|
||||||
|
private static Color GetPaymentStatusColor(Messages.PaymentStatus status) => status switch
|
||||||
|
{
|
||||||
|
Messages.PaymentStatus.Pending => Color.Warning,
|
||||||
|
Messages.PaymentStatus.Success => Color.Success,
|
||||||
|
Messages.PaymentStatus.Reject => Color.Error,
|
||||||
|
_ => Color.Default
|
||||||
|
};
|
||||||
|
|
||||||
|
// Domain/public_messages: None=0, Pending=1, InTransit=2, Delivered=3, Returned=4, Cancelled=5, ReadyForOfficePickup=6
|
||||||
|
private static string GetDeliveryStatusText(int status) => status switch
|
||||||
|
{
|
||||||
|
0 => "بدون ارسال",
|
||||||
|
1 => "در انتظار ارسال",
|
||||||
|
2 => "ارسال شده",
|
||||||
|
3 => "تحویل داده شده",
|
||||||
|
4 => "مرجوع شده",
|
||||||
|
5 => "لغو شده",
|
||||||
|
6 => "آماده تحویل در دفتر",
|
||||||
|
_ => "نامشخص"
|
||||||
|
};
|
||||||
|
|
||||||
|
private static Color GetDeliveryStatusColor(int status) => status switch
|
||||||
|
{
|
||||||
|
0 => Color.Default,
|
||||||
|
1 => Color.Warning,
|
||||||
|
2 => Color.Primary,
|
||||||
|
3 => Color.Success,
|
||||||
|
4 => Color.Error,
|
||||||
|
5 => Color.Dark,
|
||||||
|
6 => Color.Primary,
|
||||||
|
_ => Color.Default
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user