function formatDate(dateStr) {
const d = new Date(dateStr);
return d.toLocaleDateString('fr-FR', { year: 'numeric', month: 'long', day: 'numeric' });
}
function showError(message) {
document.getElementById('error').innerHTML = `
${escapeHtml(message)}
`;
}
function statTile(value, label) {
return `
${value}
${escapeHtml(label)}
`;
}
(async function init() {
await initNav(null);
try {
const profile = await api.get('/api/users/me/profile');
const container = document.getElementById('content');
container.innerHTML = `
${profile.groups && profile.groups.length ? `
Groupes Authentik
${profile.groups.map((g) => `${escapeHtml(g)} `).join('')}
` : ''}
Votre activité
${statTile(profile.stats.songsAdded, 'Morceaux ajoutés')}
${statTile(profile.stats.suggestionsProposed, 'Suggestions proposées')}
${statTile(profile.stats.votesCast, 'Votes exprimés')}
Identité gérée par Authentik — pour changer votre nom, email ou mot de passe,
${profile.authentikAccountUrl
? `rendez-vous sur votre compte Authentik .`
: 'rendez-vous sur votre compte Authentik.'}
Se déconnecter
`;
} catch (err) {
showError(err.message);
}
})();