import React, { useState, useEffect } from "react"; import styles from "./RoomModal.module.css"; import { Ring } from "konva/lib/shapes/Ring"; export default function RoomModal(props) { const [modal, setModal] = useState(false); const [room, setRoom] = useState(null); const [formData, setFormData] = useState({ name: "", type: "", description: "", }); const [roomTypes, setRoomTypes] = useState([]); const toggleModal = () => { if(modal) { room.info = formData; props.map.updateRoomNames(); } setModal(!modal); }; const saveDetails = () => { if (room) { room.info = formData; toggleModal(); console.log(room.info); } }; // impl da sa gledat dali ti e zacuvana formava const handleInputChange = (e) => { console.log(room.info) const { name, value, type, checked } = e.target; setFormData((prevData) => ({ ...prevData, [name]: type === "checkbox" ? checked : value, })); room.info = formData; }; useEffect(() => { const openModalHandler = (event) => { const roomObj = event.detail.room; console.log(roomObj, "ROOMOBJ OTV") setRoom(roomObj); setFormData({ name: roomObj.info.name, type: roomObj.info.type, description: roomObj.info.description, }); setRoomTypes(event.detail.map.getRoomTypes()); toggleModal(true); }; window.addEventListener("openRoomModalEvent", openModalHandler); return () => { window.removeEventListener("openRoomModalEvent", openModalHandler); }; }, []); if (modal) { document.body.classList.add(styles.activeModal); } else { document.body.classList.remove(styles.activeModal); } return ( <> {/* */} {modal && (

Enter Room Details