Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion BugBazaar/Screens/ConfirmationView.swift
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down Expand Up @@ -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)
Expand Down