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 96f2a3b5..08495130 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/Components/Payment/Default.cshtml +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Components/Payment/Default.cshtml @@ -12,40 +12,47 @@
-

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.Type

-
-

@address.ToString()

-
- -
- } -
- } -
- } +
Select Address
+ + @foreach (var address in Model.Address) + { + string isSelectedAddressClass = address.IsDefault ? "is-selected" : string.Empty; + +
+
+

@address.Type

+
+
+

@address.ToString()

+
+ +
+
+ } +
-

Select Payment Method

+
Select Payment Method
- - - paypal logo - - + @foreach (var paymentType in Model.PaymentTypes) + { + string isSelectedClass = paymentType.IsDefault ? "is-selected" : ""; + + + +

+ @paymentType.Name +

+

+ +

+
+
+
+ }
+
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 e0335a7a..0e458afa 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/Components/Payment/PaymentWidgetViewComponent.cs +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Components/Payment/PaymentWidgetViewComponent.cs @@ -18,19 +18,25 @@ public class PaymentWidgetViewComponent : AbpViewComponent { private readonly UserBasketProvider _userBasketProvider; private readonly UserAddressProvider _userAddressProvider; + private readonly PaymentTypeProvider _paymentTypeProvider; - public PaymentWidgetViewComponent(UserBasketProvider userBasketProvider, UserAddressProvider userAddressProvider) + public PaymentWidgetViewComponent( + UserBasketProvider userBasketProvider, + UserAddressProvider userAddressProvider, + PaymentTypeProvider paymentTypeProvider) { _userBasketProvider = userBasketProvider; _userAddressProvider = userAddressProvider; + _paymentTypeProvider = paymentTypeProvider; } public async Task InvokeAsync() { - var viewModel = new PaymentViewModel() + var viewModel = new PaymentViewModel { Basket = await _userBasketProvider.GetBasketAsync(), - Address = _userAddressProvider.GetDemoAddresses() + Address = _userAddressProvider.GetDemoAddresses(), + PaymentTypes = _paymentTypeProvider.GetPaymentTypes() }; return View("~/Components/Payment/Default.cshtml", viewModel); } @@ -40,4 +46,5 @@ public class PaymentViewModel { public BasketDto Basket { get; set; } public List Address { get; set; } + public List PaymentTypes { get; set; } } \ No newline at end of file diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Payment.cshtml b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Payment.cshtml index 96ece09b..bdfd8c57 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Payment.cshtml +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Payment.cshtml @@ -11,7 +11,6 @@ }
- @*

@L["Payment"]

*@
@await Component.InvokeAsync(typeof(PaymentWidgetViewComponent))
diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Payment.cshtml.cs b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Payment.cshtml.cs index d4191c8c..aac4373c 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Payment.cshtml.cs +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Payment.cshtml.cs @@ -59,7 +59,7 @@ public class PaymentModel : AbpPageModel var placedOrder = await _orderAppService.CreateAsync(new OrderCreateDto() { - PaymentTypeId = 1, // Paypal + PaymentTypeId = model.SelectedPaymentId, Address = GetUserAddress(model.SelectedAddressId), Products = productItems }); diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/ServiceProviders/PaymentTypeProvider.cs b/apps/public-web/src/EShopOnAbp.PublicWeb/ServiceProviders/PaymentTypeProvider.cs new file mode 100644 index 00000000..a2b9d755 --- /dev/null +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/ServiceProviders/PaymentTypeProvider.cs @@ -0,0 +1,24 @@ +using System.Collections.Generic; +using Volo.Abp.DependencyInjection; + +namespace EShopOnAbp.PublicWeb.ServiceProviders; + +public class PaymentTypeProvider : ITransientDependency +{ + public List GetPaymentTypes() + { + return new List + { + new() {Id = 0, Name = "Demo", IconCss = "fa-credit-card demo", IsDefault = true}, + new() {Id = 1, Name = "Paypal", IconCss = "fa-cc-paypal paypal"} + }; + } +} + +public class PaymentType +{ + public int Id { get; set; } + public string Name { get; set; } + public string IconCss { get; set; } + public bool IsDefault { get; set; } = false; +} \ No newline at end of file diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/ServiceProviders/UserAddressProvider.cs b/apps/public-web/src/EShopOnAbp.PublicWeb/ServiceProviders/UserAddressProvider.cs index 6e343752..9c69caa0 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/ServiceProviders/UserAddressProvider.cs +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/ServiceProviders/UserAddressProvider.cs @@ -26,8 +26,7 @@ public class UserAddressProvider : ITransientDependency Street = "Yeşilköy Serbest Bölge Mah. E-Blok Sk. Bakırköy", City = "İstanbul", Country = "Turkey", - ZipCode = "34149", - Description = "Near Ataturk Airport" + ZipCode = "34149" } }; } @@ -38,7 +37,6 @@ public class AddressDto public int Id { get; set; } public string Type { get; set; } public bool IsDefault { get; set; } = false; - public string Description { get; set; } public string Street { get; set; } public string City { get; set; } public string Country { get; set; } 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 1b38f784..90e9a095 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 @@ -17,4 +17,16 @@ .is-selected { border: solid #bfbfe3; +} + +.payment-type-header { + font-weight: 500; +} + +.paypal { + color: #6c84fa; +} + +.demo { + color: darkgray; } \ No newline at end of file diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/components/payment/payment-widget.js b/apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/components/payment/payment-widget.js index b246c5f1..1c541575 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/components/payment/payment-widget.js +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/components/payment/payment-widget.js @@ -6,12 +6,20 @@ $wrapper .find('.address-list .card') .click(function () { - var $this = $(this); - var addressId = $this.attr('data-address-id'); - abp.utils.setCookieValue("selected-address", addressId); + const $this = $(this); + // const addressId = $this.attr('data-address-id'); $this.parents(".address-list").find('.card').removeClass("is-selected"); $this.addClass("is-selected"); }); + + $wrapper + .find('.payment-list .card') + .click(el => { + const $this = $(el.currentTarget); + // const paymentTypeId = $this.attr('data-payment-id'); + $this.parents(".payment-list").find('.card').removeClass("is-selected"); + $this.addClass("is-selected"); + }); }; return {