Forum: founders are the first fifteen; the admin can take or give the badge
The site has few members yet, some of them test accounts: the badge goes to the first fifteen, and the admin can take it from a test account on its profile (the place goes to the next newcomer) or give it. 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,49 @@
|
||||
"use client";
|
||||
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
|
||||
import { api, errorText } from "@/lib/api";
|
||||
|
||||
/** The admin's switch for the "Alapító tag" badge (e.g. off for a test account; the place goes to the next newcomer). */
|
||||
export function FounderToggle({ nickname, founder }: { nickname: string; founder: boolean }) {
|
||||
const router = useRouter();
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
return (
|
||||
<div className="fmute">
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-sm btn-ghost"
|
||||
disabled={busy}
|
||||
onClick={async () => {
|
||||
if (
|
||||
founder &&
|
||||
!window.confirm(`Elveszed ${nickname} Alapító tag jelvényét? A helyét a következő új tag kapja.`)
|
||||
)
|
||||
return;
|
||||
setBusy(true);
|
||||
setError(null);
|
||||
try {
|
||||
await api(`/forum/members/${encodeURIComponent(nickname)}/founder`, {
|
||||
method: "PUT",
|
||||
body: { founder: !founder },
|
||||
});
|
||||
router.refresh();
|
||||
} catch (e) {
|
||||
setError(errorText(e));
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}}
|
||||
>
|
||||
{founder ? "Alapító tag jelvény elvétele" : "Alapító tag jelvény megadása"}
|
||||
</button>
|
||||
{error && (
|
||||
<p className="msg msg-error" role="alert">
|
||||
{error}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -8,8 +8,10 @@ import { Badge, RankBadge } from "@/components/forum/Badges";
|
||||
import { PostBody } from "@/components/forum/PostBody";
|
||||
import { type MemberProfile, ago, banText, threadHref } from "@/lib/forum";
|
||||
import { forumGet } from "@/lib/forumServer";
|
||||
import { getMe } from "@/lib/server";
|
||||
|
||||
import { BanPanel } from "./BanPanel";
|
||||
import { FounderToggle } from "./FounderToggle";
|
||||
import { MuteButton } from "./MuteButton";
|
||||
import { RequestPanel } from "./RequestPanel";
|
||||
|
||||
@@ -37,6 +39,7 @@ export default async function MemberPage({ params }: Props) {
|
||||
if (!res.ok) notFound();
|
||||
const { member, recent, viewer } = res.data;
|
||||
const a = member.author;
|
||||
const admin = viewer.logged_in ? ((await getMe())?.user.roles.includes("admin") ?? false) : false;
|
||||
const signs = signsText(a.signs);
|
||||
const since = new Date(member.created_at).toLocaleDateString("hu-HU", { year: "numeric", month: "long" });
|
||||
return (
|
||||
@@ -73,6 +76,7 @@ export default async function MemberPage({ params }: Props) {
|
||||
</Link>
|
||||
)}
|
||||
{viewer.member && !member.own && <MuteButton nickname={a.nickname} muted={member.muted} />}
|
||||
{admin && <FounderToggle nickname={a.nickname} founder={a.founder ?? false} />}
|
||||
{viewer.moderator && !member.own && !a.moderator && (
|
||||
<BanPanel
|
||||
nickname={a.nickname}
|
||||
|
||||
Reference in New Issue
Block a user