feat: add automatic catalog organization for all imported furniture
Add a fully automatic "Organize all" action in the Studio that organizes the entire database into catalog pages: - Create a dedicated sub-page per furniture line (e.g. weebz, habbox) from FurnitureData.json, falling back to the auto-detected category. - Add missing purchasable items to the catalog on their line/category page. - Re-home and re-price existing catalog entries onto their correct page. - Pages are created automatically when missing; no manual selection needed. Includes the organizeCatalogAll service, a POST /api/admin/import/furni/organize endpoint, and the Studio button.
This commit is contained in:
1 parent
0b0cf4f37f
commit
bb7ec3db02
3 files changed
+321
No files matched your search
@@ -514,6 +514,37 @@ export function StudioClient({
|
||||
}
|
||||
};
|
||||
|
||||
const [organizing, setOrganizing] = useState(false);
|
||||
|
||||
async function organizeAll() {
|
||||
if (organizing) return;
|
||||
setOrganizing(true);
|
||||
try {
|
||||
const res = await adminFetch("/api/admin/import/furni/organize", {
|
||||
method: "POST",
|
||||
});
|
||||
const data = await res.json();
|
||||
if (res.ok) {
|
||||
const parts = [
|
||||
`Catalogus georganiseerd`,
|
||||
data.pagesCreated > 0
|
||||
? `${data.pagesCreated} pagina's aangemaakt`
|
||||
: null,
|
||||
data.catalogAdded > 0 ? `${data.catalogAdded} nieuw` : null,
|
||||
data.catalogRehomed > 0 ? `${data.catalogRehomed} bijgewerkt` : null,
|
||||
].filter(Boolean);
|
||||
toast.success(parts.join(" · "));
|
||||
fetchStats();
|
||||
} else {
|
||||
toast.error(data.error || "Organiseren mislukt");
|
||||
}
|
||||
} catch {
|
||||
toast.error("Netwerkfout");
|
||||
} finally {
|
||||
setOrganizing(false);
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteItem() {
|
||||
if (!deleting) return;
|
||||
try {
|
||||
@@ -844,6 +875,22 @@ export function StudioClient({
|
||||
|
||||
<div className="flex-1" />
|
||||
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
className="gap-1.5"
|
||||
disabled={organizing || !!batchProgress}
|
||||
onClick={organizeAll}
|
||||
title="Alle meubels automatisch in catalogus-pagina's ordenen (pagina's worden aangemaakt indien nodig)"
|
||||
>
|
||||
{organizing ? (
|
||||
<Loader2 size={14} className="animate-spin" />
|
||||
) : (
|
||||
<WandSparkles size={14} />
|
||||
)}
|
||||
Organiseer alles
|
||||
</Button>
|
||||
|
||||
{selectedNonImported > 0 && (
|
||||
<Button
|
||||
size="sm"
|
||||
|
||||
Reference in new issue
Block a user