Skip to content

Commit 8980325

Browse files
committed
make sure alert blocks when it must
1 parent 2668080 commit 8980325

File tree

3 files changed

+36
-24
lines changed

3 files changed

+36
-24
lines changed

LongevityWorldCup.Website/wwwroot/onboarding/convergence.html

+17-14
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ <h2 data-aos="fade" data-aos-duration="700" data-aos-delay="400">1. Character Cr
349349
customAlert('Biomarker data is missing. Please complete the biomarker form.');
350350
return;
351351
}
352-
console.log(biomarkerData);
352+
353353
// Create the applicant data object
354354
const applicantData = {
355355
name: name,
@@ -902,26 +902,29 @@ <h2 data-aos="fade" data-aos-duration="700" data-aos-delay="400">1. Character Cr
902902

903903
if (response.ok) {
904904
// Handle success, perhaps redirect or show a success message
905-
customAlert('Application submitted successfully!');
906-
localStorage.setItem('contactEmail', applicantData.accountEmail);
907-
// Clear the image variables
908-
profilePic = null;
909-
proofPics = [];
910-
// Redirect or reset the form
911-
window.location.href = '/onboarding/application-review.html#appReviewTitle';
905+
customAlert('Application submitted successfully!').then(() => {
906+
localStorage.setItem('contactEmail', applicantData.accountEmail);
907+
// Clear the image variables
908+
profilePic = null;
909+
proofPics = [];
910+
// Redirect or reset the form
911+
window.location.href = '/onboarding/application-review.html#appReviewTitle';
912+
});
912913
} else {
913914
// Handle error
914-
customAlert('Failed to submit application. Please try again later.');
915-
applyButton.disabled = false;
916-
applyButton.textContent = 'Apply';
915+
customAlert('Failed to submit application. Please try again later.').then(() => {
916+
applyButton.disabled = false;
917+
applyButton.textContent = 'Apply';
918+
});
917919
}
918920

919921
})
920922
.catch(error => {
921923
console.error('Error submitting application:', error);
922-
customAlert('An error occurred while submitting your application.');
923-
applyButton.disabled = false;
924-
applyButton.textContent = 'Apply';
924+
customAlert('An error occurred while submitting your application.').then(() => {
925+
applyButton.disabled = false;
926+
applyButton.textContent = 'Apply';
927+
});
925928
});
926929
}
927930
}

LongevityWorldCup.Website/wwwroot/onboarding/pheno-age.html

+8-6
Original file line numberDiff line numberDiff line change
@@ -506,9 +506,10 @@ <h2 data-aos="fade" data-aos-duration="700" data-aos-delay="250">
506506

507507
// Check for invalid input
508508
if (isNaN(rawValue)) {
509-
customAlert(`Please enter a valid value for ${biomarker.name}.`);
510-
document.getElementById('continueButton').classList.remove('show');
511-
updateCalculateButton();
509+
customAlert(`Please enter a valid value for ${biomarker.name}.`).then(() => {
510+
document.getElementById('continueButton').classList.remove('show');
511+
updateCalculateButton();
512+
});
512513
return;
513514
}
514515

@@ -528,9 +529,10 @@ <h2 data-aos="fade" data-aos-duration="700" data-aos-delay="250">
528529
const wbcUnitConversion = parseFloat(wbcUnitElement.value);
529530

530531
if (isNaN(wbcRawValue)) {
531-
customAlert("Please provide White Blood Cell Count to calculate Lymphocyte percentage.");
532-
document.getElementById('continueButton').classList.remove('show');
533-
updateCalculateButton();
532+
customAlert("Please provide White Blood Cell Count to calculate Lymphocyte percentage.").then(() => {
533+
document.getElementById('continueButton').classList.remove('show');
534+
updateCalculateButton();
535+
});
534536
return;
535537
}
536538

LongevityWorldCup.Website/wwwroot/partials/header.html

+11-4
Original file line numberDiff line numberDiff line change
@@ -417,10 +417,17 @@ <h1 data-aos="fade" data-aos-duration="700" data-aos-delay="150">2025</h1>
417417
}
418418

419419
function customAlert(message) {
420-
const dialog = document.getElementById('custom-alert');
421-
const messageEl = document.getElementById('custom-alert-message');
422-
messageEl.textContent = message;
423-
dialog.showModal();
420+
return new Promise(resolve => {
421+
const dialog = document.getElementById('custom-alert');
422+
const messageEl = document.getElementById('custom-alert-message');
423+
messageEl.textContent = message;
424+
dialog.showModal();
425+
426+
document.getElementById('custom-alert-close').onclick = () => {
427+
dialog.close();
428+
resolve();
429+
};
430+
});
424431
}
425432

426433
document.getElementById('custom-alert-close').addEventListener('click', function () {

0 commit comments

Comments
 (0)