source: imaps-frontend/src/components/Modals/StairsModal/StairsModal.jsx

main
Last change on this file was 0c6b92a, checked in by stefan toskovski <stefantoska84@…>, 5 weeks ago

Pred finalna verzija

  • Property mode set to 100644
File size: 2.3 KB
Line 
1import React, {useState} from "react";
2import useModalState from "../Hooks/useModalState.jsx";
3import {useModalEvent} from "../Hooks/useModalEvent.jsx";
4import useConnections from "../Hooks/useConnections.jsx";
5import ModalNameField from "../Components/ModalNameField.jsx";
6
7import ModalDisplayConnections from "../Components/ModalDisplayConnections.jsx";
8import ModalDescriptionField from "../Components/ModalDescriptionField.jsx";
9import ModalSaveButton from "../Components/ModalSaveButton.jsx";
10import Modal from "../Components/Modal.jsx";
11import ModalSelectConnections2 from "../Components/ModalSelectConnections2.jsx";
12import ShapeRegistry from "../../../scripts/util/ShapeRegistry.js";
13import ShapeQuery from "../../../scripts/util/ShapeQuery.js";
14
15export 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}
Note: See TracBrowser for help on using the repository browser.