Merge branch 'main' into feat/deploy-restore-next-cache

This commit is contained in:
Simo committed 2026-07-18 21:17:01 +02:00
commit 0fcdd45fdc
8 files changed
+150 -34

No files matched your search

+24 -1
View File
@@ -1,7 +1,8 @@
"use client"; "use client";
import { Loader2, Plus } from "lucide-react"; import { Loader2, Plus } from "lucide-react";
import { useState } from "react"; import { useRouter } from "next/navigation";
import { useEffect, useState } from "react";
import { toast } from "sonner"; import { toast } from "sonner";
import { createCatalogPage } from "@/actions/catalog"; import { createCatalogPage } from "@/actions/catalog";
import { createBcPage } from "@/actions/catalog-bc"; import { createBcPage } from "@/actions/catalog-bc";
@@ -26,18 +27,40 @@ import { CATALOG_LAYOUTS } from "@/lib/catalog-layouts";
interface CatalogActionsProps { interface CatalogActionsProps {
catalogType?: "normal" | "bc"; catalogType?: "normal" | "bc";
/** Prefill parent and auto-open create dialog (from ?newPageParent=). */
initialParentId?: string | null;
} }
export function CatalogActions({ export function CatalogActions({
catalogType = "normal", catalogType = "normal",
initialParentId = null,
}: CatalogActionsProps) { }: CatalogActionsProps) {
const { run, isPending } = useServerAction(); const { run, isPending } = useServerAction();
const router = useRouter();
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
const [caption, setCaption] = useState(""); const [caption, setCaption] = useState("");
const [parentId, setParentId] = useState("-1"); const [parentId, setParentId] = useState("-1");
const [pageLayout, setPageLayout] = useState("default_3x3"); const [pageLayout, setPageLayout] = useState("default_3x3");
const isBc = catalogType === "bc"; const isBc = catalogType === "bc";
useEffect(() => {
if (initialParentId == null || initialParentId === "") return;
const n = Number.parseInt(initialParentId, 10);
if (!Number.isFinite(n)) return;
setParentId(String(n));
setOpen(true);
if (typeof window === "undefined") return;
const url = new URL(window.location.href);
if (url.searchParams.has("newPageParent")) {
url.searchParams.delete("newPageParent");
const qs = url.searchParams.toString();
router.replace(`${url.pathname}${qs ? `?${qs}` : ""}`, {
scroll: false,
});
}
}, [initialParentId, router]);
function handleCreate() { function handleCreate() {
if (!caption.trim()) { if (!caption.trim()) {
toast.error("Caption is required"); toast.error("Caption is required");
+19 -2
View File
@@ -212,6 +212,11 @@ export default async function CatalogPagesPage({
<CatalogManagerDialog <CatalogManagerDialog
catalogType="bc" catalogType="bc"
canEdit={canEdit} canEdit={canEdit}
totals={{
totalPages: totalBcPages,
enabledPages: enabledBcPages,
totalItems: totalBcItems,
}}
initialRoots={bcRootPages.map((p) => ({ initialRoots={bcRootPages.map((p) => ({
id: p.id, id: p.id,
caption: p.caption, caption: p.caption,
@@ -221,7 +226,12 @@ export default async function CatalogPagesPage({
}))} }))}
/> />
)} )}
{canEdit && <CatalogActions catalogType="bc" />} {canEdit && (
<CatalogActions
catalogType="bc"
initialParentId={sp.get("newPageParent")}
/>
)}
</div> </div>
</div> </div>
{viewMode === "tree" ? ( {viewMode === "tree" ? (
@@ -398,6 +408,11 @@ export default async function CatalogPagesPage({
<CatalogManagerDialog <CatalogManagerDialog
catalogType="normal" catalogType="normal"
canEdit={canEdit} canEdit={canEdit}
totals={{
totalPages,
enabledPages,
totalItems,
}}
initialRoots={rootPages.map((p) => ({ initialRoots={rootPages.map((p) => ({
id: p.id, id: p.id,
caption: p.caption, caption: p.caption,
@@ -407,7 +422,9 @@ export default async function CatalogPagesPage({
}))} }))}
/> />
)} )}
{canEdit && <CatalogActions />} {canEdit && (
<CatalogActions initialParentId={sp.get("newPageParent")} />
)}
</div> </div>
</div> </div>
@@ -13,7 +13,7 @@ import { BreadcrumbBar } from "./breadcrumb-bar";
import { InlineEditor, type PageUpdateData } from "./inline-editor"; import { InlineEditor, type PageUpdateData } from "./inline-editor";
import { RootTabs } from "./root-tabs"; import { RootTabs } from "./root-tabs";
import { SortableTree } from "./sortable-tree"; import { SortableTree } from "./sortable-tree";
import { StatsBar } from "./stats-bar"; import { type CatalogStatsTotals, StatsBar } from "./stats-bar";
import { import {
CatalogManagerProvider, CatalogManagerProvider,
type CatalogManagerMode, type CatalogManagerMode,
@@ -29,10 +29,12 @@ export function CatalogManagerDialog({
initialRoots = [], initialRoots = [],
catalogType = "normal", catalogType = "normal",
canEdit = false, canEdit = false,
totals = null,
}: { }: {
initialRoots?: RootTab[]; initialRoots?: RootTab[];
catalogType?: CatalogManagerMode; catalogType?: CatalogManagerMode;
canEdit?: boolean; canEdit?: boolean;
totals?: CatalogStatsTotals | null;
}) { }) {
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
const [mounted, setMounted] = useState(false); const [mounted, setMounted] = useState(false);
@@ -89,6 +91,7 @@ export function CatalogManagerDialog({
open={open} open={open}
onOpenChange={setOpen} onOpenChange={setOpen}
initialRoots={initialRoots} initialRoots={initialRoots}
totals={totals}
/> />
</CatalogManagerProvider> </CatalogManagerProvider>
</div> </div>
@@ -104,10 +107,12 @@ function CatalogManagerInner({
open, open,
onOpenChange, onOpenChange,
initialRoots, initialRoots,
totals,
}: { }: {
open: boolean; open: boolean;
onOpenChange: (v: boolean) => void; onOpenChange: (v: boolean) => void;
initialRoots: RootTab[]; initialRoots: RootTab[];
totals?: CatalogStatsTotals | null;
}) { }) {
const { state, dispatch, catalogType, canEdit } = useCatalogManager(); const { state, dispatch, catalogType, canEdit } = useCatalogManager();
const catQs = catalogTreeQs(catalogType); const catQs = catalogTreeQs(catalogType);
@@ -300,7 +305,7 @@ function CatalogManagerInner({
</div> </div>
</div> </div>
<StatsBar /> <StatsBar totals={totals} />
</TooltipProvider> </TooltipProvider>
); );
} }
@@ -127,7 +127,7 @@ export function RootTabs({
if (!canEdit) return; if (!canEdit) return;
const ok = await confirm({ const ok = await confirm({
title: "Delete root page", title: "Delete root page",
description: `Delete root page "${tab.caption}"? Children will be reparented.`, description: `Delete root page "${tab.caption}"? Child pages (if any) will be moved to root; items on this page will be deleted.`,
confirmLabel: "Delete", confirmLabel: "Delete",
}); });
if (!ok) return; if (!ok) return;
@@ -557,9 +557,17 @@ export function SortableTree({
const handleDelete = async (id: number) => { const handleDelete = async (id: number) => {
if (!canEdit) return; if (!canEdit) return;
const node = nodes.get(id); const node = nodes.get(id);
const childInfo =
node && node.childCount > 0
? ` Its ${node.childCount} child page(s) will be moved to the parent.`
: "";
const itemInfo =
node && node.itemCount > 0
? ` ${node.itemCount} item(s) on this page will be deleted.`
: "";
const ok = await confirm({ const ok = await confirm({
title: "Delete page", title: "Delete page",
description: `Delete "${node?.caption ?? id}"? Children will be reparented.`, description: `Delete "${node?.caption ?? id}"?${childInfo}${itemInfo}`,
confirmLabel: "Delete", confirmLabel: "Delete",
}); });
if (!ok) return; if (!ok) return;
@@ -700,19 +708,41 @@ export function SortableTree({
const handleBulkDelete = async () => { const handleBulkDelete = async () => {
if (!canEdit) return; if (!canEdit) return;
const ids = [...multiSelectedIds]; const ids = [...multiSelectedIds];
let childTotal = 0;
let itemTotal = 0;
for (const id of ids) {
const node = nodes.get(id);
if (!node) continue;
childTotal += node.childCount;
itemTotal += node.itemCount;
}
const childInfo =
childTotal > 0
? ` About ${childTotal} child page(s) will be moved to parents.`
: "";
const itemInfo =
itemTotal > 0
? ` About ${itemTotal} item(s) on selected pages will be deleted.`
: "";
const ok = await confirm({ const ok = await confirm({
title: "Delete pages", title: "Delete pages",
description: `Delete ${ids.length} page(s)? Children will be reparented.`, description: `Delete ${ids.length} page(s)?${childInfo}${itemInfo}`,
confirmLabel: "Delete", confirmLabel: "Delete",
}); });
if (!ok) return; if (!ok) return;
const del = catalogType === "bc" ? deleteBcTreePage : deleteTreePage; const del = catalogType === "bc" ? deleteBcTreePage : deleteTreePage;
await Promise.allSettled( const results = await Promise.allSettled(
ids.map((id) => del({ pageId: id, mode: "reparent" })), ids.map((id) => del({ pageId: id, mode: "reparent" })),
); );
const failed = results.filter((r) => r.status === "rejected").length;
const okCount = ids.length - failed;
dispatch({ type: "CLEAR_MULTI_SELECT" }); dispatch({ type: "CLEAR_MULTI_SELECT" });
await loadFullTree(); await loadFullTree();
toast.success(`${ids.length} page(s) deleted`); if (failed > 0) {
toast.error(`${failed} delete(s) failed; ${okCount} succeeded`);
} else {
toast.success(`${okCount} page(s) deleted`);
}
onTreeMutation(); onTreeMutation();
}; };
@@ -1,45 +1,50 @@
"use client"; "use client";
import { FolderTree, Keyboard, Package, ToggleRight } from "lucide-react"; import { FolderTree, Keyboard, Package, ToggleRight } from "lucide-react";
import { useMemo } from "react";
import { useCatalogManager } from "./use-catalog-store"; import { useCatalogManager } from "./use-catalog-store";
export function StatsBar() { export interface CatalogStatsTotals {
const { state } = useCatalogManager(); totalPages: number;
enabledPages: number;
totalItems: number;
}
const stats = useMemo(() => { export function StatsBar({ totals }: { totals?: CatalogStatsTotals | null }) {
const nodes = Array.from(state.nodes.values()); const { state } = useCatalogManager();
const enabled = nodes.filter((n) => n.enabled === "1").length; const selected = state.multiSelectedIds.size;
const totalItems = nodes.reduce((sum, n) => sum + n.itemCount, 0); const rootTabs = state.rootPages.length;
return {
rootTabs: state.rootPages.length, const pages = totals?.totalPages ?? state.nodes.size;
totalPages: nodes.length, const enabled = totals?.enabledPages ?? null;
enabled, const items = totals?.totalItems ?? null;
totalItems, const loadedOnly = !totals;
};
}, [state.nodes, state.rootPages]);
return ( return (
<div className="flex items-center justify-between gap-4 px-4 py-1.5 border-t bg-muted/30 text-[11px] text-muted-foreground shrink-0"> <div className="flex items-center justify-between gap-4 px-4 py-1.5 border-t bg-muted/30 text-[11px] text-muted-foreground shrink-0">
<div className="flex items-center gap-4"> <div className="flex items-center gap-4">
<span className="flex items-center gap-1"> <span className="flex items-center gap-1">
<FolderTree className="h-3 w-3" /> <FolderTree className="h-3 w-3" />
{stats.rootTabs} root {rootTabs} root
</span> </span>
<span>{stats.totalPages} pages</span> <span>
{pages} pages
{loadedOnly ? " loaded" : ""}
</span>
{enabled !== null && (
<span className="flex items-center gap-1"> <span className="flex items-center gap-1">
<ToggleRight className="h-3 w-3" /> <ToggleRight className="h-3 w-3" />
{stats.enabled} enabled {enabled} enabled
</span> </span>
)}
{items !== null && (
<span className="flex items-center gap-1"> <span className="flex items-center gap-1">
<Package className="h-3 w-3" /> <Package className="h-3 w-3" />
{stats.totalItems} items {items} items
</span>
{state.multiSelectedIds.size > 0 && (
<span className="text-primary font-medium">
{state.multiSelectedIds.size} selected
</span> </span>
)} )}
{selected > 0 && (
<span className="text-primary font-medium">{selected} selected</span>
)}
</div> </div>
<div className="flex items-center gap-1"> <div className="flex items-center gap-1">
<Keyboard className="h-3 w-3" /> <Keyboard className="h-3 w-3" />
+2 -2
View File
@@ -728,7 +728,7 @@ function TreeItem({
e.stopPropagation(); e.stopPropagation();
router.push( router.push(
catalogType === "bc" catalogType === "bc"
? `/admin/catalog/builder-club/${node.id}` ? `/admin/catalog?catalog=bc&newPageParent=${node.id}`
: `/admin/catalog?newPageParent=${node.id}`, : `/admin/catalog?newPageParent=${node.id}`,
); );
}} }}
@@ -872,7 +872,7 @@ function TreeItem({
onClick={() => onClick={() =>
router.push( router.push(
catalogType === "bc" catalogType === "bc"
? `/admin/catalog/builder-club/${node.id}` ? `/admin/catalog?catalog=bc&newPageParent=${node.id}`
: `/admin/catalog?newPageParent=${node.id}`, : `/admin/catalog?newPageParent=${node.id}`,
) )
} }
+36
View File
@@ -1246,6 +1246,9 @@
"subtitle": "Beheer pakketten en bestellingen", "subtitle": "Beheer pakketten en bestellingen",
"packages": "Pakketten", "packages": "Pakketten",
"orders": "Bestellingen", "orders": "Bestellingen",
"recentOrders": "Recente bestellingen",
"paidOrders": "Betaalde bestellingen",
"ordersHint": "Laatste PayPal-transacties",
"newPackage": "+ Nieuw pakket", "newPackage": "+ Nieuw pakket",
"edit": "Bewerken", "edit": "Bewerken",
"delete": "Verwijderen", "delete": "Verwijderen",
@@ -1256,6 +1259,11 @@
"colId": "ID", "colId": "ID",
"colName": "Naam", "colName": "Naam",
"colPrice": "Prijs", "colPrice": "Prijs",
"colCredits": "Credits",
"colDuckets": "Duckets",
"colDiamonds": "Diamanten",
"colRank": "Rang",
"colPosition": "Positie",
"colCurrency": "Valuta", "colCurrency": "Valuta",
"colType": "Type", "colType": "Type",
"colSold": "Verkocht", "colSold": "Verkocht",
@@ -1264,6 +1272,9 @@
"colOrderId": "Bestelling ID", "colOrderId": "Bestelling ID",
"colCustomer": "Klant", "colCustomer": "Klant",
"colPackage": "Pakket", "colPackage": "Pakket",
"colTransaction": "Transactie",
"colUser": "Gebruiker",
"colDescription": "Beschrijving",
"colAmount": "Bedrag", "colAmount": "Bedrag",
"colStatus": "Status", "colStatus": "Status",
"colDate": "Datum", "colDate": "Datum",
@@ -1299,12 +1310,20 @@
"transactions": { "transactions": {
"title": "Transacties", "title": "Transacties",
"subtitle": "PayPal betalingslogboek", "subtitle": "PayPal betalingslogboek",
"totalTransactions": "Totaal transacties",
"pagePaid": "Betaald (deze pagina)",
"pageFailed": "Mislukt (deze pagina)",
"searchPlaceholder": "Zoek op gebruiker, transactie-ID of pakket…",
"presetPaid": "Betaald",
"presetFailed": "Mislukt",
"noTransactions": "Nog geen transacties", "noTransactions": "Nog geen transacties",
"colId": "ID", "colId": "ID",
"colUser": "Gebruiker", "colUser": "Gebruiker",
"colPayer": "Betaler",
"colAmount": "Bedrag", "colAmount": "Bedrag",
"colCurrency": "Valuta", "colCurrency": "Valuta",
"colPackage": "Pakket", "colPackage": "Pakket",
"colTransaction": "Transactie-ID",
"colStatus": "Status", "colStatus": "Status",
"colDate": "Datum", "colDate": "Datum",
"colActions": "Acties", "colActions": "Acties",
@@ -1324,16 +1343,30 @@
"vouchers": { "vouchers": {
"title": "Winkel Vouchers", "title": "Winkel Vouchers",
"subtitle": "Beheer inwisselbare vouchercodes", "subtitle": "Beheer inwisselbare vouchercodes",
"vouchers": "Vouchers",
"active": "Actief",
"usedUp": "Opgebruikt",
"expired": "Verlopen",
"newVoucher": "+ Nieuwe voucher", "newVoucher": "+ Nieuwe voucher",
"edit": "Bewerken", "edit": "Bewerken",
"delete": "Verwijderen", "delete": "Verwijderen",
"noVouchers": "Nog geen vouchers", "noVouchers": "Nog geen vouchers",
"confirmDeleteTitle": "Voucher verwijderen",
"confirmDelete": "Voucher \"{code}\" verwijderen?", "confirmDelete": "Voucher \"{code}\" verwijderen?",
"created": "Voucher aangemaakt",
"deleted": "Voucher verwijderd",
"createError": "Kon voucher niet aanmaken",
"deleteError": "Kon voucher niet verwijderen",
"statusActive": "Actief",
"statusUsedUp": "Opgebruikt",
"statusExpired": "Verlopen",
"colId": "ID", "colId": "ID",
"colCode": "Code", "colCode": "Code",
"colValue": "Waarde", "colValue": "Waarde",
"colAmount": "Bedrag",
"colType": "Type", "colType": "Type",
"colUses": "Gebruik / Max", "colUses": "Gebruik / Max",
"colStatus": "Status",
"colExpires": "Verloopt", "colExpires": "Verloopt",
"colCreated": "Aangemaakt", "colCreated": "Aangemaakt",
"colActions": "Acties", "colActions": "Acties",
@@ -1341,6 +1374,8 @@
"code": "Code", "code": "Code",
"codePlaceholder": "Bijv. ZOMER2025", "codePlaceholder": "Bijv. ZOMER2025",
"value": "Waarde", "value": "Waarde",
"amount": "Aantal credits",
"amountPlaceholder": "bijv. 100",
"type": "Type", "type": "Type",
"typeCredits": "Credits", "typeCredits": "Credits",
"typeDuckets": "Duckets", "typeDuckets": "Duckets",
@@ -1355,6 +1390,7 @@
"maxUsesPlaceholder": "0 = onbeperkt", "maxUsesPlaceholder": "0 = onbeperkt",
"expiresAt": "Verloopt op", "expiresAt": "Verloopt op",
"enabled": "Ingeschakeld", "enabled": "Ingeschakeld",
"create": "Voucher aanmaken",
"save": "Voucher opslaan", "save": "Voucher opslaan",
"saving": "Opslaan…", "saving": "Opslaan…",
"cancel": "Annuleren" "cancel": "Annuleren"