Käyttäjäprofiili

Liittynyt: -
Pelejä: 0
Viestejä: 0
Yleiskatsaus
Pelit
Viimeisimmät viestit
Asetukset

Tietoja minusta

Ei kuvausta vielä.

Aktiiviset pelit

Kaikki pelit

Viimeisimmät viestit

Profiiliasetukset

Vaihda salasana

async function loadUserGames() { // Only show for GMs const profileUser = await getUserProfile(); if (!profileUser) return; const roles = JSON.parse(profileUser.roles || "[]"); if (!roles.includes("gm") && !profileUser.is_admin) { return; } // Show games section document.getElementById("gamesSection").style.display = "block"; try { const response = await fetch("/api/games", { headers: { "Authorization": `Bearer ${getCookie("token")}` } }); if (response.ok) { const games = await response.json(); const userGames = games.filter(game => game.created_by === parseInt(userId)); const gamesDiv = document.getElementById("userGames"); if (userGames.length === 0) { gamesDiv.innerHTML = "

Ei vielä luotuja pelejä.

"; return; } gamesDiv.innerHTML = userGames.map(game => `

${game.title}

${game.description}

📊 ${game.total_posts || 0} postausta | 👥 ${game.player_count || 0} pelaajaa | 📖 ${game.chapter_count || 0} lukua
`).join(""); } } catch (error) { console.error("Error loading games:", error); } } async function getUserProfile() { try { const response = await fetch(`/api/users/${userId}`, { headers: { "Authorization": `Bearer ${getCookie("token")}` } }); if (response.ok) { return await response.json(); } } catch (error) { console.error("Error fetching user profile:", error); } return null; }