source: imaps-frontend/src/components/Modals/InfoPinModal/InfoPinModal.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: 2.5 KB
RevLine 
[0c6b92a]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
40 console.log(shape.info.selectedPins, "Loaded pins on modal open");
41 },"openPinModalEvent")
42
43
44 return (
45 <Modal isOpen={isOpen} toggleModal={toggleModal} title={"Enter Pin Details"}>
46 <ModalNameField shapeInfo={shapeInfo} updateModalData={updateModalData}/>
47 <ModalSelectConnections2
48 shapeInfo={shapeInfo}
49 availableShapes={ShapeQuery.findAllByTypeAndFloor(map?.floorNum,"Stairs","InfoPin","Entrance")}
50 updateModalData={updateModalData}
51 addConnection={addConnection}
52 />
53 <ModalDisplayConnections connections={connections} removePinFromList={removeConnection}/>
54 <ModalDescriptionField shapeInfo={shapeInfo} updateModalData={updateModalData}/>
55 <ModalSaveButton saveDetails={saveDetails}/>
56 </Modal>
57
58 );
59}
60
61InfoPinModal.propTypes = {
62 map: PropTypes.instanceOf(MapBuilder),
63};
Note: See TracBrowser for help on using the repository browser.