1 | import React, {useState} from "react";
|
---|
2 | import useModalState from "../Hooks/useModalState.jsx";
|
---|
3 | import {useModalEvent} from "../Hooks/useModalEvent.jsx";
|
---|
4 | import useConnections from "../Hooks/useConnections.jsx";
|
---|
5 | import ModalNameField from "../Components/ModalNameField.jsx";
|
---|
6 |
|
---|
7 | import ModalDisplayConnections from "../Components/ModalDisplayConnections.jsx";
|
---|
8 | import ModalDescriptionField from "../Components/ModalDescriptionField.jsx";
|
---|
9 | import ModalSaveButton from "../Components/ModalSaveButton.jsx";
|
---|
10 | import Modal from "../Components/Modal.jsx";
|
---|
11 | import ModalSelectConnections2 from "../Components/ModalSelectConnections2.jsx";
|
---|
12 | import ShapeRegistry from "../../../scripts/util/ShapeRegistry.js";
|
---|
13 | import ShapeQuery from "../../../scripts/util/ShapeQuery.js";
|
---|
14 |
|
---|
15 | export default function StairsModal({map}){
|
---|
16 | const {
|
---|
17 | modalState: {isOpen,setIsOpen,setShape,shapeInfo,setShapeInfo},
|
---|
18 | handlers: {toggleModal,updateModalData,saveDetails}
|
---|
19 | } = useModalState(map);
|
---|
20 |
|
---|
21 | const {
|
---|
22 | connectionState: {connections,setConnections},
|
---|
23 | handlers: {addConnection,removeConnection}
|
---|
24 | } = useConnections(map,shapeInfo,setShapeInfo)
|
---|
25 |
|
---|
26 |
|
---|
27 | useModalEvent((event) => {
|
---|
28 | const roomObj = event.detail.room;
|
---|
29 | setShape(roomObj);
|
---|
30 | setShapeInfo(roomObj.info);
|
---|
31 | console.log("stairs connections shape info: " + roomObj.info.selectedPins)
|
---|
32 | setConnections(roomObj.info.selectedPins || []);
|
---|
33 | setIsOpen(true);
|
---|
34 | console.log(roomObj.info.selectedPins, "Loaded pins on modal open");
|
---|
35 | },"openStairsModalEvent")
|
---|
36 |
|
---|
37 |
|
---|
38 |
|
---|
39 | return (
|
---|
40 |
|
---|
41 | <Modal isOpen={isOpen} toggleModal={toggleModal} title={"Enter Stair Details"}>
|
---|
42 | <ModalNameField shapeInfo={shapeInfo} updateModalData={updateModalData} phtext={"Enter name of stairs"}/>
|
---|
43 | <ModalSelectConnections2
|
---|
44 | shapeInfo={shapeInfo}
|
---|
45 | updateModalData={updateModalData}
|
---|
46 | addConnection={addConnection}
|
---|
47 | availableShapes={ShapeQuery.findAllByType("Stairs")}
|
---|
48 | />
|
---|
49 | <ModalDisplayConnections connections={connections} removePinFromList={removeConnection}/>
|
---|
50 | <ModalDescriptionField shapeInfo={shapeInfo} updateModalData={updateModalData}/>
|
---|
51 | <ModalSaveButton saveDetails={saveDetails}/>
|
---|
52 | </Modal>
|
---|
53 | )
|
---|
54 | } |
---|