From 18b0e8f07c2fe60cfa0a0a785c39668752a6cbca Mon Sep 17 00:00:00 2001 From: magohamote Date: Mon, 16 Oct 2023 17:28:09 +0200 Subject: [PATCH] address comment --- .../PaymentsUI/Sources/Extensions/PriceFormatter.swift | 6 +++--- .../PlanPresentation/V5/CurrentPlanDetailsV5.swift | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libraries/PaymentsUI/Sources/Extensions/PriceFormatter.swift b/libraries/PaymentsUI/Sources/Extensions/PriceFormatter.swift index b9fc7cb84..67c02d8f1 100644 --- a/libraries/PaymentsUI/Sources/Extensions/PriceFormatter.swift +++ b/libraries/PaymentsUI/Sources/Extensions/PriceFormatter.swift @@ -22,12 +22,12 @@ import Foundation enum PriceFormatter { - static func formatPlanPrice(price: Double, locale: Locale = Locale.current, currency: String? = nil, maximumFractionDigits: Int = 2) -> String { + static func formatPlanPrice(price: Double, locale: Locale = Locale.current, currencyCode: String? = nil, maximumFractionDigits: Int = 2) -> String { let formatter = NumberFormatter() formatter.numberStyle = .currency formatter.locale = locale - if let currency { - formatter.currencyCode = currency + if let currencyCode { + formatter.currencyCode = currencyCode } formatter.maximumFractionDigits = maximumFractionDigits let priceString = formatter.string(from: NSNumber(value: price)) ?? "" diff --git a/libraries/PaymentsUI/Sources/ViewModels/PlanPresentation/V5/CurrentPlanDetailsV5.swift b/libraries/PaymentsUI/Sources/ViewModels/PlanPresentation/V5/CurrentPlanDetailsV5.swift index 7a09a3151..f5c135692 100644 --- a/libraries/PaymentsUI/Sources/ViewModels/PlanPresentation/V5/CurrentPlanDetailsV5.swift +++ b/libraries/PaymentsUI/Sources/ViewModels/PlanPresentation/V5/CurrentPlanDetailsV5.swift @@ -73,8 +73,8 @@ struct CurrentPlanDetailsV5 { } var price: String - if let amount = details.amount { - price = PriceFormatter.formatPlanPrice(price: Double(amount) / 100, currency: details.currency) + if let amount = details.amount, amount != 0 { + price = PriceFormatter.formatPlanPrice(price: Double(amount) / 100, currencyCode: details.currency) } else { price = PUITranslations.plan_details_free_price.l10n }