Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for displayPurchaseHistoryLink #4686

Merged
merged 31 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
01aa502
added first version of purchase history view
aboedo Jan 2, 2025
6210762
clean up
aboedo Jan 2, 2025
34ac201
more UI updates
aboedo Jan 2, 2025
196e224
add a couple of notes, clean up
aboedo Jan 2, 2025
d7e0c5d
remove navigation stack wrapper from PurchaseHistoryView
facumenzella Jan 9, 2025
9ea5101
ignore swiftlint
facumenzella Jan 14, 2025
b2cc1c9
Update PurchaseLinkView.swift
hiddevdploeg Jan 14, 2025
8b9d08d
feat: CompatibilityLabeledContent
facumenzella Jan 14, 2025
9a70e54
Merge branch 'main' into feat/customer-center-history
facumenzella Jan 14, 2025
2211c83
introduce PurchaseDetailViewModel with items
facumenzella Jan 14, 2025
9dcd8e3
Merge branch 'main' into feat/customer-center-history
facumenzella Jan 15, 2025
893ca63
feat: Add non subscription support
facumenzella Jan 15, 2025
e8c524d
nit: add missing headers
facumenzella Jan 15, 2025
d0c4b59
feat: Added price
facumenzella Jan 15, 2025
731f925
added displayPurchaseHistoryLink
facumenzella Jan 17, 2025
9a017b5
missing localizations
facumenzella Jan 17, 2025
4f6e4c7
added loading state
facumenzella Jan 17, 2025
50c6047
hide button if not enabled
facumenzella Jan 17, 2025
53ff3cd
feat: [CustomerCenter] Final tweaks for History
facumenzella Jan 20, 2025
6998d48
fix: Broken xcodeproj
facumenzella Jan 20, 2025
073a90e
update ContactSupportUtilitiesTests
facumenzella Jan 20, 2025
384d6f8
unused_declaration
facumenzella Jan 20, 2025
78d2525
nits
facumenzella Jan 20, 2025
3665dd1
add generic error view
facumenzella Jan 20, 2025
dc9f93b
nit CompatibilityNavigationStack
facumenzella Jan 20, 2025
2a89473
list all cases instead of default
facumenzella Jan 20, 2025
aee1e06
Merge branch 'main' into feat/customer-center-history2
facumenzella Jan 20, 2025
dc25e97
added Sendable conformance
facumenzella Jan 20, 2025
8176d06
Merge branch 'main' into feat/customer-center-history2
facumenzella Jan 20, 2025
53ae35d
pod lib lint fixed issues
facumenzella Jan 20, 2025
e768944
nit: Rename CSCommonLocalizedString to CCLocalizedString
facumenzella Jan 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added displayPurchaseHistoryLink
  • Loading branch information
facumenzella committed Jan 17, 2025
commit 731f925d19963872bd9fd691e93d73ed85185848
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ enum CustomerCenterConfigTestData {
// swiftlint:disable:next function_body_length
static func customerCenterData(
lastPublishedAppVersion: String?,
shouldWarnCustomerToUpdate: Bool = false
shouldWarnCustomerToUpdate: Bool = false,
displayPurchaseHistoryLink: Bool = false
) -> CustomerCenterConfigData {
CustomerCenterConfigData(
screens: [.management:
Expand Down Expand Up @@ -116,7 +117,8 @@ enum CustomerCenterConfigTestData {
),
support: .init(
email: "test-support@revenuecat.com",
shouldWarnCustomerToUpdate: shouldWarnCustomerToUpdate
shouldWarnCustomerToUpdate: shouldWarnCustomerToUpdate,
displayPurchaseHistoryLink: displayPurchaseHistoryLink
),
lastPublishedAppVersion: lastPublishedAppVersion,
productId: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,26 +50,28 @@ struct PurchaseHistoryView: View {
// todo: add information for non subscriptions
// and get product type and other info directly from StoreKit or backend

Section(header: Text(String(localized: "Other"))) {
ForEach(viewModel.nonSubscriptions) { inactiveSubscription in
Button {
viewModel.selectedPurchase = inactiveSubscription
} label: {
PurchaseLinkView(purchaseInfo: inactiveSubscription)
if !viewModel.nonSubscriptions.isEmpty {
Section(header: Text(String(localized: "Other"))) {
ForEach(viewModel.nonSubscriptions) { inactiveSubscription in
Button {
viewModel.selectedPurchase = inactiveSubscription
} label: {
PurchaseLinkView(purchaseInfo: inactiveSubscription)
}
}
}
}

// Account Details Section
// todo: make these easy to copy
Section(header: Text("Account Details")) {
Section(header: Text(String(localized: "Account Details"))) {
CompatibilityLabeledContent(
String(localized: "Date when app was first purchased:"),
String(localized: "Date when app was first purchased"),
content: dateFormatter.string(from: info.originalPurchaseDate!)
)

CompatibilityLabeledContent(
String(localized: "App User ID"),
String(localized: "User ID"),
content: info.originalAppUserId
)
.contextMenu {
Expand All @@ -96,14 +98,6 @@ struct PurchaseHistoryView: View {
}
}

private func expirationDescription(for productId: String, in info: CustomerInfo) -> String {
if let expirationDate = info.expirationDate(forProductIdentifier: productId) {
return "Expires on \(dateFormatter.string(from: expirationDate))"
} else {
return "No expiration date available"
}
}

private var dateFormatter: DateFormatter {
let formatter = DateFormatter()
formatter.dateStyle = .medium
Expand Down
6 changes: 5 additions & 1 deletion Sources/CustomerCenter/CustomerCenterConfigData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -413,13 +413,16 @@ public struct CustomerCenterConfigData {

public let email: String
public let shouldWarnCustomerToUpdate: Bool
public let displayPurchaseHistoryLink: Bool

public init(
email: String,
shouldWarnCustomerToUpdate: Bool
shouldWarnCustomerToUpdate: Bool,
displayPurchaseHistoryLink: Bool
) {
self.email = email
self.shouldWarnCustomerToUpdate = shouldWarnCustomerToUpdate
self.displayPurchaseHistoryLink = displayPurchaseHistoryLink
}

}
Expand Down Expand Up @@ -556,6 +559,7 @@ extension CustomerCenterConfigData.Support {
init(from response: CustomerCenterConfigResponse.Support) {
self.email = response.email
self.shouldWarnCustomerToUpdate = response.shouldWarnCustomerToUpdate ?? true
self.displayPurchaseHistoryLink = false
}

}
Expand Down