feat(admin): items_base browser and AdminPageShell on core pages
Co-authored-by: Cursor <[email protected]>
This commit is contained in:
1 parent
7138ae4445
commit
98613af875
42 files changed
+2196
-698
No files matched your search
@@ -0,0 +1,66 @@
|
||||
import { Package } from "lucide-react";
|
||||
import { notFound, redirect } from "next/navigation";
|
||||
import { getTranslations } from "next-intl/server";
|
||||
import { AdminPageShell } from "@/components/admin/admin-page-shell";
|
||||
import { canAccess, getAdminContext, PERMS } from "@/lib/permissions";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import { ItemsBaseEditForm } from "./items-base-edit-form";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export default async function ItemsBaseDetailPage({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<{ id: string }>;
|
||||
}) {
|
||||
const { session, permissions } = await getAdminContext();
|
||||
if (!canAccess(permissions, PERMS.CATALOG_VIEW, session.user.rank)) {
|
||||
redirect("/admin");
|
||||
}
|
||||
|
||||
const t = await getTranslations("pages.admin.items");
|
||||
const { id: rawId } = await params;
|
||||
const id = Number(rawId);
|
||||
if (!Number.isFinite(id) || id <= 0) notFound();
|
||||
|
||||
const item = await prisma.itemsBase.findUnique({ where: { id } });
|
||||
if (!item) notFound();
|
||||
|
||||
const canEdit = canAccess(permissions, PERMS.CATALOG_EDIT, session.user.rank);
|
||||
|
||||
return (
|
||||
<AdminPageShell
|
||||
icon={Package}
|
||||
title={t("editTitle", { name: item.publicName || item.itemName })}
|
||||
subtitle={t("editSubtitle", { id: item.id })}
|
||||
>
|
||||
<ItemsBaseEditForm
|
||||
canEdit={canEdit}
|
||||
initial={{
|
||||
id: item.id,
|
||||
spriteId: item.spriteId,
|
||||
publicName: item.publicName,
|
||||
itemName: item.itemName,
|
||||
type: item.type,
|
||||
width: item.width,
|
||||
length: item.length,
|
||||
stackHeight: String(item.stackHeight),
|
||||
allowStack: item.allowStack,
|
||||
allowSit: item.allowSit,
|
||||
allowLay: item.allowLay,
|
||||
allowWalk: item.allowWalk,
|
||||
allowGift: item.allowGift,
|
||||
allowTrade: item.allowTrade,
|
||||
allowRecycle: item.allowRecycle,
|
||||
allowMarketplaceSell: item.allowMarketplaceSell,
|
||||
allowInventoryStack: item.allowInventoryStack,
|
||||
interactionType: item.interactionType,
|
||||
interactionModesCount: item.interactionModesCount,
|
||||
vendingIds: item.vendingIds,
|
||||
multiheight: item.multiheight,
|
||||
customparams: item.customparams,
|
||||
}}
|
||||
/>
|
||||
</AdminPageShell>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user