lokeshloki143 commited on
Commit
9f60fd8
·
verified ·
1 Parent(s): 9648260

Update templates/combined_summary.html

Browse files
Files changed (1) hide show
  1. templates/combined_summary.html +31 -19
templates/combined_summary.html CHANGED
@@ -590,11 +590,11 @@
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 (e.g., 1800 for 30 mins) -->
594
- <!-- Pass 0 or None from Flask for a completed/past order -->
595
- <input type="hidden" id="deliveryTimeSeconds" value="{{ delivery_time_seconds | default('0') }}">
596
 
597
- <div id="orderConfirmationSection" class="section bg-white shadow-sm rounded-xl p-6 mb-6 order-confirmed" role="alert">
598
  <h1 class="text-center text-2xl font-bold text-orange-500">Order Confirmed!</h1>
599
  <p class="text-center text-gray-600 mt-2">Estimated delivery time: <span id="countdownTimer"></span></p>
600
  </div>
@@ -1046,38 +1046,50 @@
1046
  const orderConfirmationSection = document.getElementById('orderConfirmationSection');
1047
  const countdownTimerSpan = document.getElementById('countdownTimer');
1048
 
1049
- let remainingSeconds = parseInt(deliveryTimeInput.value, 10);
 
1050
 
1051
- // Check if delivery time is a valid positive number
1052
- if (!isNaN(remainingSeconds) && remainingSeconds > 0) {
1053
  // Show the section and start the timer
1054
  orderConfirmationSection.classList.remove('hidden');
 
1055
 
1056
  const timerInterval = setInterval(() => {
1057
- const minutes = Math.floor(remainingSeconds / 60);
1058
- const seconds = remainingSeconds % 60;
1059
-
1060
- // Pad seconds with a leading zero if less than 10
1061
- const paddedSeconds = seconds < 10 ? '0' + seconds : seconds;
1062
-
1063
- countdownTimerSpan.textContent = `${minutes}m ${paddedSeconds}s`;
1064
-
1065
  remainingSeconds--;
1066
 
 
 
 
 
1067
  if (remainingSeconds < 0) {
1068
  clearInterval(timerInterval);
1069
  countdownTimerSpan.textContent = 'Delivered!';
1070
  // Keep the section visible to show the "Delivered!" message
 
 
 
 
 
 
1071
  }
1072
  }, 1000);
1073
  } else {
1074
- // If no valid positive delivery time (0 or less, or not provided)
1075
- // Assume the order is delivered or this is a past order view
1076
- countdownTimerSpan.textContent = 'Delivered!';
1077
- orderConfirmationSection.classList.remove('hidden'); // Show the "Delivered!" message
1078
  }
1079
  }
1080
 
 
 
 
 
 
 
 
 
1081
 
1082
  // Close modals on outside click
1083
  document.addEventListener('click', (e) => {
 
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 ONLY for a NEW order -->
594
+ <!-- For historical orders, pass 0 or omit the value -->
595
+ <input type="hidden" id="deliveryTimeSeconds" value="{{ delivery_time_seconds | default('') }}">
596
 
597
+ <div id="orderConfirmationSection" class="section bg-white shadow-sm rounded-xl p-6 mb-6 order-confirmed hidden" role="alert">
598
  <h1 class="text-center text-2xl font-bold text-orange-500">Order Confirmed!</h1>
599
  <p class="text-center text-gray-600 mt-2">Estimated delivery time: <span id="countdownTimer"></span></p>
600
  </div>
 
1046
  const orderConfirmationSection = document.getElementById('orderConfirmationSection');
1047
  const countdownTimerSpan = document.getElementById('countdownTimer');
1048
 
1049
+ // Parse the value, default to 0 if not a valid number or empty
1050
+ let remainingSeconds = parseInt(deliveryTimeInput.value, 10) || 0;
1051
 
1052
+ // Check if delivery time is a valid positive number provided for a *new* order
1053
+ if (remainingSeconds > 0) {
1054
  // Show the section and start the timer
1055
  orderConfirmationSection.classList.remove('hidden');
1056
+ countdownTimerSpan.textContent = formatTime(remainingSeconds); // Display initial time
1057
 
1058
  const timerInterval = setInterval(() => {
 
 
 
 
 
 
 
 
1059
  remainingSeconds--;
1060
 
1061
+ if (remainingSeconds >= 0) {
1062
+ countdownTimerSpan.textContent = formatTime(remainingSeconds);
1063
+ }
1064
+
1065
  if (remainingSeconds < 0) {
1066
  clearInterval(timerInterval);
1067
  countdownTimerSpan.textContent = 'Delivered!';
1068
  // Keep the section visible to show the "Delivered!" message
1069
+ // Optional: Hide the section after a short delay if preferred
1070
+ /*
1071
+ setTimeout(() => {
1072
+ orderConfirmationSection.classList.add('hidden');
1073
+ }, 3000); // Hide after 3 seconds
1074
+ */
1075
  }
1076
  }, 1000);
1077
  } else {
1078
+ // If deliveryTimeSeconds is 0 or less, or not provided
1079
+ // This means it's not a new order with a pending timer.
1080
+ // Hide the confirmation section entirely.
1081
+ orderConfirmationSection.classList.add('hidden');
1082
  }
1083
  }
1084
 
1085
+ // Helper function to format seconds into m:ss
1086
+ function formatTime(seconds) {
1087
+ const minutes = Math.floor(seconds / 60);
1088
+ const remainingSeconds = seconds % 60;
1089
+ const paddedSeconds = remainingSeconds < 10 ? '0' + remainingSeconds : remainingSeconds;
1090
+ return `${minutes}m ${paddedSeconds}s`;
1091
+ }
1092
+
1093
 
1094
  // Close modals on outside click
1095
  document.addEventListener('click', (e) => {