Polish catalog studio: undo delete, save status pill, faster totals
This commit is contained in:
1 parent
6e0ffff94b
commit
67430e7e9d
5 files changed
+187
-9
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import { asc, count, eq, or } from "drizzle-orm";
|
||||
import { Crown, Store, Wrench } from "lucide-react";
|
||||
import { unstable_cache } from "next/cache";
|
||||
import Link from "next/link";
|
||||
import { redirect } from "next/navigation";
|
||||
import { getTranslations } from "next-intl/server";
|
||||
@@ -42,6 +43,12 @@ async function loadTotals(catalogType: "normal" | "bc"): Promise<Totals> {
|
||||
};
|
||||
}
|
||||
|
||||
const getCachedTotals = unstable_cache(
|
||||
async (catalogType: "normal" | "bc") => loadTotals(catalogType),
|
||||
["admin-catalog-totals"],
|
||||
{ revalidate: 30 },
|
||||
);
|
||||
|
||||
async function loadRootPages(catalogType: "normal" | "bc"): Promise<RootTab[]> {
|
||||
const pagesTable = catalogType === "bc" ? CatalogPagesBc : CatalogPages;
|
||||
const rootRaw = await db
|
||||
@@ -78,7 +85,7 @@ export default async function CatalogPagesPage({
|
||||
const catalogType = sp.catalog === "bc" ? "bc" : "normal";
|
||||
|
||||
const [totals, rootPages] = await Promise.all([
|
||||
loadTotals(catalogType),
|
||||
getCachedTotals(catalogType),
|
||||
loadRootPages(catalogType),
|
||||
]);
|
||||
|
||||
|
||||
Reference in new issue
Block a user