completed floor
This commit is contained in:
@@ -5,7 +5,7 @@ interface FloorStore {
|
||||
floors: Floor[];
|
||||
setFloors: (floors: Floor[]) => void;
|
||||
addFloor: (floor: Floor) => void;
|
||||
updateFloor: (uuid: string, updated: Partial<Floor>) => void;
|
||||
updateFloor: (uuid: string, updated: Partial<Floor>) => Floor | undefined;
|
||||
removeFloor: (uuid: string) => void;
|
||||
removePoint: (pointUuid: string) => { removedFloors: Floor[], updatedFloors: Floor[] };
|
||||
removeFloorByPoints: (Points: [Point, Point]) => { removedFloors: Floor[], updatedFloors: Floor[] };
|
||||
@@ -45,12 +45,17 @@ export const createFloorStore = () => {
|
||||
state.floors.push(floor);
|
||||
}),
|
||||
|
||||
updateFloor: (uuid, updated) => set(state => {
|
||||
const floor = state.floors.find(f => f.floorUuid === uuid);
|
||||
if (floor) {
|
||||
Object.assign(floor, updated);
|
||||
}
|
||||
}),
|
||||
updateFloor: (uuid, updated) => {
|
||||
let updatedFloor: Floor | undefined;
|
||||
set(state => {
|
||||
const floor = state.floors.find(f => f.floorUuid === uuid);
|
||||
if (floor) {
|
||||
Object.assign(floor, updated);
|
||||
updatedFloor = JSON.parse(JSON.stringify(floor));
|
||||
}
|
||||
});
|
||||
return updatedFloor;
|
||||
},
|
||||
|
||||
removeFloor: (uuid) => set(state => {
|
||||
state.floors = state.floors.filter(f => f.floorUuid !== uuid);
|
||||
|
||||
Reference in New Issue
Block a user