From d58cf4be663d769376e8e398a6e09e5a91ffd9c1 Mon Sep 17 00:00:00 2001 From: Galip Tolga Erdem Date: Mon, 27 Dec 2021 22:21:09 +0300 Subject: [PATCH 1/2] added user-address provider --- .../Basket/UserAddressProvider.cs | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 apps/public-web/src/EShopOnAbp.PublicWeb/Basket/UserAddressProvider.cs diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Basket/UserAddressProvider.cs b/apps/public-web/src/EShopOnAbp.PublicWeb/Basket/UserAddressProvider.cs new file mode 100644 index 00000000..dba1f13f --- /dev/null +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Basket/UserAddressProvider.cs @@ -0,0 +1,32 @@ +using System.Collections.Generic; +using Volo.Abp.DependencyInjection; + +namespace EShopOnAbp.PublicWeb.Basket; + +public class UserAddressProvider : ITransientDependency +{ + public List GetDemoAddresses() + { + return new List() + { + new() + { + Name = "Home", + Description = "Cecilia Chapman Senior 711-2880 Nulla St. Mankato Mississippi 96522/USA", + IsDefault = true + }, + new() + { + Name = "Work", + Description = "Yeşilköy Serbest Bölge Mah. E-Blok Sokak E1 Blok No:2, Bakırköy/İstanbul" + } + }; + } +} + +public class AddressDto +{ + public string Name { get; set; } + public string Description { get; set; } + public bool IsDefault { get; set; } = false; +} \ No newline at end of file From aef9320bb93464c1ffa8233beb14096914918c6f Mon Sep 17 00:00:00 2001 From: Galip Tolga Erdem Date: Mon, 27 Dec 2021 22:21:16 +0300 Subject: [PATCH 2/2] updated payment widget --- .../Components/Payment/Default.cshtml | 34 +++++++++++++++++-- .../Payment/PaymentWidgetStyleContributor.cs | 5 +++ .../Payment/PaymentWidgetViewComponent.cs | 23 ++++++++++--- .../components/payment/payment-widget.css | 18 ++++++++++ 4 files changed, 73 insertions(+), 7 deletions(-) diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Components/Payment/Default.cshtml b/apps/public-web/src/EShopOnAbp.PublicWeb/Components/Payment/Default.cshtml index 400b2a4f..88ed30e7 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/Components/Payment/Default.cshtml +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Components/Payment/Default.cshtml @@ -1,19 +1,47 @@ @using EShopOnAbp.Localization @using EShopOnAbp.PublicWeb.Components.Purchase @using Microsoft.Extensions.Localization +@model EShopOnAbp.PublicWeb.Components.Payment.PaymentViewModel + @inject IStringLocalizer L +@{ + const int defaultColumnSize = 4; +} +
-
+

Select Address

+ @for (int i = 0; i < Math.Ceiling(Model.Address.Count / (double) defaultColumnSize); i++) + { + + @for (int j = 0; j < defaultColumnSize; j++) + { + + @if ((i * defaultColumnSize) + j < Model.Address.Count) + { + var address = Model.Address[(i * defaultColumnSize) + j]; + string isSelected = address.IsDefault ? "is-selected" : string.Empty; +
+
+

@address.Name

+

@address.Description

+
+
+ } +
+ } +
+ } +
-
+

Select Payment Method

@await Component.InvokeAsync(typeof(PurchaseWidgetViewComponent), - new {Basket = Model, ButtonDescription = "CompleteOrder"}) + new {Basket = Model.Basket, ButtonDescription = "CompleteOrder"})
\ No newline at end of file diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Components/Payment/PaymentWidgetStyleContributor.cs b/apps/public-web/src/EShopOnAbp.PublicWeb/Components/Payment/PaymentWidgetStyleContributor.cs index 361e2bb5..e4a64246 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/Components/Payment/PaymentWidgetStyleContributor.cs +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Components/Payment/PaymentWidgetStyleContributor.cs @@ -1,7 +1,12 @@ +using System.Collections.Generic; using Volo.Abp.AspNetCore.Mvc.UI.Bundling; namespace EShopOnAbp.PublicWeb.Components.Payment; public class PaymentWidgetStyleContributor: BundleContributor { + public override void ConfigureBundle(BundleConfigurationContext context) + { + context.Files.AddIfNotContains("/components/payment/payment-widget.css"); + } } \ No newline at end of file diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Components/Payment/PaymentWidgetViewComponent.cs b/apps/public-web/src/EShopOnAbp.PublicWeb/Components/Payment/PaymentWidgetViewComponent.cs index 38b7ef06..92b281fa 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/Components/Payment/PaymentWidgetViewComponent.cs +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Components/Payment/PaymentWidgetViewComponent.cs @@ -1,4 +1,6 @@ -using System.Threading.Tasks; +using System.Collections.Generic; +using System.Threading.Tasks; +using EShopOnAbp.BasketService; using EShopOnAbp.PublicWeb.Basket; using Microsoft.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc; @@ -12,17 +14,30 @@ namespace EShopOnAbp.PublicWeb.Components.Payment; StyleTypes = new[] {typeof(PaymentWidgetStyleContributor)}, ScriptTypes = new[] {typeof(PaymentWidgetScriptContributor)} )] -public class PaymentWidgetViewComponent: AbpViewComponent +public class PaymentWidgetViewComponent : AbpViewComponent { private readonly UserBasketProvider _userBasketProvider; + private readonly UserAddressProvider _userAddressProvider; - public PaymentWidgetViewComponent(UserBasketProvider userBasketProvider) + public PaymentWidgetViewComponent(UserBasketProvider userBasketProvider, UserAddressProvider userAddressProvider) { _userBasketProvider = userBasketProvider; + _userAddressProvider = userAddressProvider; } public async Task InvokeAsync() { - return View("~/Components/Payment/Default.cshtml", await _userBasketProvider.GetBasketAsync()); + var viewModel = new PaymentViewModel() + { + Basket = await _userBasketProvider.GetBasketAsync(), + Address = _userAddressProvider.GetDemoAddresses() + }; + return View("~/Components/Payment/Default.cshtml", viewModel); } +} + +public class PaymentViewModel +{ + public BasketDto Basket { get; set; } + public List Address { get; set; } } \ No newline at end of file diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/components/payment/payment-widget.css b/apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/components/payment/payment-widget.css index e69de29b..117d3043 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/components/payment/payment-widget.css +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/components/payment/payment-widget.css @@ -0,0 +1,18 @@ +.card { + /* Add shadows to create the "card" effect */ + box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2); + transition: 0.3s; +} + +/* On mouse-over, add a deeper shadow */ +.card:hover { + box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2); +} + +/* Add some padding inside the card container */ +.card-body { + padding: 2px 16px; +} +.is-selected{ + border: solid #bfbfe3; +} \ No newline at end of file