Skip to content

Commit

Permalink
refactor: select -> selected
Browse files Browse the repository at this point in the history
  • Loading branch information
ha1f committed Jul 4, 2024
1 parent 16f8fa2 commit 9d59cfd
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public struct ProductPurchaseContentLogic {
public init() {}

public struct State: Equatable {
var selectProductID: String?
var selectedProductID: String?
let appAccountToken: UUID
public let products: [MembershipProduct]
public var isActivityIndicatorVisible = false
Expand All @@ -26,7 +26,7 @@ public struct ProductPurchaseContentLogic {
) {
self.appAccountToken = appAccountToken
self.products = products
selectProductID = products.first(where: { $0.isRecommended })?.appleProduct.id ?? products.first?.appleProduct.id
selectedProductID = products.first(where: { $0.isRecommended })?.appleProduct.id ?? products.first?.appleProduct.id
}
}

Expand Down Expand Up @@ -54,7 +54,7 @@ public struct ProductPurchaseContentLogic {
return .send(.updateRows, animation: .default)

case let .rows(.element(id, .rowButtonTapped)):
state.selectProductID = id
state.selectedProductID = id
return .run { send in
await feedbackGenerator.impactOccurred()
await send(.updateRows, animation: .default)
Expand All @@ -69,7 +69,7 @@ public struct ProductPurchaseContentLogic {
price: $0.appleProduct.price,
currencyCode: $0.appleProduct.priceFormatStyle.currencyCode,
displayPrice: $0.id.contains("1week") ? nil : $0.appleProduct.displayPrice,
isSelected: $0.id == state.selectProductID,
isSelected: $0.id == state.selectedProductID,
isMostPopular: $0.isMostPopular
)
}
Expand All @@ -84,7 +84,7 @@ public struct ProductPurchaseContentLogic {
}

case .purchaseButtonTapped:
guard let product = state.products.first(where: { $0.appleProduct.id == state.selectProductID })
guard let product = state.products.first(where: { $0.appleProduct.id == state.selectedProductID })
else { return .none }

state.isActivityIndicatorVisible = true
Expand Down

0 comments on commit 9d59cfd

Please sign in to comment.