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