- Add 11 missing server action files: badges, bulk-users, catalog, catalog-bc, catalog-items, import-badges, import-furni, multi-account-detect, permissions, rooms, soundtracks - Add missing admin navigation links: tickets, sounds, translations, import, radio sub-pages - Add translation keys for all new navigation items
243 lines
10 KiB
TypeScript
243 lines
10 KiB
TypeScript
import Link from "next/link";
|
|
import { redirect } from "next/navigation";
|
|
import type { ReactNode } from "react";
|
|
import { getTranslations } from "next-intl/server";
|
|
import { AdminNavLink } from "@/components/admin/admin-nav-link";
|
|
import { requireStaff } from "@/lib/admin/guard";
|
|
import { prisma } from "@/lib/prisma";
|
|
import { siteSettings } from "@/lib/services/site-settings";
|
|
import {
|
|
LayoutDashboard,
|
|
Newspaper,
|
|
Tags,
|
|
Compass,
|
|
HelpCircle,
|
|
Megaphone,
|
|
SquarePen,
|
|
Image,
|
|
Users,
|
|
Ban,
|
|
Globe,
|
|
Shield,
|
|
ClipboardList,
|
|
Group,
|
|
Key,
|
|
Store,
|
|
ShoppingCart,
|
|
Receipt,
|
|
Ticket,
|
|
CreditCard,
|
|
Gem,
|
|
Award,
|
|
Trophy,
|
|
Calendar,
|
|
Radio,
|
|
History,
|
|
Terminal,
|
|
Monitor,
|
|
Bell,
|
|
FileText,
|
|
Filter,
|
|
Wrench,
|
|
Settings,
|
|
DoorOpen,
|
|
Mail,
|
|
Palette,
|
|
Cog,
|
|
LogOut,
|
|
Music,
|
|
Languages,
|
|
Upload,
|
|
MessageSquare,
|
|
} from "lucide-react";
|
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
function getNavGroups(t: (key: string) => string) {
|
|
return [
|
|
{
|
|
label: t("overview"),
|
|
icon: <LayoutDashboard size={14} />,
|
|
items: [{ href: "/admin", label: t("dashboard"), icon: <LayoutDashboard size={16} /> }],
|
|
},
|
|
{
|
|
label: t("content"),
|
|
icon: <Newspaper size={14} />,
|
|
items: [
|
|
{ href: "/admin/articles", label: t("articles"), icon: <Newspaper size={16} /> },
|
|
{ href: "/admin/tags", label: t("tags"), icon: <Tags size={16} /> },
|
|
{ href: "/admin/navigation", label: t("navigator"), icon: <Compass size={16} /> },
|
|
{ href: "/admin/help-questions", label: t("helpCenter"), icon: <HelpCircle size={16} /> },
|
|
{ href: "/admin/ads", label: t("advertisements"), icon: <Megaphone size={16} /> },
|
|
{ href: "/admin/writeable-boxes", label: t("writeableBoxes"), icon: <SquarePen size={16} /> },
|
|
{ href: "/admin/photos", label: t("photos"), icon: <Image size={16} /> },
|
|
{ href: "/admin/tickets", label: t("tickets"), icon: <MessageSquare size={16} /> },
|
|
],
|
|
},
|
|
{
|
|
label: t("usersAccess"),
|
|
icon: <Shield size={14} />,
|
|
items: [
|
|
{ href: "/admin/users", label: t("users"), icon: <Users size={16} /> },
|
|
{ href: "/admin/bans", label: t("bans"), icon: <Ban size={16} /> },
|
|
{ href: "/admin/ip", label: t("ipManagement"), icon: <Globe size={16} /> },
|
|
{ href: "/admin/vpn", label: t("vpn"), icon: <Shield size={16} /> },
|
|
{ href: "/admin/applications", label: t("applications"), icon: <ClipboardList size={16} /> },
|
|
{ href: "/admin/teams", label: t("teams"), icon: <Group size={16} /> },
|
|
{ href: "/admin/permissions", label: t("permissions"), icon: <Key size={16} /> },
|
|
],
|
|
},
|
|
{
|
|
label: t("economy"),
|
|
icon: <ShoppingCart size={14} />,
|
|
items: [
|
|
{ href: "/admin/catalog", label: t("catalog"), icon: <Store size={16} /> },
|
|
{ href: "/admin/shop", label: t("shop"), icon: <ShoppingCart size={16} /> },
|
|
{ href: "/admin/transactions", label: t("transactions"), icon: <Receipt size={16} /> },
|
|
{ href: "/admin/vouchers", label: t("vouchers"), icon: <Ticket size={16} /> },
|
|
{ href: "/admin/subscriptions", label: t("subscriptions"), icon: <CreditCard size={16} /> },
|
|
{ href: "/admin/rare-values", label: t("rareValues"), icon: <Gem size={16} /> },
|
|
{ href: "/admin/badges", label: t("badges"), icon: <Award size={16} /> },
|
|
{ href: "/admin/achievements", label: t("achievements"), icon: <Trophy size={16} /> },
|
|
{ href: "/admin/calendar", label: t("calendar"), icon: <Calendar size={16} /> },
|
|
],
|
|
},
|
|
{
|
|
label: t("radio"),
|
|
icon: <Radio size={14} />,
|
|
items: [
|
|
{ href: "/admin/radio", label: t("radio"), icon: <Radio size={16} /> },
|
|
{ href: "/admin/radio/history", label: t("radioHistory"), icon: <History size={16} /> },
|
|
{ href: "/admin/radio/banners", label: t("radioBanners"), icon: <Image size={16} /> },
|
|
{ href: "/admin/radio/embed", label: t("radioEmbed"), icon: <Radio size={16} /> },
|
|
{ href: "/admin/radio/api-keys", label: t("radioApiKeys"), icon: <Key size={16} /> },
|
|
{ href: "/admin/radio/moderation", label: t("radioModeration"), icon: <Shield size={16} /> },
|
|
{ href: "/admin/radio/settings", label: t("radioSettings"), icon: <Settings size={16} /> },
|
|
{ href: "/admin/radio/monitoring", label: t("radioMonitoring"), icon: <Monitor size={16} /> },
|
|
{ href: "/admin/radio/points", label: t("radioPoints"), icon: <Gem size={16} /> },
|
|
{ href: "/admin/radio/ranks", label: t("radioRanks"), icon: <Group size={16} /> },
|
|
{ href: "/admin/radio/autodj", label: t("radioAutodj"), icon: <Radio size={16} /> },
|
|
],
|
|
},
|
|
{
|
|
label: t("system"),
|
|
icon: <Settings size={14} />,
|
|
items: [
|
|
{ href: "/admin/commandocentrum", label: t("commandocentrum"), icon: <Terminal size={16} /> },
|
|
{ href: "/admin/emulator", label: t("emulator"), icon: <Monitor size={16} /> },
|
|
{ href: "/admin/alerts", label: t("alerts"), icon: <Bell size={16} /> },
|
|
{ href: "/admin/logs", label: t("logs"), icon: <FileText size={16} /> },
|
|
{ href: "/admin/wordfilter", label: t("wordFilter"), icon: <Filter size={16} /> },
|
|
{ href: "/admin/maintenance", label: t("maintenance"), icon: <Wrench size={16} /> },
|
|
{ href: "/admin/housekeeping", label: t("housekeeping"), icon: <Settings size={16} /> },
|
|
{ href: "/admin/rooms", label: t("rooms"), icon: <DoorOpen size={16} /> },
|
|
{ href: "/admin/email-templates", label: t("emailTemplates"), icon: <Mail size={16} /> },
|
|
{ href: "/admin/theme", label: t("theme"), icon: <Palette size={16} /> },
|
|
{ href: "/admin/media", label: t("media"), icon: <Image size={16} /> },
|
|
{ href: "/admin/favicon", label: t("favicon"), icon: <Image size={16} /> },
|
|
{ href: "/admin/sounds", label: t("sounds"), icon: <Music size={16} /> },
|
|
{ href: "/admin/translations", label: t("translations"), icon: <Languages size={16} /> },
|
|
{ href: "/admin/import", label: t("import"), icon: <Upload size={16} /> },
|
|
{ href: "/admin/settings", label: t("settings"), icon: <Cog size={16} /> },
|
|
],
|
|
},
|
|
];
|
|
}
|
|
|
|
export default async function AdminLayout({ children }: { children: ReactNode }) {
|
|
const staff = await requireStaff();
|
|
if (await siteSettings.getBool("force_staff_2fa", false)) {
|
|
const u = await prisma.user
|
|
.findUnique({ where: { id: staff.id }, select: { twoFactorConfirmedAt: true } })
|
|
.catch(() => null);
|
|
if (!u?.twoFactorConfirmedAt) redirect("/settings/2fa?error=staffrequired");
|
|
}
|
|
|
|
return (
|
|
<div className="grid grid-cols-1 lg:grid-cols-[260px_minmax(0,1fr)] min-h-screen bg-[var(--color-background)]">
|
|
<Sidebar staff={staff} />
|
|
<div className="flex flex-col min-w-0 p-5 lg:p-6">
|
|
<Topbar staff={staff} />
|
|
<section className="admin-page flex-1">{children}</section>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
async function Sidebar({ staff }: { staff: { id: number; username: string; rank: number } }) {
|
|
const t = await getTranslations("pages.admin.nav");
|
|
const initial = staff.username.charAt(0).toUpperCase();
|
|
const navGroups = getNavGroups(t);
|
|
|
|
return (
|
|
<aside className="sticky top-0 self-start h-screen bg-gradient-to-b from-[#1e1b2e] to-[#151226] text-[#c8cbe0] shadow-xl flex flex-col">
|
|
<div className="flex items-center gap-3 px-4 py-5 border-b border-white/[0.06]">
|
|
<span
|
|
className="flex-none w-10 h-10 rounded-xl grid place-items-center font-extrabold text-base text-[#1a1a2e] bg-gradient-to-br from-[var(--color-primary)] to-[var(--color-primary-hover)] shadow-lg shadow-[var(--color-primary)]/20"
|
|
aria-hidden
|
|
>
|
|
{initial}
|
|
</span>
|
|
<div className="min-w-0 flex-1">
|
|
<div className="font-semibold text-sm text-white truncate">{staff.username}</div>
|
|
<span className="inline-block mt-0.5 text-[0.6rem] font-bold uppercase tracking-widest text-[rgba(200,203,224,0.5)]">
|
|
{t("rankLabel", { rank: staff.rank })}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
|
|
<nav className="flex-1 overflow-y-auto px-3 py-4 space-y-1">
|
|
{navGroups.map((group) => (
|
|
<div key={group.label}>
|
|
<div className="flex items-center gap-1.5 px-2 py-2 text-[0.6rem] font-bold uppercase tracking-[0.12em] text-[rgba(200,203,224,0.3)]">
|
|
{group.icon}
|
|
<span>{group.label}</span>
|
|
</div>
|
|
<div className="space-y-0.5">
|
|
{group.items.map((item) => (
|
|
<AdminNavLink key={item.href} href={item.href} icon={item.icon}>
|
|
{item.label}
|
|
</AdminNavLink>
|
|
))}
|
|
</div>
|
|
</div>
|
|
))}
|
|
</nav>
|
|
|
|
<div className="px-3 py-3 border-t border-white/[0.06]">
|
|
<Link
|
|
href="/"
|
|
className="flex items-center gap-2.5 px-2.5 py-2 rounded-lg text-[#c8cbe0]/60 text-xs font-medium hover:text-white hover:bg-white/5 transition-all duration-150 no-underline"
|
|
>
|
|
<LogOut size={14} />
|
|
<span>{t("backToSite")}</span>
|
|
</Link>
|
|
</div>
|
|
</aside>
|
|
);
|
|
}
|
|
|
|
async function Topbar({ staff }: { staff: { id: number; username: string; rank: number } }) {
|
|
const t = await getTranslations("pages.admin.nav");
|
|
|
|
return (
|
|
<header className="flex items-center justify-between gap-4 bg-[var(--color-surface)] border border-[var(--border-subtle)] rounded-2xl px-5 py-3 mb-5 shadow-card">
|
|
<div className="flex items-center gap-3">
|
|
<h2 className="m-0 text-base font-extrabold text-[var(--color-text)]">{t("housekeeping")}</h2>
|
|
<span className="hidden sm:inline-block w-px h-5 bg-[var(--border-subtle)]" />
|
|
<span className="hidden sm:inline text-xs text-[var(--color-text-muted)]">
|
|
{t("hotelManagementPanel")}
|
|
</span>
|
|
</div>
|
|
<div className="flex items-center gap-3">
|
|
<span className="text-xs text-[var(--color-text-muted)]">
|
|
<strong className="text-[var(--color-text)]">{staff.username}</strong>
|
|
</span>
|
|
<span className="inline-flex items-center gap-1.5 text-[0.6rem] font-bold uppercase tracking-wider text-[#1a1a2e] bg-[var(--color-primary)] rounded-full px-2.5 py-1">
|
|
{t("rankLabel", { rank: staff.rank })}
|
|
</span>
|
|
</div>
|
|
</header>
|
|
);
|
|
}
|