window.addEventListener('DOMContentLoaded', (event) => { const params = new URLSearchParams(window.location.search); const status = params.get('status'); if (status) { let message = ''; let type = ''; if (status === 'success') { message = 'Thank you for joining the friends list!'; type = 'success'; } else if (status === 'error') { message = 'There was an error with your submission. Please try again.'; type = 'danger'; } if (message) { showToast(message, type); // Clean URL window.history.replaceState({}, document.title, window.location.pathname); } } }); function showToast(message, type = 'success') { const toastContainer = document.getElementById('toast-container'); if (!toastContainer) return; const toastId = 'toast-' + Date.now(); const toastHTML = ` `; toastContainer.insertAdjacentHTML('beforeend', toastHTML); const toastElement = document.getElementById(toastId); const toast = new bootstrap.Toast(toastElement, { delay: 5000 }); toast.show(); toastElement.addEventListener('hidden.bs.toast', () => { toastElement.remove(); }); }