Add user list to admin panel and validated/guest badges on posts

Admin panel: new "Käyttäjät" section showing all registered users with
post count, likes count, email and join date.

Posts: submissions by logged-in users show a green "Vahvistettu" badge,
while guest submissions show a random code (e.g. #L01U51) for tracking.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-08 12:02:50 +02:00
parent 69902035ab
commit 30d57c80c0
4 changed files with 94 additions and 4 deletions

View File

@@ -213,7 +213,7 @@ function renderCards() {
<div class="card-body">
<span class="category-tag">${getCategoryLabel(p.category)}</span>
<h3>${p.title}</h3>
${p.author ? `<p class="card-author">✍️ ${p.author}</p>` : ''}
${p.author ? `<p class="card-author">✍️ ${p.author}${p.submittedBy?.validated ? ' <span class="validated-badge">✔ Vahvistettu</span>' : (p.submittedBy?.guestCode ? ` <span class="guest-badge">#${p.submittedBy.guestCode}</span>` : '')}</p>` : ''}
<p>${p.desc || ''}</p>
${metaRow}
<div class="card-actions">
@@ -326,7 +326,7 @@ async function openPost(id) {
<p class="modal-meta">
📂 ${getCategoryLabel(p.category)}
${p.time ? `&nbsp;|&nbsp; ⏱ ${p.time} &nbsp;|&nbsp; 👤 ${p.servings}` : ''}
${p.author ? `&nbsp;|&nbsp; ✍️ ${t('modal_by')} ${p.author}` : ''}
${p.author ? `&nbsp;|&nbsp; ✍️ ${t('modal_by')} ${p.author}${p.submittedBy?.validated ? ' <span class="validated-badge">✔ Vahvistettu</span>' : (p.submittedBy?.guestCode ? ` <span class="guest-badge">#${p.submittedBy.guestCode}</span>` : '')}` : ''}
</p>
<div class="modal-like-row">
<button class="like-btn ${liked ? 'liked' : ''}" data-like-id="${p.id}" onclick="toggleLike('${p.id}')">${liked ? t('liked_btn') : t('like_btn')}</button>
@@ -590,10 +590,15 @@ async function submitPublicPost() {
document.getElementById('sub-img3').value.trim(),
].filter(Boolean);
const submittedBy = APP.user
? { userId: APP.user.id, nickname: APP.user.nickname, validated: true }
: { guestCode: Math.random().toString(36).slice(2, 8).toUpperCase(), validated: false };
const post = {
id: title.toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g,'').replace(/\s+/g,'_').replace(/[^a-z0-9_]/g,'') + '_' + Date.now(),
title, emoji, category, subcategory, author, desc, images,
type: submitType,
submittedBy,
};
if (submitType === 'recipe') {