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
@@ -1,4 +1,7 @@
|
||||
import { Store } from "lucide-react";
|
||||
import { redirect } from "next/navigation";
|
||||
import { getTranslations } from "next-intl/server";
|
||||
import { AdminPageShell } from "@/components/admin/admin-page-shell";
|
||||
import { CatalogTree } from "@/components/admin/catalog-tree";
|
||||
import { Prisma } from "@/generated/prisma/client";
|
||||
import { calcPagination, parseListParams } from "@/lib/admin-helpers";
|
||||
@@ -23,6 +26,7 @@ export default async function CatalogPagesPage({
|
||||
}
|
||||
|
||||
const canEdit = canAccess(permissions, PERMS.CATALOG_EDIT, session.user.rank);
|
||||
const t = await getTranslations("pages.admin.catalog");
|
||||
|
||||
const params = await searchParams;
|
||||
const sp = new URLSearchParams(params);
|
||||
@@ -200,50 +204,52 @@ export default async function CatalogPagesPage({
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<div className="flex items-center justify-between">
|
||||
<p className="text-muted-foreground">
|
||||
{totalBcPages} BC pages ({enabledBcPages} enabled) ·{" "}
|
||||
{totalBcItems} items
|
||||
</p>
|
||||
<div className="flex items-center gap-2">
|
||||
<CatalogViewToggle currentView={viewMode} catalogType="bc" />
|
||||
{canEdit && (
|
||||
<CatalogManagerDialog
|
||||
catalogType="bc"
|
||||
canEdit={canEdit}
|
||||
totals={{
|
||||
totalPages: totalBcPages,
|
||||
enabledPages: enabledBcPages,
|
||||
totalItems: totalBcItems,
|
||||
}}
|
||||
initialRoots={bcRootPages.map((p) => ({
|
||||
id: p.id,
|
||||
caption: p.caption,
|
||||
iconImage: p.iconImage,
|
||||
enabled: p.enabled,
|
||||
orderNum: 0,
|
||||
}))}
|
||||
/>
|
||||
)}
|
||||
{canEdit && (
|
||||
<CatalogActions
|
||||
catalogType="bc"
|
||||
initialParentId={sp.get("newPageParent")}
|
||||
/>
|
||||
)}
|
||||
<AdminPageShell icon={Store} title={t("title")} subtitle={t("subtitle")}>
|
||||
<div className="space-y-6">
|
||||
<div className="flex items-center justify-between">
|
||||
<p className="text-muted-foreground">
|
||||
{totalBcPages} BC pages ({enabledBcPages} enabled) ·{" "}
|
||||
{totalBcItems} items
|
||||
</p>
|
||||
<div className="flex items-center gap-2">
|
||||
<CatalogViewToggle currentView={viewMode} catalogType="bc" />
|
||||
{canEdit && (
|
||||
<CatalogManagerDialog
|
||||
catalogType="bc"
|
||||
canEdit={canEdit}
|
||||
totals={{
|
||||
totalPages: totalBcPages,
|
||||
enabledPages: enabledBcPages,
|
||||
totalItems: totalBcItems,
|
||||
}}
|
||||
initialRoots={bcRootPages.map((p) => ({
|
||||
id: p.id,
|
||||
caption: p.caption,
|
||||
iconImage: p.iconImage,
|
||||
enabled: p.enabled,
|
||||
orderNum: 0,
|
||||
}))}
|
||||
/>
|
||||
)}
|
||||
{canEdit && (
|
||||
<CatalogActions
|
||||
catalogType="bc"
|
||||
initialParentId={sp.get("newPageParent")}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
{viewMode === "tree" ? (
|
||||
<CatalogTree rootPages={bcRootPages} catalogType="bc" />
|
||||
) : (
|
||||
<CatalogTable
|
||||
data={{ rows: bcRows, ...bcPagination }}
|
||||
canEdit={canEdit}
|
||||
catalogType="bc"
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
{viewMode === "tree" ? (
|
||||
<CatalogTree rootPages={bcRootPages} catalogType="bc" />
|
||||
) : (
|
||||
<CatalogTable
|
||||
data={{ rows: bcRows, ...bcPagination }}
|
||||
canEdit={canEdit}
|
||||
catalogType="bc"
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</AdminPageShell>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -396,43 +402,45 @@ export default async function CatalogPagesPage({
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<div className="flex items-center justify-between">
|
||||
<p className="text-muted-foreground">
|
||||
{totalPages} pages ({enabledPages} enabled) · {totalItems}{" "}
|
||||
items
|
||||
</p>
|
||||
<div className="flex items-center gap-2">
|
||||
<CatalogViewToggle currentView={viewMode} catalogType="normal" />
|
||||
{canEdit && (
|
||||
<CatalogManagerDialog
|
||||
catalogType="normal"
|
||||
canEdit={canEdit}
|
||||
totals={{
|
||||
totalPages,
|
||||
enabledPages,
|
||||
totalItems,
|
||||
}}
|
||||
initialRoots={rootPages.map((p) => ({
|
||||
id: p.id,
|
||||
caption: p.caption,
|
||||
iconImage: p.iconImage,
|
||||
enabled: p.enabled,
|
||||
orderNum: 0,
|
||||
}))}
|
||||
/>
|
||||
)}
|
||||
{canEdit && (
|
||||
<CatalogActions initialParentId={sp.get("newPageParent")} />
|
||||
)}
|
||||
<AdminPageShell icon={Store} title={t("title")} subtitle={t("subtitle")}>
|
||||
<div className="space-y-6">
|
||||
<div className="flex items-center justify-between">
|
||||
<p className="text-muted-foreground">
|
||||
{totalPages} pages ({enabledPages} enabled) · {totalItems}{" "}
|
||||
items
|
||||
</p>
|
||||
<div className="flex items-center gap-2">
|
||||
<CatalogViewToggle currentView={viewMode} catalogType="normal" />
|
||||
{canEdit && (
|
||||
<CatalogManagerDialog
|
||||
catalogType="normal"
|
||||
canEdit={canEdit}
|
||||
totals={{
|
||||
totalPages,
|
||||
enabledPages,
|
||||
totalItems,
|
||||
}}
|
||||
initialRoots={rootPages.map((p) => ({
|
||||
id: p.id,
|
||||
caption: p.caption,
|
||||
iconImage: p.iconImage,
|
||||
enabled: p.enabled,
|
||||
orderNum: 0,
|
||||
}))}
|
||||
/>
|
||||
)}
|
||||
{canEdit && (
|
||||
<CatalogActions initialParentId={sp.get("newPageParent")} />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{viewMode === "tree" ? (
|
||||
<CatalogTree rootPages={rootPages} catalogType="normal" />
|
||||
) : (
|
||||
<CatalogTable data={{ rows, ...pagination }} canEdit={canEdit} />
|
||||
)}
|
||||
</div>
|
||||
{viewMode === "tree" ? (
|
||||
<CatalogTree rootPages={rootPages} catalogType="normal" />
|
||||
) : (
|
||||
<CatalogTable data={{ rows, ...pagination }} canEdit={canEdit} />
|
||||
)}
|
||||
</div>
|
||||
</AdminPageShell>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user