diff --git a/src/app/(frontend)/logistics/structures/actions.ts b/src/app/(frontend)/logistics/structures/actions.ts index 53dbd82..5e35a94 100644 --- a/src/app/(frontend)/logistics/structures/actions.ts +++ b/src/app/(frontend)/logistics/structures/actions.ts @@ -737,7 +737,7 @@ export async function splitGridStack( let overlaps = false; for (const other of existing) { - if (other.id === entryId || other.id == null) continue; + if (other.id == null) continue; const otherRes = other.resource as Resource; if (!otherRes || typeof otherRes === "number") continue; const otherRotated = other.rotated ?? false; diff --git a/src/components/frontend/storage/GridToolbar.tsx b/src/components/frontend/storage/GridToolbar.tsx index 3a875c2..4e9f576 100644 --- a/src/components/frontend/storage/GridToolbar.tsx +++ b/src/components/frontend/storage/GridToolbar.tsx @@ -9,7 +9,7 @@ import { LayoutGridIcon, ListIcon, } from "lucide-react"; -import { GridItem, getItemFootprint, getGridOccupancy } from "@/lib/logistics"; +import { GridItem, getItemFootprint, getGridOccupancy, findEmptySpot } from "@/lib/logistics"; import { Resource } from "@/payload-types"; import { cn, pluralize } from "@/lib/utils"; @@ -41,6 +41,9 @@ export function GridToolbar({ const occupancy = getGridOccupancy(storedResources, gridWidth, gridHeight); const res = selectedItem ? (selectedItem.resource as Resource) : null; const fp = res ? getItemFootprint(res, selectedItem!.rotated) : null; + const canSplit = selectedItem && res && fp + ? findEmptySpot(storedResources, fp.width, fp.height, gridWidth, gridHeight) !== null + : false; return (