feat(orders): separar reviews e criar detalhe de pedido

This commit is contained in:
Daniel Arantes Loverde
2026-03-05 10:10:03 -03:00
parent 56d6ff7223
commit a8e3631177
3 changed files with 586 additions and 0 deletions

View File

@@ -479,6 +479,7 @@ struct OrderEntryDestinationView: View {
@State var pixContext: PixPaymentContext? = nil
@State var cardContext: CardPaymentContext? = nil
@State var orderTrackingContext: OrderTrackingContext? = nil
@State var orderDetails: PublicOrderResult? = nil
var body: some View {
Group {
@@ -511,6 +512,8 @@ struct OrderEntryDestinationView: View {
orderTrackingContext = OrderTrackingContext(orderId: cardContext.orderId, shortId: cardContext.shortId)
}
)
} else if let orderDetails {
OrderDetailsView(order: orderDetails, orderId: orderId, initialShortId: initialShortId)
} else {
OrderTrackingView(orderId: orderId, initialShortId: initialShortId)
}
@@ -531,6 +534,10 @@ struct OrderEntryDestinationView: View {
let order = await fetchOrderForRouting()
guard let order else { return }
if shouldOpenOrderDetails(for: order) {
orderDetails = order
return
}
guard shouldOpenPaymentScreen(for: order) else { return }
let normalizedMethod = normalizePaymentMethod(order)
@@ -592,6 +599,13 @@ struct OrderEntryDestinationView: View {
return method == "PIX" || method == "CREDIT_CARD" || method == "DEBIT_CARD"
}
func shouldOpenOrderDetails(for order: PublicOrderResult) -> Bool {
let status = normalize(order.status)
if status.contains("CANCEL") { return true }
if status.contains("COMPLETED") || status.contains("DELIVERED") { return true }
return false
}
func shouldOpenPaymentScreen(for order: PublicOrderResult) -> Bool {
guard order.isPaymentConfirmed == false else { return false }
guard isOnlinePaymentMethod(order) else { return false }