source: imaps-frontend/src/components/Modals/InfoPinModal/InfoPinModal.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: 2.5 KB
Line 
1import React, {useState, useEffect} from "react";
2import styles from "./InfoPinModal.module.css";
3import PropTypes, {instanceOf} from "prop-types";
4import {MapBuilder} from "../../../scripts/main/MapBuilder.js";
5import ModalNameField from "../Components/ModalNameField.jsx";
6import ModalSelectConnections from "../Components/ModalSelectConnections.jsx";
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 useModalState from "../Hooks/useModalState.jsx";
12import useConnections from "../Hooks/useConnections.jsx";
13import {useModalEvent} from "../Hooks/useModalEvent.jsx";
14import ModalSelectConnections2 from "../Components/ModalSelectConnections2.jsx";
15import ShapeQuery from "../../../scripts/util/ShapeQuery.js";
16
17export default function InfoPinModal({map}) {
18
19 const {
20 modalState: {isOpen,shapeInfo,shape,setIsOpen,setShape,setShapeInfo},
21 handlers: {toggleModal,updateModalData,saveDetails}
22 } = useModalState(map);
23
24 const {
25 connectionState: {connections,setConnections},
26 handlers: {addConnection,removeConnection}
27 } = useConnections(map,shapeInfo,setShapeInfo)
28
29
30 useModalEvent((event) => {
31 const shape = event.detail.room;
32 setShape(shape);
33 setShapeInfo({
34 ...shape.info,
35 selectedPin: ""
36 })
37 setConnections(shape.info.selectedPins || []);
38 setIsOpen(true);
39 event.detail.map.detachKeyPressEventListeners();
40
41 console.log(shape.info.selectedPins, "Loaded pins on modal open");
42 },"openPinModalEvent")
43
44
45 return (
46 <Modal isOpen={isOpen} toggleModal={toggleModal} title={"Enter Pin Details"}>
47 <ModalNameField shapeInfo={shapeInfo} updateModalData={updateModalData}/>
48 <ModalSelectConnections2
49 shapeInfo={shapeInfo}
50 availableShapes={ShapeQuery.findAllByTypeAndFloor(map?.floorNum,"Stairs","InfoPin","Entrance")}
51 updateModalData={updateModalData}
52 addConnection={addConnection}
53 />
54 <ModalDisplayConnections connections={connections} removePinFromList={removeConnection}/>
55 <ModalDescriptionField shapeInfo={shapeInfo} updateModalData={updateModalData}/>
56 <ModalSaveButton saveDetails={saveDetails}/>
57 </Modal>
58
59 );
60}
61
62InfoPinModal.propTypes = {
63 map: PropTypes.instanceOf(MapBuilder),
64};
Note: See TracBrowser for help on using the repository browser.