Skip to content

Commit

Permalink
Merge pull request #1571 from HedvigInsurance/fix/tier/add-from-in-pr…
Browse files Browse the repository at this point in the history
…emium

Add “from” price if it’s the lowest
  • Loading branch information
juliaendre authored Oct 17, 2024
2 parents 4dc2772 + eba16ed commit 8130ffa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions Projects/ChangeTier/Sources/Models/ChangeTierIntentModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,15 @@ public struct Tier: Codable, Equatable, Hashable, Identifiable {
self.exposureName = exposureName
}

func getPremium() -> MonetaryAmount? {
func getPremiumLabel() -> String? {
if quotes.count == 1 {
return quotes.first?.premium
return quotes.first?.premium.formattedAmountPerMonth
} else {
if let smallestPremium = quotes.sorted(by: { $0.premium.amount < $1.premium.amount }).first?.premium
.formattedAmountWithoutSymbol
{
return L10n.tierFlowPriceLabel(smallestPremium)
}
}
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions Projects/ChangeTier/Sources/Views/EditTierScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ struct EditTierScreen: View {
HStack {
hText(tier.quotes.first?.productVariant?.displayNameTier ?? tier.name)
Spacer()
if let premiumValue = tier.getPremium()?.formattedAmountPerMonth {
if let premiumLabel = tier.getPremiumLabel() {
hPill(
text: premiumValue,
text: premiumLabel,
color: .grey(translucent: false),
colorLevel: .one
)
Expand Down

0 comments on commit 8130ffa

Please sign in to comment.