añadido soporte para sacar la y y volverla a añadir
This commit is contained in:
@@ -1,4 +1,8 @@
|
|||||||
|
import { useState } from "react";
|
||||||
export default function EditarModal({ tipo, coord, show, close, setCoords }) {
|
export default function EditarModal({ tipo, coord, show, close, setCoords }) {
|
||||||
|
if (coord == null) return null;
|
||||||
|
const [hasY, setHasY] = useState(coord.y !== null);
|
||||||
|
|
||||||
const handleSubmit = (e) => {
|
const handleSubmit = (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
@@ -50,6 +54,18 @@ export default function EditarModal({ tipo, coord, show, close, setCoords }) {
|
|||||||
</div>
|
</div>
|
||||||
<div className="modal-body">
|
<div className="modal-body">
|
||||||
<form onSubmit={handleSubmit}>
|
<form onSubmit={handleSubmit}>
|
||||||
|
<div className="mb-3">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
className="form-check-input me-2"
|
||||||
|
checked={hasY}
|
||||||
|
onChange={(e) => {
|
||||||
|
coord.y = e.target.checked ? "0" : null;
|
||||||
|
setHasY(e.target.checked);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<label className="form-label">Lleva coordenada Y?</label>
|
||||||
|
</div>
|
||||||
<div className="mb-3">
|
<div className="mb-3">
|
||||||
<label className="form-label">Coordenada X</label>
|
<label className="form-label">Coordenada X</label>
|
||||||
<input
|
<input
|
||||||
@@ -59,7 +75,7 @@ export default function EditarModal({ tipo, coord, show, close, setCoords }) {
|
|||||||
defaultValue={coord.x}
|
defaultValue={coord.x}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{coord.y != null && (
|
{hasY && (
|
||||||
<div className="mb-3">
|
<div className="mb-3">
|
||||||
<label className="form-label">Coordenada Y</label>
|
<label className="form-label">Coordenada Y</label>
|
||||||
<input
|
<input
|
||||||
|
|||||||
Reference in New Issue
Block a user