[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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user