Fix
This commit is contained in:
@@ -53,18 +53,27 @@ struct OrdersView: View {
|
||||
orderId: context.orderId,
|
||||
initialShortId: context.shortId,
|
||||
fallbackPaymentMethod: context.paymentMethod,
|
||||
fallbackTotal: context.total
|
||||
fallbackTotal: context.total,
|
||||
routeIntent: context.intent
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private func orderCard(_ order: AppOrderSummary) -> some View {
|
||||
let status = orderVisualStatus(for: order)
|
||||
let route = OrderRouteContext(
|
||||
let detailsRoute = OrderRouteContext(
|
||||
orderId: trackingOrderId(for: order),
|
||||
shortId: order.shortId,
|
||||
paymentMethod: order.paymentMethod,
|
||||
total: order.total
|
||||
total: order.total,
|
||||
intent: .details
|
||||
)
|
||||
let trackingRoute = OrderRouteContext(
|
||||
orderId: trackingOrderId(for: order),
|
||||
shortId: order.shortId,
|
||||
paymentMethod: order.paymentMethod,
|
||||
total: order.total,
|
||||
intent: .tracking
|
||||
)
|
||||
|
||||
return VStack(alignment: .leading, spacing: 14) {
|
||||
@@ -121,7 +130,7 @@ struct OrdersView: View {
|
||||
|
||||
HStack(spacing: 12) {
|
||||
Button(status.isCanceled ? "Ajuda" : "Ver Detalhes") {
|
||||
selectedOrderRoute = route
|
||||
selectedOrderRoute = detailsRoute
|
||||
}
|
||||
.font(AppTypography.heading3)
|
||||
.foregroundStyle(AppColors.textMuted)
|
||||
@@ -134,7 +143,7 @@ struct OrdersView: View {
|
||||
|
||||
Button {
|
||||
if status.isInProgress {
|
||||
selectedOrderRoute = route
|
||||
selectedOrderRoute = trackingRoute
|
||||
return
|
||||
}
|
||||
SnackbarCenter.shared.show(
|
||||
@@ -464,11 +473,18 @@ struct OrdersView: View {
|
||||
}
|
||||
|
||||
struct OrderRouteContext: Identifiable, Hashable {
|
||||
var id: String { orderId }
|
||||
var id: String { "\(orderId)|\(intent.rawValue)" }
|
||||
let orderId: String
|
||||
let shortId: String?
|
||||
let paymentMethod: String?
|
||||
let total: Double?
|
||||
let intent: OrderRouteIntent
|
||||
}
|
||||
|
||||
enum OrderRouteIntent: String, Hashable {
|
||||
case details
|
||||
case tracking
|
||||
case auto
|
||||
}
|
||||
|
||||
private enum OrderRowStatusStyle {
|
||||
@@ -584,6 +600,7 @@ struct OrderEntryDestinationView: View {
|
||||
let initialShortId: String?
|
||||
let fallbackPaymentMethod: String?
|
||||
let fallbackTotal: Double?
|
||||
let routeIntent: OrderRouteIntent
|
||||
|
||||
@State var isResolvingRoute = true
|
||||
@State var didResolve = false
|
||||
@@ -643,8 +660,16 @@ struct OrderEntryDestinationView: View {
|
||||
func resolveRoute() async {
|
||||
defer { isResolvingRoute = false }
|
||||
|
||||
if routeIntent == .tracking {
|
||||
return
|
||||
}
|
||||
|
||||
let order = await fetchOrderForRouting()
|
||||
guard let order else { return }
|
||||
if routeIntent == .details {
|
||||
orderDetails = order
|
||||
return
|
||||
}
|
||||
if shouldOpenOrderDetails(for: order) {
|
||||
orderDetails = order
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user