geethareddy commited on
Commit
7c227d7
·
verified ·
1 Parent(s): eb88f8b

Create order_summary.html

Browse files
Files changed (1) hide show
  1. templates/order_summary.html +129 -0
templates/order_summary.html ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Order Summary - Biryani Hub</title>
7
+ <style>
8
+ body {
9
+ font-family: Arial, sans-serif;
10
+ background-color: #f8f8f8;
11
+ margin: 0;
12
+ padding: 0;
13
+ }
14
+
15
+ .summary-container {
16
+ max-width: 800px;
17
+ margin: 0 auto;
18
+ padding: 20px;
19
+ background-color: #fff;
20
+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
21
+ border-radius: 8px;
22
+ margin-top: 50px;
23
+ }
24
+
25
+ h1 {
26
+ text-align: center;
27
+ font-size: 2.5rem;
28
+ color: #333;
29
+ margin-bottom: 20px;
30
+ }
31
+
32
+ .order-item {
33
+ border-bottom: 1px solid #eee;
34
+ padding: 15px 0;
35
+ }
36
+
37
+ .order-total {
38
+ font-size: 1.5rem;
39
+ font-weight: bold;
40
+ text-align: right;
41
+ margin-top: 20px;
42
+ }
43
+
44
+ .confirm-btn {
45
+ display: block;
46
+ width: 100%;
47
+ padding: 15px;
48
+ font-size: 1.2rem;
49
+ background-color: #4CAF50;
50
+ color: white;
51
+ border: none;
52
+ border-radius: 5px;
53
+ cursor: pointer;
54
+ text-align: center;
55
+ }
56
+
57
+ .confirm-btn:hover {
58
+ background-color: #45a049;
59
+ }
60
+ </style>
61
+ </head>
62
+ <body>
63
+
64
+ <div class="summary-container">
65
+ <h1>Order Summary</h1>
66
+
67
+ <div id="order-items">
68
+ <!-- Order items will be inserted here dynamically -->
69
+ </div>
70
+
71
+ <div class="order-total" id="order-total">Total: $0.00</div>
72
+
73
+ <button class="confirm-btn" onclick="confirmOrder()">Confirm Order</button>
74
+ </div>
75
+
76
+ <script>
77
+ let cart = JSON.parse(localStorage.getItem("cart")) || [];
78
+
79
+ function loadOrderSummary() {
80
+ let orderHTML = "";
81
+ let total = 0;
82
+
83
+ cart.forEach((item, index) => {
84
+ total += item.price * item.quantity;
85
+ orderHTML += `
86
+ <div class="order-item">
87
+ <h3>${item.name}</h3>
88
+ <p>Quantity: ${item.quantity}</p>
89
+ <p>Price: $${item.price.toFixed(2)}</p>
90
+ </div>
91
+ `;
92
+ });
93
+
94
+ document.getElementById("order-items").innerHTML = orderHTML;
95
+ document.getElementById("order-total").innerText = `Total: $${total.toFixed(2)}`;
96
+ }
97
+
98
+ function confirmOrder() {
99
+ if (cart.length === 0) {
100
+ alert("No items in order!");
101
+ return;
102
+ }
103
+
104
+ // Send order data to backend
105
+ fetch("/order", {
106
+ method: "POST",
107
+ headers: {
108
+ "Content-Type": "application/json"
109
+ },
110
+ body: JSON.stringify({ cart })
111
+ })
112
+ .then(response => response.json())
113
+ .then(data => {
114
+ if (data.success) {
115
+ alert("Order confirmed!");
116
+ localStorage.removeItem("cart");
117
+ window.location.href = "/menu";
118
+ } else {
119
+ alert("Order failed. Please try again.");
120
+ }
121
+ })
122
+ .catch(error => console.error("Error confirming order:", error));
123
+ }
124
+
125
+ window.onload = loadOrderSummary;
126
+ </script>
127
+
128
+ </body>
129
+ </html>