Compare commits

...

2 Commits

Author SHA1 Message Date
2484cf8191 correjido comportmiento del formulario de editar 2025-03-18 00:46:37 -03:00
3e0452c4d7 cleanup: eliminado evento sin uso 2025-03-18 00:46:19 -03:00
2 changed files with 12 additions and 11 deletions

View File

@@ -1,7 +1,9 @@
import { useState } from "react";
import React from "react";
export default function EditarModal({ tipo, coord, show, close, setCoords }) {
if (coord == null) return null;
const [hasY, setHasY] = useState(coord.y !== null);
const [showY, setShowY] = React.useState(coord.y !== null);
const handleSubmit = (e) => {
e.preventDefault();
@@ -11,6 +13,7 @@ export default function EditarModal({ tipo, coord, show, close, setCoords }) {
const y = formData.get("y");
const z = formData.get("z");
const descripcion = formData.get("descripcion");
const hasY = formData.get("hasY") === "true";
let storedTipo = localStorage.getItem(tipo);
if (storedTipo) {
@@ -20,7 +23,7 @@ export default function EditarModal({ tipo, coord, show, close, setCoords }) {
arr[index] = {
...coord,
x: Number(x),
y: y ? Number(y) : null,
y: hasY ? Number(y) : null,
z: Number(z),
descripcion: descripcion,
};
@@ -57,12 +60,11 @@ export default function EditarModal({ tipo, coord, show, close, setCoords }) {
<div className="mb-3">
<input
type="checkbox"
name="hasY"
value="true"
className="form-check-input me-2"
checked={hasY}
onChange={(e) => {
coord.y = e.target.checked ? "0" : null;
setHasY(e.target.checked);
}}
defaultChecked={coord.y !== null}
onChange={(e) => setShowY(e.target.checked)}
/>
<label className="form-label">Lleva coordenada Y?</label>
</div>
@@ -75,7 +77,7 @@ export default function EditarModal({ tipo, coord, show, close, setCoords }) {
defaultValue={coord.x}
/>
</div>
{hasY && (
{showY && (
<div className="mb-3">
<label className="form-label">Coordenada Y</label>
<input

View File

@@ -38,14 +38,13 @@ export default function Keeper({ tipo }) {
useEffect(() => {
const storedCoords = JSON.parse(localStorage.getItem(tipo) || "[]");
console.log(storedCoords);
if (storedCoords) {
setCoords(storedCoords);
}
}, [tipo]);
useEffect(() => {
const handlePaste = async (e) => {
const handlePaste = async () => {
const text = await navigator.clipboard.readText();
const regex = /- (.*), X: (-?\d+)(?:\s*Y:\s*(-?\d+))?\s*Z:\s*(-?\d+)/;
const match = text.match(regex);