File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed
WooCommerce/Classes/ViewRelated/Coupons/CouponDetails Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -83,14 +83,20 @@ struct CouponDetails: View {
8383 . secondaryBodyStyle ( )
8484 Text ( viewModel. discountedOrdersCount)
8585 . font ( . title)
86+ Spacer ( )
8687 }
8788 . frame ( maxWidth: . infinity, alignment: . leading)
8889
8990 VStack ( alignment: . leading, spacing: Constants . verticalSpacing) {
9091 Text ( Localization . amount)
9192 . secondaryBodyStyle ( )
92- Text ( viewModel. discountedAmount)
93- . font ( . title)
93+ if let amount = viewModel. discountedAmount {
94+ Text ( amount)
95+ . font ( . title)
96+ } else {
97+ ActivityIndicator ( isAnimating: . constant( true ) , style: . medium)
98+ }
99+ Spacer ( )
94100 }
95101 . padding ( . leading, Constants . margin)
96102 . frame ( maxWidth: . infinity, alignment: . leading)
Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ final class CouponDetailsViewModel: ObservableObject {
4242
4343 /// Total amount deducted from orders that applied the coupon
4444 ///
45- @Published private( set) var discountedAmount : String = " "
45+ @Published private( set) var discountedAmount : String ?
4646
4747 /// The current coupon
4848 ///
@@ -61,7 +61,6 @@ final class CouponDetailsViewModel: ObservableObject {
6161 self . coupon = coupon
6262 self . stores = stores
6363 self . currencySettings = currencySettings
64- self . discountedAmount = formatStringAmount ( " 0 " )
6564 populateDetails ( )
6665 }
6766
@@ -102,6 +101,10 @@ private extension CouponDetailsViewModel {
102101 func populateDetails( ) {
103102 couponCode = coupon. code
104103 description = coupon. description
104+ discountedOrdersCount = " \( coupon. usageCount) "
105+ if coupon. usageCount == 0 {
106+ discountedAmount = formatStringAmount ( " 0 " )
107+ }
105108
106109 switch coupon. discountType {
107110 case . percent:
You can’t perform that action at this time.
0 commit comments