adds the pack of 10 units

newoffer2025
Laurent 2 months ago
parent 28973c4bcf
commit d3c443d116
  1. 4
      PadelClubData/Subscriptions/Guard.swift
  2. 4
      PadelClubData/Subscriptions/StoreItem.swift
  3. 4
      PadelClubData/Subscriptions/StoreManager.swift

@ -235,7 +235,9 @@ import Combine
let purchases = DataStore.shared.purchases
let units = purchases.filter { $0.productId == StoreItem.unit.rawValue }
return units.reduce(0) { $0 + ($1.quantity ?? 0) }
let units10Pack = purchases.filter { $0.productId == StoreItem.unit10Pack.rawValue }
return units.reduce(0) { $0 + ($1.quantity ?? 0) } + 10 * units10Pack.reduce(0) { $0 + ($1.quantity ?? 0) }
// let units = self.userFilteredPurchases().filter { $0.productID == StoreItem.unit.rawValue }
// return units.reduce(0) { $0 + $1.purchasedQuantity }

@ -11,6 +11,7 @@ public enum StoreItem: String, Identifiable, CaseIterable {
case monthlyUnlimited = "app.padelclub.tournament.subscription.unlimited"
case fivePerMonth = "app.padelclub.tournament.subscription.five.per.month"
case unit = "app.padelclub.tournament.unit"
case unit10Pack = "app.padelclub.tournament.unit.10"
#if DEBUG
public static let five: Int = 2
@ -25,13 +26,14 @@ public enum StoreItem: String, Identifiable, CaseIterable {
case .monthlyUnlimited: return "infinity.circle.fill"
case .fivePerMonth: return "star.circle.fill"
case .unit: return "tennisball.circle.fill"
case .unit10Pack: return "10.circle.fill"
}
}
public var isConsumable: Bool {
switch self {
case .monthlyUnlimited, .fivePerMonth: return false
case .unit: return true
case .unit, .unit10Pack: return true
}
}

@ -68,11 +68,11 @@ public class StoreManager {
var items: [StoreItem] = []
switch Guard.main.currentPlan {
case .fivePerMonth:
items = [StoreItem.unit, StoreItem.monthlyUnlimited]
items = [StoreItem.unit, StoreItem.unit10Pack, StoreItem.monthlyUnlimited]
case .monthlyUnlimited:
break
default:
items = StoreItem.allCases
items = [StoreItem.unit, StoreItem.unit10Pack, StoreItem.monthlyUnlimited]
}
return items.map { $0.rawValue }
}

Loading…
Cancel
Save