Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
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
840 changes: 454 additions & 386 deletions DashWallet.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "eye_closed-icon@x1.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "eye_closed-icon@x2.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "eye_closed-icon@x3.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "eye_opened-icon@x1.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "eye_opened-icon@x2.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "eye_opened-icon@x3.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "icon-gift_card-piggy_cards@x1.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "icon-gift_card-piggy_cards@x2.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "icon-gift_card-piggy_cards@x3.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "minus-icon@x1.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "minus-icon@x2.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "minus-icon@x3.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "plus-icon@x1.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "plus-icon@x2.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "plus-icon@x3.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -138,112 +138,181 @@ class ExploreDatabaseConnection {
}

private func insertTestMerchant() {
print("🎯 ExploreDatabaseConnection: Adding test merchant...")
print("🎯 ExploreDatabaseConnection: Adding test merchants...")

guard let db = self.db else {
print("🎯 ExploreDatabaseConnection: Database not ready yet")
return
}

// Add PiggyCards test merchant
addPiggyCardsTestMerchant(db: db)
addPiggyCardsTestMerchants(db: db)
}

private func addPiggyCardsTestMerchant(db: Connection) {
do {
let testMerchantId = "2e393eee-4508-47fe-954d-66209333fc96"

// Check if merchant already exists
let checkQuery = "SELECT COUNT(*) FROM merchant WHERE merchantId = '\(testMerchantId)'"
let count = try db.scalar(checkQuery) as? Int64 ?? 0

if count > 0 {
print("🎯 PiggyCards test merchant already exists, skipping")
return
}
private struct PiggyCardsTestMerchant {
let merchantId: String
let name: String
let sourceId: String
let merchantSavings: Int
let merchantDenomType: String
let providerSavings: Int
let providerDenomType: String
let logo: String
let website: String
let territory: String?
let city: String?
}

print("🎯 Adding PiggyCards test merchant...")
// Matches Android PiggyCardsTestMerchants data
private let piggyCardsTestMerchants: [PiggyCardsTestMerchant] = [
PiggyCardsTestMerchant(
merchantId: "2e393eee-4508-47fe-954d-66209333fc96",
name: "Piggy Cards Test Merchant",
sourceId: "177",
merchantSavings: -250,
merchantDenomType: "Fixed",
providerSavings: 100,
providerDenomType: "fixed",
logo: "https://piggy.cards/image/catalog/piggycards/logo2023_mobile.png",
website: "https://piggy.cards",
territory: "MA",
city: "Boston"
),
PiggyCardsTestMerchant(
merchantId: "2e393fff-4508-47fe-954d-66209333fc96",
name: "Piggy Cards Flexible Test Merchant",
sourceId: "177",
merchantSavings: -250,
merchantDenomType: "min-max",
providerSavings: -250,
providerDenomType: "min-max",
logo: "https://piggy.cards/image/catalog/piggycards/logo2023_mobile.png",
website: "https://piggy.cards",
territory: "MA",
city: "Boston"
),
PiggyCardsTestMerchant(
merchantId: "2e393aaa-4508-47fe-954d-66209333fc96",
name: "Home Depot [Flexible]",
sourceId: "74",
merchantSavings: 100,
merchantDenomType: "min-max",
providerSavings: -50,
providerDenomType: "min-max",
logo: "https://piggy.cards/image/catalog/piggycards/Home_Depot_Copy.jpg",
website: "https://www.homedepot.com",
territory: nil,
city: nil
),
PiggyCardsTestMerchant(
merchantId: "2e393ddd-4508-47fe-954d-66209333fc96",
name: "Apple [Flexible]",
sourceId: "13",
merchantSavings: 100,
merchantDenomType: "min-max",
providerSavings: 100,
providerDenomType: "min-max",
logo: "https://piggy.cards/image/catalog/incenti/8aaa3d5d-logo.png",
website: "https://www.apple.com",
territory: nil,
city: nil
),
PiggyCardsTestMerchant(
merchantId: "2e393ccc-4508-47fe-954d-66209333fc96",
name: "Dominos [Flexible]",
sourceId: "45",
merchantSavings: 100,
merchantDenomType: "min-max",
providerSavings: 150,
providerDenomType: "min-max",
logo: "https://piggy.cards/image/catalog/incenti/68ea431c-logo.png",
website: "https://www.dominos.com",
territory: nil,
city: nil
),
]

private func addPiggyCardsTestMerchants(db: Connection) {
do {
let allIds = piggyCardsTestMerchants.map { "'\($0.merchantId)'" }.joined(separator: ", ")

// Wrap all FTS trigger operations in a transaction for atomicity
try db.transaction {
// Drop FTS triggers temporarily
// Drop FTS triggers to allow merchant table modifications
try db.run("DROP TRIGGER IF EXISTS room_fts_content_sync_merchant_fts_AFTER_INSERT")
try db.run("DROP TRIGGER IF EXISTS room_fts_content_sync_merchant_fts_AFTER_UPDATE")
try db.run("DROP TRIGGER IF EXISTS room_fts_content_sync_merchant_fts_BEFORE_UPDATE")
try db.run("DROP TRIGGER IF EXISTS room_fts_content_sync_merchant_fts_BEFORE_DELETE")

// Insert merchant with unique prefix
// Delete existing test merchants (matches Android delete+re-insert pattern)
try db.run("""
INSERT INTO merchant (
merchantId, name, source, sourceId, logoLocation, active, paymentMethod,
savingsPercentage, denominationsType, type, redeemType, territory, city,
website, addDate, updateDate
) VALUES (
'2e393eee-4508-47fe-954d-66209333fc96',
'Piggy Cards Test Merchant',
'PiggyCards',
'177',
'https://piggy.cards/image/catalog/piggycards/logo2023_mobile.png',
1,
'gift card',
1000,
'Fixed',
'online',
'online',
'MA',
'Boston',
'https://piggy.cards',
datetime('now'),
datetime('now')
DELETE FROM merchant_fts
WHERE docid IN (
SELECT rowid
FROM merchant
WHERE source = 'PiggyCards' AND merchantId IN (\(allIds))
)
""")

let insertedRowId = db.lastInsertRowid

// Insert gift_card_providers record
try db.run("""
INSERT INTO gift_card_providers (
merchantId, provider, sourceId, savingsPercentage,
denominationsType, active, redeemType
) VALUES (
'2e393eee-4508-47fe-954d-66209333fc96',
'PiggyCards',
'177',
10,
'fixed',
1,
'online'
)
DELETE FROM gift_card_providers
WHERE provider = 'PiggyCards' AND merchantId IN (\(allIds))
""")

// Update FTS index
try db.run("""
INSERT INTO merchant_fts(docid, name)
VALUES (\(insertedRowId), 'Piggy Cards Test Merchant')
DELETE FROM merchant
WHERE source = 'PiggyCards' AND merchantId IN (\(allIds))
""")

// Insert all test merchants
for m in piggyCardsTestMerchants {
let territory = "'\(m.territory ?? "")'"
let city = "'\(m.city ?? "")'"

try db.run("""
INSERT INTO merchant (
merchantId, name, source, sourceId, logoLocation, active, paymentMethod,
savingsPercentage, denominationsType, type, redeemType, territory, city,
website, addDate, updateDate
) VALUES (
'\(m.merchantId)', '\(m.name)', 'PiggyCards', '\(m.sourceId)',
'\(m.logo)', 1, 'gift card', \(m.merchantSavings),
'\(m.merchantDenomType)', 'online', 'online',
\(territory), \(city), '\(m.website)',
datetime('now'), datetime('now')
)
""")

let rowId = db.lastInsertRowid

try db.run("""
INSERT INTO gift_card_providers (
merchantId, provider, sourceId, savingsPercentage,
denominationsType, active, redeemType
) VALUES (
'\(m.merchantId)', 'PiggyCards', '\(m.sourceId)',
\(m.providerSavings), '\(m.providerDenomType)', 1, 'online'
)
""")

try db.run("INSERT INTO merchant_fts(docid, name) VALUES (\(rowId), '\(m.name)')")
}

// Recreate FTS triggers
try db.run("""
CREATE TRIGGER room_fts_content_sync_merchant_fts_BEFORE_UPDATE
BEFORE UPDATE ON merchant BEGIN
DELETE FROM merchant_fts WHERE docid=OLD.rowid;
END
""")

try db.run("""
CREATE TRIGGER room_fts_content_sync_merchant_fts_BEFORE_DELETE
BEFORE DELETE ON merchant BEGIN
DELETE FROM merchant_fts WHERE docid=OLD.rowid;
END
""")

try db.run("""
CREATE TRIGGER room_fts_content_sync_merchant_fts_AFTER_UPDATE
AFTER UPDATE ON merchant BEGIN
INSERT INTO merchant_fts(docid, name) VALUES (NEW.rowid, NEW.name);
END
""")

try db.run("""
CREATE TRIGGER room_fts_content_sync_merchant_fts_AFTER_INSERT
AFTER INSERT ON merchant BEGIN
Expand All @@ -252,10 +321,9 @@ class ExploreDatabaseConnection {
""")
}

print("✅ PiggyCards test merchant added successfully")

print("✅ PiggyCards test merchants added successfully (\(piggyCardsTestMerchants.count) merchants)")
} catch {
print("🎯 Error adding PiggyCards test merchant: \(error)")
print("🎯 Error adding PiggyCards test merchants: \(error)")
}
}
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ class PiggyCardsConstants {
static let tokenExpirationSeconds = 3600
static let serviceFeePercent = 1.5 // 1.5% service fee deducted from discount
static let orderPollingDelayMs = 250 // Delay before first status check
static let maxOrderAmount: Decimal = 2500
}
Loading
Loading