Forum: whom a reply answers, icon badges, the new features on the pages
- Replies stay two levels deep, but a reply to a reply says whom it is
for ("↪ Holdfény"): posts.reply_to_id.
- The question stands apart on its own card; the listening reminder above
the reply box is gone.
- Every rank and badge has its own line icon (Vándor, Kereső, Fonó,
Csillagfonó, Sorsfonó; Moderátor, Meghallgató, Támogató, Szálindító).
- Pages for the new features: own avatar upload and the moderator's reset,
the listener and supporter switches, mention and weekly summary e-mails
(the weekly one off by default), "@" suggestions and mention links, the
daily sky thread by "Sorsfonalak", "Most itt vannak", joining restricted
topics, and the moderators' Témák tab (requests; topics for the admin).
- Members-only topics say so to members too.
- The privacy notice (HU, EN) and point 8.1 of the terms cover own
pictures, badges, mentions, restricted topics and the weekly summary;
the data export and account deletion include them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -0,0 +1,238 @@
|
||||
"use client";
|
||||
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
|
||||
import { Avatar } from "@/components/forum/Avatar";
|
||||
import { RankBadge } from "@/components/forum/Badges";
|
||||
import { api, errorText } from "@/lib/api";
|
||||
import { type ForumTopic, type TopicRequest, ago } from "@/lib/forum";
|
||||
|
||||
const VISIBILITY: Record<string, string> = {
|
||||
public: "Nyilvános (a keresők is látják)",
|
||||
members: "Csak tagoknak",
|
||||
restricted: "Zárt (jóváhagyással)",
|
||||
};
|
||||
|
||||
/** Moderators: requests to join restricted topics. Admins also: opening and editing topics. */
|
||||
export function TopicsAdmin({
|
||||
requests,
|
||||
topics,
|
||||
admin,
|
||||
}: {
|
||||
requests: TopicRequest[];
|
||||
topics: ForumTopic[];
|
||||
admin: boolean;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [form, setForm] = useState({ name: "", description: "", visibility: "restricted", listening: false });
|
||||
|
||||
async function act(work: () => Promise<unknown>) {
|
||||
setBusy(true);
|
||||
setError(null);
|
||||
try {
|
||||
await work();
|
||||
router.refresh();
|
||||
} catch (e) {
|
||||
setError(errorText(e));
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
const decide = (r: TopicRequest, action: "approve" | "reject" | "remove") =>
|
||||
act(() =>
|
||||
api("/forum/mod/topic-requests", {
|
||||
body: { topic: r.topic.slug, nickname: r.member?.nickname ?? "", action },
|
||||
}),
|
||||
);
|
||||
|
||||
const pending = requests.filter((r) => r.status === "pending");
|
||||
const approved = requests.filter((r) => r.status === "approved");
|
||||
|
||||
return (
|
||||
<>
|
||||
{error && (
|
||||
<p className="msg msg-error" role="alert">
|
||||
{error}
|
||||
</p>
|
||||
)}
|
||||
<section className="fh-section" aria-labelledby="ftop-pending">
|
||||
<h2 id="ftop-pending" className="fmsg-h">
|
||||
Jelentkezések zárt témákba ({pending.length})
|
||||
</h2>
|
||||
{pending.length === 0 ? (
|
||||
<p className="fh-card fh-empty">Nincs várakozó jelentkezés.</p>
|
||||
) : (
|
||||
pending.map((r) => (
|
||||
<article key={`${r.topic.slug}-${r.member?.nickname}`} className="fh-card fmod-report">
|
||||
<div className="fmod-report-head">
|
||||
<span className="fh-online-item">
|
||||
<Avatar avatar={r.member?.avatar} size={28} />
|
||||
<strong>{r.member?.nickname ?? "?"}</strong>
|
||||
{r.member && <RankBadge rank={r.member.rank} name={r.member.rank_name} />}
|
||||
</span>
|
||||
<span className="hint">
|
||||
{r.topic.name} ·{" "}
|
||||
<time suppressHydrationWarning dateTime={r.requested_at}>
|
||||
{ago(r.requested_at)}
|
||||
</time>
|
||||
</span>
|
||||
</div>
|
||||
{r.note && <p className="fmod-note">„{r.note}”</p>}
|
||||
<div className="fmsg-actions">
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-sm btn-primary"
|
||||
disabled={busy}
|
||||
onClick={() => decide(r, "approve")}
|
||||
>
|
||||
Jóváhagyom
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-sm btn-ghost"
|
||||
disabled={busy}
|
||||
onClick={() => decide(r, "reject")}
|
||||
>
|
||||
Elutasítom
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
))
|
||||
)}
|
||||
</section>
|
||||
|
||||
{approved.length > 0 && (
|
||||
<section className="fh-section" aria-labelledby="ftop-members">
|
||||
<h2 id="ftop-members" className="fmsg-h">
|
||||
Zárt témák tagjai
|
||||
</h2>
|
||||
<ul className="fh-card fh-flush fmodlog">
|
||||
{approved.map((r) => (
|
||||
<li key={`${r.topic.slug}-${r.member?.nickname}`} className="ftop-member">
|
||||
<span className="fh-online-item">
|
||||
<Avatar avatar={r.member?.avatar} size={24} />
|
||||
{r.member?.nickname ?? "?"}
|
||||
<span className="hint">· {r.topic.name}</span>
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-sm btn-ghost"
|
||||
disabled={busy}
|
||||
onClick={() =>
|
||||
window.confirm(`Eltávolítod ${r.member?.nickname} tagot a(z) „${r.topic.name}” témából?`) &&
|
||||
decide(r, "remove")
|
||||
}
|
||||
>
|
||||
Eltávolítom
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
)}
|
||||
|
||||
{admin && (
|
||||
<section className="fh-section" aria-labelledby="ftop-admin">
|
||||
<h2 id="ftop-admin" className="fmsg-h">
|
||||
Témák (admin)
|
||||
</h2>
|
||||
<ul className="fh-card fh-flush fmodlog">
|
||||
{topics.map((t) => (
|
||||
<li key={t.slug} className="ftop-member">
|
||||
<span>
|
||||
<strong>{t.name}</strong> <span className="hint">· {VISIBILITY[t.visibility] ?? t.visibility}</span>
|
||||
</span>
|
||||
<select
|
||||
className="inp ftop-vis"
|
||||
aria-label={`${t.name} láthatósága`}
|
||||
value={t.visibility}
|
||||
disabled={busy}
|
||||
onChange={(e) =>
|
||||
act(() => api(`/forum/topics/${t.slug}`, { method: "PATCH", body: { visibility: e.target.value } }))
|
||||
}
|
||||
>
|
||||
{Object.entries(VISIBILITY).map(([value, label]) => (
|
||||
<option key={value} value={value}>
|
||||
{label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<form
|
||||
className="fh-card fnew"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
void act(async () => {
|
||||
await api("/forum/topics", { body: form });
|
||||
setForm({ name: "", description: "", visibility: "restricted", listening: false });
|
||||
});
|
||||
}}
|
||||
>
|
||||
<strong>Új téma</strong>
|
||||
<div className="field">
|
||||
<label htmlFor="ftop-name">Név</label>
|
||||
<input
|
||||
id="ftop-name"
|
||||
className="inp"
|
||||
value={form.name}
|
||||
maxLength={60}
|
||||
onChange={(e) => setForm({ ...form, name: e.target.value })}
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<div className="field">
|
||||
<label htmlFor="ftop-desc">Rövid leírás</label>
|
||||
<input
|
||||
id="ftop-desc"
|
||||
className="inp"
|
||||
value={form.description}
|
||||
maxLength={160}
|
||||
onChange={(e) => setForm({ ...form, description: e.target.value })}
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<div className="field">
|
||||
<label htmlFor="ftop-visibility">Láthatóság</label>
|
||||
<select
|
||||
id="ftop-visibility"
|
||||
className="inp"
|
||||
value={form.visibility}
|
||||
onChange={(e) => setForm({ ...form, visibility: e.target.value })}
|
||||
>
|
||||
{Object.entries(VISIBILITY).map(([value, label]) => (
|
||||
<option key={value} value={value}>
|
||||
{label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
<label className="fprof-check">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={form.listening}
|
||||
onChange={(e) => setForm({ ...form, listening: e.target.checked })}
|
||||
/>
|
||||
<span>
|
||||
<strong>Meghallgatós téma</strong>
|
||||
<span className="hint">Az új szálak alapból meghallgatást kérnek, nem tanácsot.</span>
|
||||
</span>
|
||||
</label>
|
||||
<button
|
||||
type="submit"
|
||||
className="btn btn-primary"
|
||||
disabled={busy || !form.name.trim() || !form.description.trim()}
|
||||
>
|
||||
Téma létrehozása
|
||||
</button>
|
||||
</form>
|
||||
</section>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user