From a5878b832620dbebc08899591d01085a186765cd Mon Sep 17 00:00:00 2001 From: Daniel Arantes Loverde Date: Fri, 10 Jul 2026 11:37:02 -0300 Subject: [PATCH] [cart-checkout] Fix address name hardcoded to 'Casa' in Checkout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CheckoutView.swift's addressSection showed the literal string "Casa" as the address name/label regardless of which address was actually selected — only the street/detail line below it (customerAddressLabel) was wired to real state. Added customerAddressName, preferring selectedCustomerAddress?.label then appState.address.display, matching the same fallback pattern already used for the detail line. --- Sources/PediFoods/Views/Main/CheckoutView.swift | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Sources/PediFoods/Views/Main/CheckoutView.swift b/Sources/PediFoods/Views/Main/CheckoutView.swift index 181023c..fbbe7f6 100644 --- a/Sources/PediFoods/Views/Main/CheckoutView.swift +++ b/Sources/PediFoods/Views/Main/CheckoutView.swift @@ -297,7 +297,7 @@ struct CheckoutView: View { ) VStack(alignment: .leading, spacing: 4) { - Text(isDeliveryMode ? "Casa" : (appState.cart.storeName ?? "Loja")) + Text(isDeliveryMode ? customerAddressName : (appState.cart.storeName ?? "Loja")) .font(AppTypography.heading3) .foregroundStyle(AppColors.textPrimary) Text(isDeliveryMode ? customerAddressLabel : storeAddressLabel) @@ -557,6 +557,16 @@ struct CheckoutView: View { } } + private var customerAddressName: String { + let label = (selectedCustomerAddress?.label ?? "").trimmingCharacters(in: .whitespacesAndNewlines) + if label.isEmpty == false { return label } + + let displayLabel = appState.address.display.trimmingCharacters(in: .whitespacesAndNewlines) + if displayLabel.isEmpty == false, displayLabel != "Defina seu endereco" { return displayLabel } + + return "Endereço" + } + private var customerAddressLabel: String { if let address = selectedCustomerAddress { let street = (address.address ?? "").trimmingCharacters(in: .whitespacesAndNewlines)