Update templates/combined_summary.html
Browse files
templates/combined_summary.html
CHANGED
|
@@ -590,9 +590,10 @@
|
|
| 590 |
<div class="container mx-auto p-6 pt-2">
|
| 591 |
<!-- Order Confirmation -->
|
| 592 |
<!-- Added a hidden input to store delivery time in seconds -->
|
|
|
|
| 593 |
<input type="hidden" id="deliveryTimeSeconds" value="{{ delivery_time_seconds | default('') }}">
|
| 594 |
|
| 595 |
-
<div id="orderConfirmationSection" class="section bg-white shadow-sm rounded-xl p-6 mb-6 order-confirmed
|
| 596 |
<h1 class="text-center text-2xl font-bold text-orange-500">Order Confirmed!</h1>
|
| 597 |
<p class="text-center text-gray-600 mt-2">Estimated delivery time: <span id="countdownTimer"></span></p>
|
| 598 |
</div>
|
|
@@ -658,7 +659,7 @@
|
|
| 658 |
{% elif next_tier == "Gold" %}
|
| 659 |
<li class="flex items-center">
|
| 660 |
<span class="text-2xl mr-3">🏷️</span>
|
| 661 |
-
<span class="text-
|
| 662 |
</li>
|
| 663 |
<li class="flex items-center">
|
| 664 |
<span class="text-2xl mr-3">🍰</span>
|
|
@@ -1046,7 +1047,7 @@
|
|
| 1046 |
|
| 1047 |
let remainingSeconds = parseInt(deliveryTimeInput.value, 10);
|
| 1048 |
|
| 1049 |
-
//
|
| 1050 |
if (!isNaN(remainingSeconds) && remainingSeconds > 0) {
|
| 1051 |
orderConfirmationSection.classList.remove('hidden'); // Ensure it's visible for a new order
|
| 1052 |
|
|
@@ -1054,22 +1055,36 @@
|
|
| 1054 |
const minutes = Math.floor(remainingSeconds / 60);
|
| 1055 |
const seconds = remainingSeconds % 60;
|
| 1056 |
|
| 1057 |
-
|
|
|
|
|
|
|
|
|
|
| 1058 |
|
| 1059 |
remainingSeconds--;
|
| 1060 |
|
| 1061 |
if (remainingSeconds < 0) {
|
| 1062 |
clearInterval(timerInterval);
|
| 1063 |
countdownTimerSpan.textContent = 'Delivered!';
|
| 1064 |
-
//
|
|
|
|
|
|
|
|
|
|
| 1065 |
setTimeout(() => {
|
| 1066 |
orderConfirmationSection.classList.add('hidden');
|
| 1067 |
}, 3000); // Hide after 3 seconds
|
|
|
|
| 1068 |
}
|
| 1069 |
}, 1000);
|
| 1070 |
} else {
|
| 1071 |
-
// If no valid delivery time
|
| 1072 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1073 |
}
|
| 1074 |
}
|
| 1075 |
|
|
|
|
| 590 |
<div class="container mx-auto p-6 pt-2">
|
| 591 |
<!-- Order Confirmation -->
|
| 592 |
<!-- Added a hidden input to store delivery time in seconds -->
|
| 593 |
+
<!-- Pass delivery_time_seconds from Flask for a NEW order -->
|
| 594 |
<input type="hidden" id="deliveryTimeSeconds" value="{{ delivery_time_seconds | default('') }}">
|
| 595 |
|
| 596 |
+
<div id="orderConfirmationSection" class="section bg-white shadow-sm rounded-xl p-6 mb-6 order-confirmed" role="alert">
|
| 597 |
<h1 class="text-center text-2xl font-bold text-orange-500">Order Confirmed!</h1>
|
| 598 |
<p class="text-center text-gray-600 mt-2">Estimated delivery time: <span id="countdownTimer"></span></p>
|
| 599 |
</div>
|
|
|
|
| 659 |
{% elif next_tier == "Gold" %}
|
| 660 |
<li class="flex items-center">
|
| 661 |
<span class="text-2xl mr-3">🏷️</span>
|
| 662 |
+
<span class="text-700">15% discount on next purchase</span>
|
| 663 |
</li>
|
| 664 |
<li class="flex items-center">
|
| 665 |
<span class="text-2xl mr-3">🍰</span>
|
|
|
|
| 1047 |
|
| 1048 |
let remainingSeconds = parseInt(deliveryTimeInput.value, 10);
|
| 1049 |
|
| 1050 |
+
// Check if delivery time is a valid number and greater than 0
|
| 1051 |
if (!isNaN(remainingSeconds) && remainingSeconds > 0) {
|
| 1052 |
orderConfirmationSection.classList.remove('hidden'); // Ensure it's visible for a new order
|
| 1053 |
|
|
|
|
| 1055 |
const minutes = Math.floor(remainingSeconds / 60);
|
| 1056 |
const seconds = remainingSeconds % 60;
|
| 1057 |
|
| 1058 |
+
// Pad seconds with a leading zero if less than 10
|
| 1059 |
+
const paddedSeconds = seconds < 10 ? '0' + seconds : seconds;
|
| 1060 |
+
|
| 1061 |
+
countdownTimerSpan.textContent = `${minutes}m ${paddedSeconds}s`;
|
| 1062 |
|
| 1063 |
remainingSeconds--;
|
| 1064 |
|
| 1065 |
if (remainingSeconds < 0) {
|
| 1066 |
clearInterval(timerInterval);
|
| 1067 |
countdownTimerSpan.textContent = 'Delivered!';
|
| 1068 |
+
// You can optionally hide the section here if you prefer,
|
| 1069 |
+
// but your request implied showing "Delivered!" after completion.
|
| 1070 |
+
// If you want to hide it automatically after completion, uncomment:
|
| 1071 |
+
/*
|
| 1072 |
setTimeout(() => {
|
| 1073 |
orderConfirmationSection.classList.add('hidden');
|
| 1074 |
}, 3000); // Hide after 3 seconds
|
| 1075 |
+
*/
|
| 1076 |
}
|
| 1077 |
}, 1000);
|
| 1078 |
} else {
|
| 1079 |
+
// If no valid delivery time (e.g., page load for past orders or timer finished)
|
| 1080 |
+
// Check if the delivery time was 0 or less, indicating completion
|
| 1081 |
+
if (isNaN(remainingSeconds) || remainingSeconds <= 0) {
|
| 1082 |
+
countdownTimerSpan.textContent = 'Delivered!';
|
| 1083 |
+
orderConfirmationSection.classList.remove('hidden'); // Show "Delivered!" message
|
| 1084 |
+
} else {
|
| 1085 |
+
// This case shouldn't happen if backend sends valid data for new orders
|
| 1086 |
+
orderConfirmationSection.classList.add('hidden'); // Hide if no valid time at all
|
| 1087 |
+
}
|
| 1088 |
}
|
| 1089 |
}
|
| 1090 |
|