fix: resolve layout type errors in organize-imports-dialog
CI / check (push) Successful in 2m29s
CI / deploy (push) Successful in 18s
CI / publish-container (push) Successful in 1m32s

This commit is contained in:
openhands committed 2026-09-11 23:25:53 +02:00
1 parent caeb4eb0b3
commit 683fee3bd9
2 files changed
+106 -49

No files matched your search

+51 -1
View File
@@ -1,4 +1,8 @@
import { sql } from "drizzle-orm";
import {
groupSuggestedCategories,
type SugFurniEntry,
} from "@/features/catalog/domain/organize";
import {
getImportedCategoryPageIds,
getImportedRootCaption,
@@ -193,9 +197,55 @@ export const GET = withAdmin(
);
});
// 5) Group on the server so the client only ever sees compact, ready-made
// categories instead of a giant raw item array.
type SugFurniEntryExtra = SugFurniEntry & {
alreadyPlaced?: boolean;
catalogItemId?: number;
spriteId?: number;
sourcePageCaption?: string;
itemId?: number;
};
// Map to the extended shape so groupSuggestedCategories accepts it,
// then we can use the extra fields in the returned groups.
const sugItems = items.map((it) => ({
id: it.itemId,
itemName: it.itemName,
publicName: it.publicName,
type: it.type,
spriteId: it.spriteId,
interactionType: it.interactionType,
alreadyPlaced: it.alreadyPlaced,
catalogItemId: it.catalogItemId,
})) as SugFurniEntryExtra[];
const groups = groupSuggestedCategories(sugItems).map((g) => {
const moved = g.items.filter((i) => i.alreadyPlaced).length;
return {
name: g.name,
icon: g.icon,
layout: g.layout?.layout ?? null,
total: g.items.length,
moved,
added: g.items.length - moved,
thumbs: g.items.slice(0, 12).map((i) => ({
itemName: i.itemName,
publicName: i.publicName,
spriteId: i.spriteId,
alreadyPlaced: i.alreadyPlaced,
sourcePageCaption: i.sourcePageCaption,
})),
items: g.items.map((i) => ({
itemId: i.itemId,
catalogItemId: i.catalogItemId,
alreadyPlaced: i.alreadyPlaced,
})),
};
});
const importRootPageId = pageIds[0] ?? null;
return apiOk({
items,
groups,
groupCount: groups.length,
total: items.length,
importRootPageId,
importRootCaption: await getImportedRootCaption(),