diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Components/UserOrders/Default.cshtml b/apps/public-web/src/EShopOnAbp.PublicWeb/Components/UserOrders/Default.cshtml new file mode 100644 index 00000000..cad59f57 --- /dev/null +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Components/UserOrders/Default.cshtml @@ -0,0 +1,76 @@ +@using System.Globalization +@using EShopOnAbp.Localization +@using Microsoft.Extensions.Localization +@model EShopOnAbp.PublicWeb.Components.UserOrders.UserOrderWidgetViewComponent.UserOrderViewModel +@inject IStringLocalizer L + +@if (Model.ServiceError) +{ +
SERVICE ERROR
+} + + @Model.UserOrders.Count sipariş verildi. + +@foreach (var order in Model.UserOrders) +{ + var orderTotalString = order.Items.Sum(q => q.UnitPrice).ToString("C", new CultureInfo("en-US")); + string addressString = $"{order.Address.Street} {order.Address.ZipCode} \n {order.Address.City}/{order.Address.Country}"; +
+
+
+
+
Sipariş Tarihi
+
@order.OrderDate.ToString("dd MMMM yyyy")
+
+
+
Toplam
+
@orderTotalString
+
+
+
Teslimat Adresi
+
+ @order.Address.Description +
+
+
+
+ Sipariş No @order.OrderNo.ToString("N0", new NumberFormatInfo() {NumberGroupSeparator = " "}) +
+
+
+
+
+ @foreach (var item in order.Items) + { + + +
+

@order.OrderStatus

+
+ + + + + +
@item.ProductName
+
Ürünü iade edebileceğiniz son tarih: @order.OrderDate.AddMonths(1).ToString("dd MMMM yyyy")
+
+ +
+
+ + + Ürünleri iade et + + + Ürün yorumu yazın + + +
+
+
+ } +
+
+
+} \ No newline at end of file diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Components/UserOrders/UserOrderWidgetScriptContributor.cs b/apps/public-web/src/EShopOnAbp.PublicWeb/Components/UserOrders/UserOrderWidgetScriptContributor.cs new file mode 100644 index 00000000..c04eb3da --- /dev/null +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Components/UserOrders/UserOrderWidgetScriptContributor.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; +using Volo.Abp.AspNetCore.Mvc.UI.Bundling; + +namespace EShopOnAbp.PublicWeb.Components.UserOrders; + +public class UserOrderWidgetScriptContributor : BundleContributor +{ + public override void ConfigureBundle(BundleConfigurationContext context) + { + context.Files.AddIfNotContains("/components/user-orders/user-order-widget.js"); + } +} \ No newline at end of file diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Components/UserOrders/UserOrderWidgetStyleContributor.cs b/apps/public-web/src/EShopOnAbp.PublicWeb/Components/UserOrders/UserOrderWidgetStyleContributor.cs new file mode 100644 index 00000000..bd98d748 --- /dev/null +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Components/UserOrders/UserOrderWidgetStyleContributor.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; +using Volo.Abp.AspNetCore.Mvc.UI.Bundling; + +namespace EShopOnAbp.PublicWeb.Components.UserOrders; + +public class UserOrderWidgetStyleContributor : BundleContributor +{ + public override void ConfigureBundle(BundleConfigurationContext context) + { + context.Files.AddIfNotContains("/components/user-orders/user-order-widget.css"); + } +} \ No newline at end of file diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Components/UserOrders/UserOrderWidgetViewComponent.cs b/apps/public-web/src/EShopOnAbp.PublicWeb/Components/UserOrders/UserOrderWidgetViewComponent.cs new file mode 100644 index 00000000..31627b0f --- /dev/null +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Components/UserOrders/UserOrderWidgetViewComponent.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using EShopOnAbp.OrderingService.Orders; +using Microsoft.AspNetCore.Mvc; +using Volo.Abp.AspNetCore.Mvc; +using Volo.Abp.AspNetCore.Mvc.UI.Widgets; + +namespace EShopOnAbp.PublicWeb.Components.UserOrders; + +[Widget( + AutoInitialize = true, + RefreshUrl = "/Widgets/MyOrders", + StyleTypes = new[] {typeof(UserOrderWidgetStyleContributor)}, + ScriptTypes = new[] {typeof(UserOrderWidgetScriptContributor)} +)] +public class UserOrderWidgetViewComponent : AbpViewComponent +{ + private readonly IOrderAppService _orderAppService; + public UserOrderViewModel ViewModel { get; set; } = new(); + + public UserOrderWidgetViewComponent(IOrderAppService orderAppService) + { + _orderAppService = orderAppService; + } + + public async Task InvokeAsync(string filter) + { + try + { + ViewModel.UserOrders = await _orderAppService.GetMyOrdersAsync(new GetMyOrdersInput {Filter = filter}); + } + catch (Exception e) + { + ViewModel.ServiceError = true; + ViewModel.UserOrders = new List(); + Console.WriteLine(e); + } + + return View("~/Components/UserOrders/Default.cshtml", ViewModel); + } + + public class UserOrderViewModel + { + public List UserOrders { get; set; } + public bool ServiceError { get; set; } + } +} \ No newline at end of file diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/MyOrders.cshtml b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/MyOrders.cshtml index ba3799e3..eaf32853 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/MyOrders.cshtml +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/MyOrders.cshtml @@ -1,7 +1,7 @@ @page @using EShopOnAbp.Localization @using Microsoft.Extensions.Localization -@using System.Globalization +@using EShopOnAbp.PublicWeb.Components.UserOrders @model EShopOnAbp.PublicWeb.Pages.MyOrdersModel @inject IStringLocalizer L @@ -18,124 +18,26 @@ @{ string lastYearString = $"y{DateTime.Today.Year - 1}"; + string filter = ""; + var selectList = new List + { + new(@L["Last30Days"], "last30", selected: true), + new(@L["LastMonth"], "m1"), + new(@L["Last3Months"], "m3"), + new(@L["LastYear"], lastYearString), + new("2020", "y2020"), + new("2019", "y2019") + }; } -
+
- @Model.MyOrders.Count sipariş verildi. - - + +
-@foreach (var order in Model.MyOrders) -{ - var orderTotalString = order.Items.Sum(q => q.UnitPrice).ToString("C", new CultureInfo("en-US")); - string addressString = $"{order.Address.Street} {order.Address.ZipCode} \n {order.Address.City}/{order.Address.Country}"; -
-
-
-
-
Sipariş Tarihi
-
@order.OrderDate.ToString("dd MMMM yyyy")
-
-
-
Toplam
-
@orderTotalString
-
-
-
Teslimat Adresi
-
- @order.Address.Description -
-
-
-
- Sipariş No @order.OrderNo.ToString("N0", new NumberFormatInfo() {NumberGroupSeparator = " "}) -
-
-
-
-
- @foreach (var item in order.Items) - { - - -
-

@order.OrderStatus

-
- - - - - -
@item.ProductName
-
Ürünü iade edebileceğiniz son tarih: @order.OrderDate.AddMonths(1).ToString("dd MMMM yyyy")
-
- -
-
- - - Ürünleri iade et - - - Ürün yorumu yazın - - -
-
-
- } -
-
-
-} - - - - - - - - - - - - - - -@* @foreach (var item in Model.MyOrders) *@ -@* { *@ -@* *@ -@* *@ -@*
@item.OrderDate
*@ -@*

@item.OrderStatus

*@ -@*

@item.Buyer.Name

*@ -@* *@ -@* @foreach (var product in item.Items) *@ -@* { *@ -@* *@ -@* *@ -@* *@ -@* *@ -@* *@ -@* *@ -@*

@product.ProductName x @product.Units

*@ -@*
*@ -@*
*@ -@*
*@ -@* } *@ -@*
*@ -@*
*@ -@*
*@ -@*
*@ -@* } *@ \ No newline at end of file +
+ @await Component.InvokeAsync(typeof(UserOrderWidgetViewComponent), new {Filter = Model.OrderFilter}) +
\ No newline at end of file diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/MyOrders.cshtml.cs b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/MyOrders.cshtml.cs index 710c5d84..c7dccf65 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/MyOrders.cshtml.cs +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/MyOrders.cshtml.cs @@ -1,22 +1,14 @@ -using System.Collections.Generic; -using System.Threading.Tasks; -using EShopOnAbp.OrderingService.Orders; +using System.Threading.Tasks; using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; namespace EShopOnAbp.PublicWeb.Pages; public class MyOrdersModel : AbpPageModel { - private readonly IOrderAppService _orderAppService; - public List MyOrders { get; set; } + public string OrderFilter { get; set; } - public MyOrdersModel(IOrderAppService orderAppService) + public async Task OnGet(string filter) { - _orderAppService = orderAppService; - } - - public async Task OnGet() - { - MyOrders = await _orderAppService.GetMyOrdersAsync(new GetMyOrdersInput()); + OrderFilter = filter; } } \ No newline at end of file diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/myOrders.js b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/myOrders.js index c7ba7a01..d13b0593 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/myOrders.js +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/myOrders.js @@ -16,15 +16,11 @@ }); }); - $('#date-filter-selecter').on("change", el => { + $('#OrderFilter').on("change", el => { const filter = el.target.value; - console.log(filter); - eShopOnAbp.orderingService.orders.order.getMyOrders({ - filter: filter - }).then(res => { - console.log(res); - }); - }) + location.href=`?filter=${filter}` + }); + $('#total-orders').val($('#total-order-count').val()); }); })(); \ No newline at end of file diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/components/user-orders/user-order-widget.css b/apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/components/user-orders/user-order-widget.css new file mode 100644 index 00000000..e69de29b diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/components/user-orders/user-order-widget.js b/apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/components/user-orders/user-order-widget.js new file mode 100644 index 00000000..e69de29b