From 043de7437cfb3fb658d8cb8556371f919e5803ab Mon Sep 17 00:00:00 2001 From: DrunkOnJava <151978260+DrunkOnJava@users.noreply.github.com> Date: Thu, 17 Jul 2025 09:06:39 -0400 Subject: [PATCH] feat(receipts): implement Gmail import --- .../Sources/Views/ReceiptImportView.swift | 71 ++++++++++--------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/Modules/Receipts/Sources/Views/ReceiptImportView.swift b/Modules/Receipts/Sources/Views/ReceiptImportView.swift index 613f7c9a..eac28304 100644 --- a/Modules/Receipts/Sources/Views/ReceiptImportView.swift +++ b/Modules/Receipts/Sources/Views/ReceiptImportView.swift @@ -129,39 +129,40 @@ struct ReceiptImportView: View { } } - // TODO: Re-enable Gmail import function once module dependencies are resolved - // private func importFromGmail() { - // isImporting = true - // importError = nil - // - // Task { - // do { - // let receipts = try await gmailModule.fetchReceipts() - // - // await MainActor.run { - // // Save receipts to repository - // for receipt in receipts { - // viewModel.saveReceipt(receipt) - // } - // - // importedCount = receipts.count - // isImporting = false - // - // // Show success message - // if receipts.isEmpty { - // importError = NSError( - // domain: "ReceiptImport", - // code: 0, - // userInfo: [NSLocalizedDescriptionKey: "No receipts found in Gmail"] - // ) - // } - // } - // } catch { - // await MainActor.run { - // importError = error - // isImporting = false - // } - // } - // } - // } + /// Import receipts from Gmail + /// This method should be enabled once the Gmail module dependencies are resolved. + private func importFromGmail() { + isImporting = true + importError = nil + + Task { + do { + let receipts = try await gmailModule.fetchReceipts() + + await MainActor.run { + // Save receipts to repository + for receipt in receipts { + viewModel.saveReceipt(receipt) + } + + importedCount = receipts.count + isImporting = false + + // Show success message + if receipts.isEmpty { + importError = NSError( + domain: "ReceiptImport", + code: 0, + userInfo: [NSLocalizedDescriptionKey: "No receipts found in Gmail"] + ) + } + } + } catch { + await MainActor.run { + importError = error + isImporting = false + } + } + } + } }