source: imaps-frontend/src/components/Modals/EntranceModal/EntranceModal.jsx@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 3.0 KB
RevLine 
[0c6b92a]1import React, {useState, useEffect} from "react";
2import styles from "./EntranceModal.module.css";
3import PropTypes from "prop-types";
4import {MapBuilder} from "../../../scripts/main/MapBuilder.js";
5
6import Modal from "../Components/Modal.jsx";
7import ModalNameField from "../Components/ModalNameField.jsx";
8import ModalSelectRoom from "../Components/ModalSelectRoom.jsx";
9import ModalSelectConnections from "../Components/ModalSelectConnections.jsx";
10import ModalDisplayConnections from "../Components/ModalDisplayConnections.jsx";
11import ModalDescriptionField from "../Components/ModalDescriptionField.jsx";
12import ModalSaveButton from "../Components/ModalSaveButton.jsx";
13import ModalMainEntranceCheckbox from "../Components/ModalMainEntranceCheckbox.jsx";
14import {useModalEvent} from "../Hooks/useModalEvent.jsx";
15import useModalState from "../Hooks/useModalState.jsx";
16import useConnections from "../Hooks/useConnections.jsx";
17import ModalSelectConnections2 from "../Components/ModalSelectConnections2.jsx";
18import ShapeQuery from "../../../scripts/util/ShapeQuery.js";
19
20export default function EntranceModal({map}) {
21
22 const {
23 modalState: {isOpen,setIsOpen,shape,setShape,shapeInfo,setShapeInfo},
24 handlers: {toggleModal,updateModalData,saveDetails}
25 } = useModalState(map);
26
27 const {
28 connectionState: {connections,setConnections},
29 handlers: {addConnection,removeConnection}
30 } = useConnections(map,shapeInfo,setShapeInfo)
31
32
33 useModalEvent((event) => {
34 const shape = event.detail.room;
35 setShape(shape);
36 setShapeInfo({
37 ...shape.info,
38 selectedPin: ""
39
40 })
41 const connections = shape.info.selectedPins || [];
42 setConnections(connections);
43 setIsOpen(true);
[79a0317]44 event.detail.map.detachKeyPressEventListeners();
[0c6b92a]45 console.log(connections, "Loaded pins on modal open");
46 },"openEntranceModalEvent")
47
48
49
50 return (
51 <Modal isOpen={isOpen} toggleModal={toggleModal} title={"Enter Entrance Details"}>
52 <ModalNameField shapeInfo={shapeInfo} updateModalData={updateModalData}/>
53 <ModalSelectRoom shapeInfo={shapeInfo} availableRooms={ShapeQuery.findAllByTypeAndFloor(shape?.floorNum,"Room")} updateModalData={updateModalData}/>
54 <ModalSelectConnections2
[79a0317]55 availableShapes={ShapeQuery.findAllByTypeAndFloor(map?.floorNum,"Entrance","InfoPin")} // najubo ke e entrance samo so room da mozit
[0c6b92a]56 addConnection={addConnection}
57 updateModalData={updateModalData}
58 shapeInfo={shapeInfo}
59 />
60 <ModalDisplayConnections connections={connections} removePinFromList={removeConnection}/>
61 <ModalDescriptionField shapeInfo={shapeInfo} updateModalData={updateModalData}/>
62 <ModalMainEntranceCheckbox shapeInfo={shapeInfo} updateModalData={updateModalData}></ModalMainEntranceCheckbox>
63 <ModalSaveButton saveDetails={saveDetails}/>
64 </Modal>
65 );
66}
67
68EntranceModal.propTypes = {
69 map: PropTypes.instanceOf(MapBuilder),
70};
Note: See TracBrowser for help on using the repository browser.