Fix modal not opening when users try to sign in or join

Update Alpine.js components to correctly handle global events for showing the authentication modal, resolving the issue where tapping sign in or join buttons did not open the modal.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 495199c6-aa06-48cd-8c40-9cccf398cfcf
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/d6d61dac-164d-45dd-929f-7dcdfd771b64/495199c6-aa06-48cd-8c40-9cccf398cfcf/4DtGbtV
This commit is contained in:
pac7
2025-09-21 14:18:34 +00:00
committed by pacnpal
parent e47c679bc0
commit 828d7d9b9a

View File

@@ -375,6 +375,13 @@ Alpine.data('authModal', (defaultMode = 'login') => ({
this.resetForms();
}
});
// Listen for global auth modal events
document.addEventListener('show-auth-modal', (event) => {
const mode = event.detail?.mode || 'login';
this.show(mode);
console.log('Auth modal opened via event:', mode);
});
},
async fetchSocialProviders() {
@@ -618,6 +625,21 @@ Alpine.store('toast', {
});
console.log('All Alpine.js components registered successfully');
// Expose global authModal instance for mobile buttons
if (typeof window !== 'undefined') {
window.authModal = {
show: (mode = 'login') => {
// Dispatch custom event to trigger auth modal
const event = new CustomEvent('show-auth-modal', {
detail: { mode: mode }
});
document.dispatchEvent(event);
console.log('Auth modal event dispatched:', mode);
}
};
console.log('Global authModal exposed on window');
}
}
// Try multiple registration approaches