Revert "Attempt to make apply page faster"

This reverts commit c2523bdfbf.
This commit is contained in:
Kent Joseph T. Palima
2026-05-17 19:10:24 +08:00
parent c2523bdfbf
commit a43717a25e
+12 -14
View File
@@ -137,8 +137,6 @@ import '../styles/apply.scss';
// === PASTE YOUR GOOGLE SCRIPT URL HERE ONCE === // === PASTE YOUR GOOGLE SCRIPT URL HERE ONCE ===
const SCRIPT_URL = 'https://script.google.com/macros/s/AKfycby_xG6EGVuLXvgs9ro20rMkK2zSyElPCHeMU_2F2Q_0WE08gtCNzrO-SEyjDAqS46Hr/exec'; const SCRIPT_URL = 'https://script.google.com/macros/s/AKfycby_xG6EGVuLXvgs9ro20rMkK2zSyElPCHeMU_2F2Q_0WE08gtCNzrO-SEyjDAqS46Hr/exec';
const STATUS_CSV_URL = 'https://docs.google.com/spreadsheets/d/e/2PACX-1vRZvHQma9ZHzgyb3tmkCzXKZVpW9esnVAOQEN994ZuUvszO6dhE4fzq0psXLA2lTtDuefUIXNQvvfN_/pub?gid=202325095&single=true&output=csv';
// --- ELEMENTS --- // --- ELEMENTS ---
const loadingStatus = document.getElementById('loading-status'); const loadingStatus = document.getElementById('loading-status');
const closedMessage = document.getElementById('closed-message'); const closedMessage = document.getElementById('closed-message');
@@ -152,24 +150,24 @@ import '../styles/apply.scss';
const loadingMsg = document.getElementById('loading-msg'); const loadingMsg = document.getElementById('loading-msg');
const successMsg = document.getElementById('success-message'); const successMsg = document.getElementById('success-message');
// --- STEP 1: CHECK GOOGLE SHEET STATUS VIA CSV --- // --- STEP 1: CHECK GOOGLE SHEET STATUS ---
// Added the protective if-statement here!
if (loadingStatus && closedMessage && registrationContent) { if (loadingStatus && closedMessage && registrationContent) {
// We fetch the lightning-fast CSV instead of the script fetch(SCRIPT_URL)
fetch(STATUS_CSV_URL) .then(response => response.json())
.then(response => response.text()) // Parse it as raw text, not JSON .then(data => {
.then(csvText => { loadingStatus.style.display = 'none'; // Hide the spinner
loadingStatus.style.display = 'none';
// CSV text usually comes with a newline at the end, so we use .trim() to clean it // Look at the B1 cell value from the Google Sheet
// We also check if it includes 'OPEN' just in case there are other headers if (data.status === 'OPEN') {
if (csvText.trim().includes('OPEN')) { registrationContent.style.display = 'block'; // Reveal the portal!
registrationContent.style.display = 'block';
} else { } else {
closedMessage.style.display = 'block'; closedMessage.style.display = 'block'; // Show the closed message
} }
}) })
.catch(error => { .catch(error => {
console.error("Status check failed:", error); console.error("Status check failed:", error); // Added this to clear the warning
// If the internet is down or script fails, fail gracefully by showing closed
loadingStatus.style.display = 'none'; loadingStatus.style.display = 'none';
closedMessage.style.display = 'block'; closedMessage.style.display = 'block';
}); });