source: imaps-frontend/src/components/Modals/EntranceModal/EntranceModal.jsx@ 0c6b92a

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

Pred 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);
44 console.log(connections, "Loaded pins on modal open");
45 },"openEntranceModalEvent")
46
47
48
49 return (
50 <Modal isOpen={isOpen} toggleModal={toggleModal} title={"Enter Entrance Details"}>
51 <ModalNameField shapeInfo={shapeInfo} updateModalData={updateModalData}/>
52 <ModalSelectRoom shapeInfo={shapeInfo} availableRooms={ShapeQuery.findAllByTypeAndFloor(shape?.floorNum,"Room")} updateModalData={updateModalData}/>
53 <ModalSelectConnections2
54 availableShapes={ShapeQuery.findAllByType("InfoPin","Entrance")} // najubo ke e entrance samo so room da mozit
55 addConnection={addConnection}
56 updateModalData={updateModalData}
57 shapeInfo={shapeInfo}
58 />
59 <ModalDisplayConnections connections={connections} removePinFromList={removeConnection}/>
60 <ModalDescriptionField shapeInfo={shapeInfo} updateModalData={updateModalData}/>
61 <ModalMainEntranceCheckbox shapeInfo={shapeInfo} updateModalData={updateModalData}></ModalMainEntranceCheckbox>
62 <ModalSaveButton saveDetails={saveDetails}/>
63 </Modal>
64 );
65}
66
67EntranceModal.propTypes = {
68 map: PropTypes.instanceOf(MapBuilder),
69};
Note: See TracBrowser for help on using the repository browser.