deletepanel added

This commit is contained in:
2025-04-01 11:33:10 +05:30
parent 6f483baf8d
commit 695b066c81
21 changed files with 97 additions and 46 deletions

View File

@@ -36,7 +36,7 @@ type DroppedObjectsState = {
bottom: number | "auto";
}
) => void;
deleteObject: (zoneName: string, index: number) => void; // Add this line
deleteObject: (zoneName: string, id: string, index: number) => void; // Add this line
duplicateObject: (zoneName: string, index: number) => void; // Add this line
};
@@ -77,15 +77,16 @@ export const useDroppedObjectsStore = create<DroppedObjectsState>((set) => ({
};
}),
deleteObject: (zoneName: string, index: number) =>
deleteObject: (zoneName: string, id: string, index: number) =>
set((state) => {
const zone = state.zones[zoneName];
console.log("zone: ", zone);
if (!zone) return state;
return {
zones: {
[zoneName]: {
...zone,
objects: zone.objects.filter((_, i) => i !== index), // Remove object at the given index
objects: zone.objects.filter((obj) => obj.id !== id), // Remove object at the given index
},
},
};