Refactor floor management APIs: implement getFloorsApi, deleteFloorApi, and upsertFloorApi for enhanced floor data handling. Update FloorCreator for improved point snapping and floor creation logic. Modify ReferencePoint to include UUID and user data. Adjust usePointSnapping to handle temporary points more effectively.

This commit is contained in:
2025-06-26 18:23:01 +05:30
parent 1e88006780
commit 5003dc3504
9 changed files with 157 additions and 33 deletions

View File

@@ -13,7 +13,7 @@ interface FloorStore {
setPosition: (
pointUuid: string,
position: [number, number, number]
) => Floor | undefined;
) => Floor[] | [];
setIsBeveled: (uuid: string, isBeveled: boolean) => void;
setBevelStrength: (uuid: string, strength: number) => void;
setDepth: (uuid: string, depth: number) => void;
@@ -83,6 +83,7 @@ export const createFloorStore = () => {
return removedFloors;
},
removeFloorByPoints: ([pointA, pointB]) => {
const removedFloors: Floor[] = [];
@@ -134,14 +135,13 @@ export const createFloorStore = () => {
}),
setPosition: (pointUuid, position) => {
let updatedFloor: Floor | undefined;
let updatedFloor: Floor[] = [];
set((state) => {
for (const floor of state.floors) {
const point = floor.points.find((p) => p.pointUuid === pointUuid);
if (point) {
point.position = position;
updatedFloor = JSON.parse(JSON.stringify(floor));
break;
updatedFloor.push(JSON.parse(JSON.stringify(floor)));
}
}
});