Spaces:
Sleeping
Sleeping
Update templates/order_history.html
Browse files- templates/order_history.html +81 -26
templates/order_history.html
CHANGED
@@ -80,15 +80,52 @@
|
|
80 |
color: #333;
|
81 |
margin-bottom: 20px;
|
82 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
</style>
|
84 |
</head>
|
85 |
<body>
|
86 |
|
|
|
|
|
87 |
<div class="container">
|
88 |
<div class="order-heading">Order History</div>
|
89 |
|
90 |
-
<!-- Loop through the orders -->
|
91 |
-
{% for order in orders %}
|
92 |
<div class="order-item">
|
93 |
<!-- Order details: item names and quantities -->
|
94 |
<div class="order-details">
|
@@ -104,11 +141,36 @@
|
|
104 |
<div class="order-price">
|
105 |
<p>Total: ₹{{ order.Total_Bill__c }}</p>
|
106 |
</div>
|
107 |
-
|
108 |
-
|
109 |
</div>
|
110 |
{% endfor %}
|
111 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
<!-- If no orders exist -->
|
113 |
{% if not orders %}
|
114 |
<div class="no-orders">
|
@@ -116,30 +178,23 @@
|
|
116 |
</div>
|
117 |
{% endif %}
|
118 |
</div>
|
119 |
-
<script>
|
120 |
-
function reorder(orderId) {
|
121 |
-
fetch(`/reorder/${orderId}`, {
|
122 |
-
method: 'POST',
|
123 |
-
headers: {
|
124 |
-
'Content-Type': 'application/json',
|
125 |
-
},
|
126 |
-
body: JSON.stringify({ orderId: orderId }),
|
127 |
-
})
|
128 |
-
.then(response => response.json())
|
129 |
-
.then(data => {
|
130 |
-
if (data.success) {
|
131 |
-
// Redirect to the cart page after adding the items
|
132 |
-
window.location.href = '/cart'; // Or any cart page URL
|
133 |
-
} else {
|
134 |
-
alert("Error reordering: " + data.error);
|
135 |
-
}
|
136 |
-
})
|
137 |
-
.catch(error => {
|
138 |
-
console.error('Error:', error);
|
139 |
-
});
|
140 |
-
}
|
141 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
</script>
|
143 |
|
144 |
</body>
|
145 |
</html>
|
|
|
|
80 |
color: #333;
|
81 |
margin-bottom: 20px;
|
82 |
}
|
83 |
+
|
84 |
+
.back-button {
|
85 |
+
display: inline-block;
|
86 |
+
background-color: green;
|
87 |
+
color: white;
|
88 |
+
padding: 10px 20px;
|
89 |
+
text-decoration: none;
|
90 |
+
font-weight: bold;
|
91 |
+
border-radius: 4px;
|
92 |
+
margin-bottom: 20px;
|
93 |
+
}
|
94 |
+
|
95 |
+
.back-button:hover {
|
96 |
+
background-color: darkgreen;
|
97 |
+
}
|
98 |
+
|
99 |
+
/* Hide additional orders by default */
|
100 |
+
.more-orders {
|
101 |
+
display: none;
|
102 |
+
}
|
103 |
+
|
104 |
+
/* Style for the Show More/Show Less button */
|
105 |
+
.show-more-btn {
|
106 |
+
background-color: #ff7f00;
|
107 |
+
color: white;
|
108 |
+
padding: 10px 20px;
|
109 |
+
border: none;
|
110 |
+
cursor: pointer;
|
111 |
+
border-radius: 4px;
|
112 |
+
margin-top: 20px;
|
113 |
+
}
|
114 |
+
|
115 |
+
.show-more-btn:hover {
|
116 |
+
background-color: #f55b00;
|
117 |
+
}
|
118 |
</style>
|
119 |
</head>
|
120 |
<body>
|
121 |
|
122 |
+
<a href="{{ url_for('menu') }}" class="back-button">Back to Menu</a>
|
123 |
+
|
124 |
<div class="container">
|
125 |
<div class="order-heading">Order History</div>
|
126 |
|
127 |
+
<!-- Loop through the orders (first 3) -->
|
128 |
+
{% for order in orders[:3] %}
|
129 |
<div class="order-item">
|
130 |
<!-- Order details: item names and quantities -->
|
131 |
<div class="order-details">
|
|
|
141 |
<div class="order-price">
|
142 |
<p>Total: ₹{{ order.Total_Bill__c }}</p>
|
143 |
</div>
|
|
|
|
|
144 |
</div>
|
145 |
{% endfor %}
|
146 |
|
147 |
+
<!-- Loop through the remaining orders (hidden initially) -->
|
148 |
+
<div class="more-orders" id="more-orders">
|
149 |
+
{% for order in orders[3:] %}
|
150 |
+
<div class="order-item">
|
151 |
+
<!-- Order details: item names and quantities -->
|
152 |
+
<div class="order-details">
|
153 |
+
<p>{{ order.formatted_items }}</p>
|
154 |
+
</div>
|
155 |
+
|
156 |
+
<!-- Order date and time -->
|
157 |
+
<div class="order-date-time">
|
158 |
+
<p>{{ order.formatted_date }}</p>
|
159 |
+
</div>
|
160 |
+
|
161 |
+
<!-- Total price -->
|
162 |
+
<div class="order-price">
|
163 |
+
<p>Total: ₹{{ order.Total_Bill__c }}</p>
|
164 |
+
</div>
|
165 |
+
</div>
|
166 |
+
{% endfor %}
|
167 |
+
</div>
|
168 |
+
|
169 |
+
<!-- Show More button -->
|
170 |
+
{% if orders|length > 3 %}
|
171 |
+
<button class="show-more-btn" onclick="toggleOrders()">Show More</button>
|
172 |
+
{% endif %}
|
173 |
+
|
174 |
<!-- If no orders exist -->
|
175 |
{% if not orders %}
|
176 |
<div class="no-orders">
|
|
|
178 |
</div>
|
179 |
{% endif %}
|
180 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
181 |
|
182 |
+
<script>
|
183 |
+
// Function to toggle between Show More and Show Less
|
184 |
+
function toggleOrders() {
|
185 |
+
const moreOrders = document.getElementById("more-orders");
|
186 |
+
const button = document.querySelector(".show-more-btn");
|
187 |
+
|
188 |
+
if (moreOrders.style.display === "none") {
|
189 |
+
moreOrders.style.display = "block";
|
190 |
+
button.innerHTML = "Show Less"; // Change button text
|
191 |
+
} else {
|
192 |
+
moreOrders.style.display = "none";
|
193 |
+
button.innerHTML = "Show More"; // Change button text back
|
194 |
+
}
|
195 |
+
}
|
196 |
</script>
|
197 |
|
198 |
</body>
|
199 |
</html>
|
200 |
+
|