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:
@@ -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)));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user