import { ArrowLeft, BadgeCheck, Copy, ImagePlus, ScrollText, Settings2, Trash2, UserRound } from "lucide-react"; import { useEffect, useState, type ReactNode } from "react"; import { api, errorMessage } from "../api"; import { ActionButton } from "../components/ActionButton"; import { Avatar } from "../components/Avatar"; import { AvatarModal } from "../components/AvatarModal"; import { CopyBotTokenModal } from "../components/CopyBotTokenModal"; import { Alert, AuditTable, Badge, LoadingSurface, PageFrame, SectionHead, Summary } from "../components/ui"; import { ScamFakeActions, ScamFakeBadges } from "../components/flags"; import { ColorAction, EmojiStatusAction, UsernameAction } from "../components/attributes"; import { displayUsername, formatDate } from "../lib/format"; import type { Navigate } from "../routing"; import type { BotDetail } from "../types"; type Tab = "profile" | "actions"; export function BotDetailPage({ id, navigate }: { id: number; navigate: Navigate }) { const [detail, setDetail] = useState(null); const [error, setError] = useState(""); const [busy, setBusy] = useState(false); const [tab, setTab] = useState("profile"); const [avatarModalOpen, setAvatarModalOpen] = useState(false); const [avatarVersion, setAvatarVersion] = useState(0); const [copyTokenModalOpen, setCopyTokenModalOpen] = useState(false); async function load() { setBusy(true); setError(""); try { setDetail(await api.bot(id)); } catch (err) { setError(errorMessage(err)); } finally { setBusy(false); } } useEffect(() => { void load(); setTab("profile"); // eslint-disable-next-line react-hooks/exhaustive-deps }, [id]); if (error) { return {error}; } if (!detail) { return ; } const bot = detail.Bot; const tabs: Array<{ key: Tab; label: string; icon: ReactNode }> = [ { key: "profile", label: "Profile & Status", icon: }, { key: "actions", label: "Actions & Management", icon: } ]; return ( navigate("/bots")}> {"Back to list"}} >
{bot.FirstName || "Unnamed bot"}
{displayUsername(bot.Username) || "No username"}
{bot.System ? "System" : "User"} {bot.Verified ? {"Verified"} : {"Not verified"}}
{tabs.map((item) => ( ))}
{tab === "profile" && (
0 ? `${bot.OwnerUserID} ${displayUsername(detail.OwnerUsername)}`.trim() : "None"} />
{detail.About &&

{detail.About}

} {detail.Description && detail.Description.trim() !== detail.About.trim() &&

{detail.Description}

}
)} {tab === "actions" && (
} tone="neutral" path="/api/actions/set-verified" payload={() => ({ user_id: bot.ID, verified: !bot.Verified })} onDone={load} />
{!bot.System && (

{"Copies straight to the clipboard through a dedicated confirmation step -- the token itself is never shown on this page."}

)}
{bot.System ? (

{"System bots are built in and cannot be deleted."}

) : (
} tone="danger" path="/api/actions/delete-bot" payload={() => ({ bot_user_id: bot.ID })} onDone={() => navigate("/bots")} />

{"Permanently deletes this user-created bot and invalidates its token. This cannot be undone."}

)}
} />
)} {avatarModalOpen && ( setAvatarModalOpen(false)} onDone={() => { setAvatarVersion((v) => v + 1); void load(); }} /> )} {copyTokenModalOpen && ( setCopyTokenModalOpen(false)} /> )}
); }