[cart-checkout] Fix address name hardcoded to 'Casa' in Checkout

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.
This commit is contained in:
Daniel Arantes Loverde
2026-07-10 11:37:02 -03:00
parent 6b77775238
commit a5878b8326

View File

@@ -297,7 +297,7 @@ struct CheckoutView: View {
) )
VStack(alignment: .leading, spacing: 4) { VStack(alignment: .leading, spacing: 4) {
Text(isDeliveryMode ? "Casa" : (appState.cart.storeName ?? "Loja")) Text(isDeliveryMode ? customerAddressName : (appState.cart.storeName ?? "Loja"))
.font(AppTypography.heading3) .font(AppTypography.heading3)
.foregroundStyle(AppColors.textPrimary) .foregroundStyle(AppColors.textPrimary)
Text(isDeliveryMode ? customerAddressLabel : storeAddressLabel) 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 { private var customerAddressLabel: String {
if let address = selectedCustomerAddress { if let address = selectedCustomerAddress {
let street = (address.address ?? "").trimmingCharacters(in: .whitespacesAndNewlines) let street = (address.address ?? "").trimmingCharacters(in: .whitespacesAndNewlines)