fix(catalog): open visual manager from dedicated button
This commit is contained in:
1 parent
814d8650be
commit
0bedc04692
3 files changed
+14
-91
No files matched your search
@@ -1,38 +0,0 @@
|
||||
import "server-only";
|
||||
import { asc, count, eq, or } from "drizzle-orm";
|
||||
import {
|
||||
CatalogItems,
|
||||
CatalogItemsBc,
|
||||
CatalogPages,
|
||||
CatalogPagesBc,
|
||||
db,
|
||||
} from "@/lib/db";
|
||||
import type { CatalogKind } from "./page-commands";
|
||||
export async function loadCatalogOverview(kind: CatalogKind) {
|
||||
const pages = kind === "bc" ? CatalogPagesBc : CatalogPages;
|
||||
const items = kind === "bc" ? CatalogItemsBc : CatalogItems;
|
||||
const [roots, pageCount, itemCount, enabledCount] = await Promise.all([
|
||||
db
|
||||
.select({
|
||||
id: pages.id,
|
||||
caption: pages.caption,
|
||||
iconImage: pages.iconImage,
|
||||
enabled: pages.enabled,
|
||||
orderNum: pages.orderNum,
|
||||
})
|
||||
.from(pages)
|
||||
.where(or(eq(pages.parentId, -1), eq(pages.parentId, 0)))
|
||||
.orderBy(asc(pages.orderNum), asc(pages.id)),
|
||||
db.select({ total: count() }).from(pages),
|
||||
db.select({ total: count() }).from(items),
|
||||
db.select({ total: count() }).from(pages).where(eq(pages.enabled, "1")),
|
||||
]);
|
||||
return {
|
||||
roots,
|
||||
totals: {
|
||||
totalPages: Number(pageCount[0]?.total ?? 0),
|
||||
totalItems: Number(itemCount[0]?.total ?? 0),
|
||||
enabledPages: Number(enabledCount[0]?.total ?? 0),
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user