Language Exchange Partner Finder
Find people from around the world to practice languages with.
Loading your profile...
Create Your Profile
My Profile
Filters
Potential Partners
No partners found. Try adjusting your filters.
Could not initialize the application. ${e.message}
`; return; } // --- AUTHENTICATION & PROFILE HANDLING --- // Use custom token if available, otherwise sign in anonymously try { if (typeof __initial_auth_token !== 'undefined' && __initial_auth_token) { await signInWithCustomToken(auth, __initial_auth_token); } else { await signInAnonymously(auth); } } catch (error) { console.error("Authentication failed:", error); loadingView.innerHTML = `Authentication failed. Please try again later.
`; return; } onAuthStateChanged(auth, async (user) => { if (user) { currentUser = user; const userProfileDocRef = doc(db, "artifacts", appId, "public", "data", "profiles", user.uid); const userProfile = await getDoc(userProfileDocRef); if (userProfile.exists()) { renderMyProfile(userProfile.data()); showView('finder'); fetchAllUsers(); } else { showView('profile-creation'); } } }); saveProfileBtn.addEventListener('click', async () => { const name = document.getElementById('profile-name').value.trim(); const location = document.getElementById('profile-location').value.trim(); const speaks = document.getElementById('profile-speaks').value.split(',').map(s => s.trim().toLowerCase()).filter(Boolean); const learning = document.getElementById('profile-learning').value.split(',').map(s => s.trim().toLowerCase()).filter(Boolean); if (!name || speaks.length === 0 || learning.length === 0) { alert("Please fill in your name and at least one language for speaks/learning."); return; } const profileData = { name, location, speaks, learning }; const userProfileDocRef = doc(db, "artifacts", appId, "public", "data", "profiles", currentUser.uid); await setDoc(userProfileDocRef, profileData); renderMyProfile(profileData); showView('finder'); fetchAllUsers(); }); // --- RENDER FUNCTIONS --- const showView = (view) => { loadingView.classList.add('hidden'); profileCreationView.classList.toggle('hidden', view !== 'profile-creation'); finderView.classList.toggle('hidden', view !== 'finder'); }; const renderMyProfile = (profile) => { myProfileSummary.innerHTML = `${profile.name}
${profile.location}
SPEAKS:
${profile.speaks.map(lang => `${lang}`).join('')}
LEARNING:
${profile.learning.map(lang => `${lang}`).join('')}
No partners found. Try adjusting your filters.
'; return; } users.forEach(user => { const card = document.createElement('div'); card.className = 'profile-card bg-white p-4 rounded-lg shadow border'; card.innerHTML = `${user.name}
${user.location}
SPEAKS:
${user.speaks.map(lang => `${lang}`).join('')}
LEARNING:
${user.learning.map(lang => `${lang}`).join('')}
