| | |
| | const appState = { |
| | currentUser: null, |
| | isAuthenticated: false, |
| | role: null |
| | }; |
| |
|
| | |
| | document.addEventListener('DOMContentLoaded', () => { |
| | |
| | initAuthModal(); |
| | |
| | |
| | checkSavedSession(); |
| | }); |
| |
|
| | function checkSavedSession() { |
| | const token = localStorage.getItem('edu_token'); |
| | if (token) { |
| | |
| | console.log('Found saved session token'); |
| | } |
| | } |
| |
|
| | function initAuthModal() { |
| | const modal = document.querySelector('custom-auth-modal'); |
| | |
| | |
| | modal.shadowRoot.querySelector('#loginForm').addEventListener('submit', (e) => { |
| | e.preventDefault(); |
| | const email = e.target.elements.email.value; |
| | const password = e.target.elements.password.value; |
| | const remember = e.target.elements.remember.checked; |
| | |
| | |
| | console.log(`Login attempt with ${email}`); |
| | setTimeout(() => { |
| | modal.hideModal(); |
| | showToast('Login successful! Redirecting...', 'success'); |
| | }, 1500); |
| | }); |
| | |
| | |
| | modal.shadowRoot.querySelector('#forgotForm').addEventListener('submit', (e) => { |
| | e.preventDefault(); |
| | const email = e.target.elements.resetEmail.value; |
| | |
| | |
| | console.log(`Password reset requested for ${email}`); |
| | setTimeout(() => { |
| | modal.hideModal(); |
| | showToast('Password reset link sent to your email', 'success'); |
| | }, 1500); |
| | }); |
| | } |
| |
|
| | function showToast(message, type = 'info') { |
| | const toast = document.createElement('div'); |
| | toast.className = `fixed bottom-4 right-4 px-6 py-3 rounded-lg shadow-lg text-white ${ |
| | type === 'success' ? 'bg-green-500' : 'bg-blue-500' |
| | } fade-in`; |
| | toast.textContent = message; |
| | document.body.appendChild(toast); |
| | |
| | setTimeout(() => { |
| | toast.remove(); |
| | }, 3000); |
| | } |