añadido que elimine coords
This commit is contained in:
@@ -16,7 +16,6 @@ export default function NuevaCoord({ coord, setcoord, colapsar, tipo }) {
|
|||||||
|
|
||||||
setcoord([...coord, newCoord]);
|
setcoord([...coord, newCoord]);
|
||||||
localStorage.setItem(tipo, JSON.stringify([...coord, newCoord]));
|
localStorage.setItem(tipo, JSON.stringify([...coord, newCoord]));
|
||||||
if (colapsar) colapsar();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,39 +1,44 @@
|
|||||||
export default function Modal() {
|
export default function Modal({ CloseModal, Coord, EliminarCoord }) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div
|
<div
|
||||||
class="modal fade"
|
className="modal fade show"
|
||||||
id="staticBackdrop"
|
id="staticBackdrop"
|
||||||
data-bs-backdrop="static"
|
data-bs-backdrop="static"
|
||||||
data-bs-keyboard="false"
|
style={{ display: "block" }}
|
||||||
tabIndex="-1"
|
|
||||||
aria-labelledby="staticBackdropLabel"
|
|
||||||
aria-hidden="true"
|
|
||||||
>
|
>
|
||||||
<div class="modal-dialog">
|
<div className="modal-dialog">
|
||||||
<div class="modal-content">
|
<div className="modal-content">
|
||||||
<div class="modal-header">
|
<div className="modal-header">
|
||||||
<h1 class="modal-title fs-5" id="staticBackdropLabel">
|
<h1 className="modal-title fs-5">Eliminar Coordenada</h1>
|
||||||
Modal title
|
|
||||||
</h1>
|
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="btn-close"
|
className="btn-close"
|
||||||
data-bs-dismiss="modal"
|
onClick={CloseModal}
|
||||||
aria-label="Close"
|
|
||||||
></button>
|
></button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">...</div>
|
<div className="modal-body">
|
||||||
<div class="modal-footer">
|
{console.log(Coord)}
|
||||||
|
Desea eliminar la Coordenada: X: {Coord.x},
|
||||||
|
{Coord.y != null && `Y: ${Coord.y}, `}Z: {Coord.z}
|
||||||
|
</div>
|
||||||
|
<div className="modal-footer">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="btn btn-secondary"
|
className="btn btn-danger"
|
||||||
data-bs-dismiss="modal"
|
onClick={() => {
|
||||||
|
EliminarCoord();
|
||||||
|
CloseModal();
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
Close
|
Eliminar
|
||||||
</button>
|
</button>
|
||||||
<button type="button" class="btn btn-primary">
|
<button
|
||||||
Understood
|
type="button"
|
||||||
|
className="btn btn-secondary"
|
||||||
|
onClick={CloseModal}
|
||||||
|
>
|
||||||
|
Cerrar
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -5,14 +5,31 @@ import ShareIcon from "./ShareIcon";
|
|||||||
import RemoveIcon from "./RemoveIcon";
|
import RemoveIcon from "./RemoveIcon";
|
||||||
import StaticModal from "./StaticModal";
|
import StaticModal from "./StaticModal";
|
||||||
|
|
||||||
|
function Modall({ show, CloseModal, Coord, Coords, EliminarCoord, tipo }) {
|
||||||
|
if (show === true && Coord !== null) {
|
||||||
|
return (
|
||||||
|
<StaticModal
|
||||||
|
CloseModal={CloseModal}
|
||||||
|
Coord={Coord}
|
||||||
|
EliminarCoord={() => {
|
||||||
|
const nuevasCoords = Coords.filter((c) => c !== Coord);
|
||||||
|
localStorage.setItem(tipo, JSON.stringify(nuevasCoords));
|
||||||
|
EliminarCoord(nuevasCoords);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
export default function Keeper({ tipo }) {
|
export default function Keeper({ tipo }) {
|
||||||
const [coords, setCoords] = useState(
|
const [coords, setCoords] = useState(
|
||||||
JSON.parse(localStorage.getItem(tipo) || "[]"),
|
JSON.parse(localStorage.getItem(tipo) || "[]"),
|
||||||
);
|
);
|
||||||
const collapseRef = useRef(null);
|
const collapseRef = useRef(null);
|
||||||
const [showModal, setModal] = useState(false);
|
const [showModal, setModal] = useState(false);
|
||||||
|
//const [showShareToast, setShowShareToast] = useState(false);
|
||||||
console.log(coords);
|
const [selCoord, setCoord] = useState(null);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const storedCoords = JSON.parse(localStorage.getItem(tipo) || "[]");
|
const storedCoords = JSON.parse(localStorage.getItem(tipo) || "[]");
|
||||||
|
|
||||||
@@ -30,7 +47,8 @@ export default function Keeper({ tipo }) {
|
|||||||
//wip
|
//wip
|
||||||
};
|
};
|
||||||
|
|
||||||
const Remover = () => {
|
const Remover = (coord) => {
|
||||||
|
setCoord(coord);
|
||||||
setModal(true);
|
setModal(true);
|
||||||
};
|
};
|
||||||
const collapseAccordion = () => {
|
const collapseAccordion = () => {
|
||||||
@@ -43,7 +61,14 @@ export default function Keeper({ tipo }) {
|
|||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{showModal && <StaticModal />}
|
<Modall
|
||||||
|
show={showModal}
|
||||||
|
CloseModal={() => setModal(false)}
|
||||||
|
Coord={selCoord}
|
||||||
|
Coords={coords}
|
||||||
|
EliminarCoord={setCoords}
|
||||||
|
tipo={tipo}
|
||||||
|
/>
|
||||||
<div className="accordion" id="accordionNuevaCoord">
|
<div className="accordion" id="accordionNuevaCoord">
|
||||||
<div className="accordion-item">
|
<div className="accordion-item">
|
||||||
<h2 className="accordion-header" id="headingNuevaCoord">
|
<h2 className="accordion-header" id="headingNuevaCoord">
|
||||||
@@ -100,7 +125,7 @@ export default function Keeper({ tipo }) {
|
|||||||
coords.map((x) => (
|
coords.map((x) => (
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<b>#{x.num}:</b>
|
<b>{x.num}</b>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td>{x.x}</td>
|
<td>{x.x}</td>
|
||||||
@@ -121,7 +146,7 @@ export default function Keeper({ tipo }) {
|
|||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
className="btn btn-sm btn-outline-danger ms-2"
|
className="btn btn-sm btn-outline-danger ms-2"
|
||||||
onClick={() => Remover()}
|
onClick={() => Remover(x)}
|
||||||
>
|
>
|
||||||
<RemoveIcon />
|
<RemoveIcon />
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
Reference in New Issue
Block a user