From bdb7965c668023fc8c553a3cbdbbdc654764b176 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 4 Jul 2026 02:19:57 +0000 Subject: [PATCH] Fix confirmation screen to show real order ID and total Read the most recent order from CartStore instead of generating a random order ID on ConfirmationView. Display the charged total formatted with the existing .usd extension, with a fallback when orders is empty. Co-authored-by: Anam Hira --- BugBazaar/Screens/ConfirmationView.swift | 25 +++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/BugBazaar/Screens/ConfirmationView.swift b/BugBazaar/Screens/ConfirmationView.swift index 6a43efe..b1c0551 100644 --- a/BugBazaar/Screens/ConfirmationView.swift +++ b/BugBazaar/Screens/ConfirmationView.swift @@ -1,9 +1,21 @@ import SwiftUI struct ConfirmationView: View { + @EnvironmentObject private var cart: CartStore @EnvironmentObject private var router: Router @State private var appeared = false - @State private var orderID = "ORD-\(Int.random(in: 1000...9999))" + + private var latestOrder: Order? { + cart.orders.first + } + + private var orderID: String { + latestOrder?.id ?? "ORD-0000" + } + + private var orderTotal: String? { + latestOrder.map { $0.total.usd } + } var body: some View { VStack(spacing: 0) { @@ -36,6 +48,17 @@ struct ConfirmationView: View { Text(orderID) .font(.bodyFont(20, bold: true)) .foregroundColor(Theme.inkBlack) + + if let orderTotal { + Text("TOTAL CHARGED") + .font(.bodyFont(9, bold: true)) + .kerning(1.5) + .foregroundColor(Theme.gray) + .padding(.top, 8) + Text(orderTotal) + .font(.bodyFont(20, bold: true)) + .foregroundColor(Theme.priceGray) + } } .padding(.vertical, 12) .padding(.horizontal, 24)