source: imaps-frontend/src/components/Modals/CreateMapModal/CreateMapModal.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.1 KB
RevLine 
[0c6b92a]1import React, { useContext, useState } from "react";
2import PropTypes from "prop-types";
3import styles from "./CreateMapModal.module.css";
4
5const CreateMapModal = ({ isOpen, onClose,addMap}) => {
6 const [mapName, setMapName] = useState("");
7 const [mapType, setMapType] = useState("");
8
9 const handleSubmit = (e) => {
10 const mapDetails = {
11 name: mapName,
12 type: mapType,
13 };
14
15 addMap(mapDetails);
16
17 onClose();
18 };
19
20 if (!isOpen) return null;
21
22 return (
23 <div className={styles.modalOverlay} onClick={onClose}>
24 <div className={styles.modalContent} onClick={(e) => e.stopPropagation()}>
25 <h2 className={styles.title}>Enter Map Details</h2>
26 <form onSubmit={handleSubmit} className={styles.formData}>
27 <label>
28 Map Name:
29 <input
30 type="text"
31 value={mapName}
32 onChange={(e) => setMapName(e.target.value)}
33 required
34 />
35 </label>
36 <label>
37 Map Type:
38 <input
39 type="text"
40 value={mapType}
41 onChange={(e) => setMapType(e.target.value)}
42 required
43 />
44 </label>
45 <div className={styles.modalButtons}>
46 <button type="submit" className={styles.modalSubmitButton}>
47 Submit
48 </button>
49 <button type="button" className={styles.modalCancelButton} onClick={onClose}>
50 Cancel
51 </button>
52 </div>
53 </form>
54 </div>
55 </div>
56 );
57};
58
59CreateMapModal.propTypes = {
60 isOpen: PropTypes.bool.isRequired,
61 onClose: PropTypes.func.isRequired,
62};
63
64export default CreateMapModal;
Note: See TracBrowser for help on using the repository browser.