commit 292eec0ec85c999dc379e078feb77f255edb2776 parent 17970268fad39017ac45db2497f51e880c4f85e0 Author: Marc Stibane <marc@taler.net> Date: Mon, 27 May 2024 23:00:39 +0200 prepare bankIntegrated without amount Diffstat:
| M | TalerWallet1/Model/Model+Withdraw.swift | | | 5 | +++-- |
| M | TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawURIView.swift | | | 25 | ++++++++++++++----------- |
2 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/TalerWallet1/Model/Model+Withdraw.swift b/TalerWallet1/Model/Model+Withdraw.swift @@ -46,8 +46,9 @@ struct WithdrawalExchangeAccountDetails: Decodable { // MARK: - /// The result from getWithdrawalDetailsForUri struct WithdrawUriInfoResponse: Decodable { - var amount: Amount - var defaultExchangeBaseUrl: String? + var amount: Amount? // if nil then ask User + var currency: String // use this if amount=nil + var defaultExchangeBaseUrl: String? // if nil then use possibleExchanges var possibleExchanges: [Exchange] // TODO: query these for fees? } /// A request to get an exchange's withdrawal details. diff --git a/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawURIView.swift b/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawURIView.swift @@ -95,18 +95,21 @@ struct WithdrawURIView: View { .task { symLog.log(".task") if let withdrawUriInfo = try? await model.getWithdrawalDetailsForUriM(url.absoluteString) { - let amount = withdrawUriInfo.amount - let baseUrl = withdrawUriInfo.defaultExchangeBaseUrl - ?? withdrawUriInfo.possibleExchanges.first?.exchangeBaseUrl - if let baseUrl { - exchange = try? await model.getExchangeByUrl(url: baseUrl) - if let details = try? await model.getWithdrawalDetailsForAmountM(baseUrl, amount: amount) { - withdrawalAmountDetails = details + if let amount = withdrawUriInfo.amount { + let baseUrl = withdrawUriInfo.defaultExchangeBaseUrl + ?? withdrawUriInfo.possibleExchanges.first?.exchangeBaseUrl + if let baseUrl { + exchange = try? await model.getExchangeByUrl(url: baseUrl) + if let details = try? await model.getWithdrawalDetailsForAmountM(baseUrl, amount: amount) { + withdrawalAmountDetails = details + } + // agePicker.setAges(ages: details?.ageRestrictionOptions) + } else { // TODO: error + symLog.log("no exchangeBaseUrl or no exchange") + withdrawalAmountDetails = nil } - // agePicker.setAges(ages: details?.ageRestrictionOptions) - } else { // TODO: error - symLog.log("no exchangeBaseUrl or no exchange") - withdrawalAmountDetails = nil + } else { + // TODO: amount = nil ==> show amount input } } }