diff --git a/migrations/versions/2309db853ee5_.py b/migrations/versions/72e27a338232_.py similarity index 97% rename from migrations/versions/2309db853ee5_.py rename to migrations/versions/72e27a338232_.py index 27d785e2e1..f4f6d7d975 100644 --- a/migrations/versions/2309db853ee5_.py +++ b/migrations/versions/72e27a338232_.py @@ -1,8 +1,8 @@ """empty message -Revision ID: 2309db853ee5 +Revision ID: 72e27a338232 Revises: -Create Date: 2025-03-20 14:23:41.224215 +Create Date: 2025-03-20 18:45:28.776433 """ from alembic import op @@ -10,7 +10,7 @@ # revision identifiers, used by Alembic. -revision = '2309db853ee5' +revision = '72e27a338232' down_revision = None branch_labels = None depends_on = None diff --git a/src/front/js/pages/vistaMascota.js b/src/front/js/pages/vistaMascota.js index 206952ff07..51811b6e62 100644 --- a/src/front/js/pages/vistaMascota.js +++ b/src/front/js/pages/vistaMascota.js @@ -1,8 +1,7 @@ import React, { useEffect, useState, useContext } from 'react'; -import { useParams, useNavigate } from 'react-router-dom'; +import { useParams, useNavigate, Link } from 'react-router-dom'; import { Context } from "../store/appContext"; import { Modal, Button, Form } from 'react-bootstrap'; -import "../../styles/home.css"; export const VistaMascota = () => { const { id } = useParams(); @@ -22,32 +21,30 @@ export const VistaMascota = () => { }); const [foodSuggestions, setFoodSuggestions] = useState([]); - const getPetDetails = async (id) => { - try { - const resp = await fetch(`${process.env.BACKEND_URL}/api/pets/${id}`); - if (resp.status === 404) { + useEffect(() => { + const getPetDetails = async (id) => { + try { + const resp = await fetch(`${process.env.BACKEND_URL}/api/pets/${id}`); + if (resp.status === 404) { + setPetDetails(null); + } else { + const petData = await resp.json(); + setPetDetails(petData); + setEditedPet({ + name: petData.name || "", + animal_type: petData.animal_type || "", + breed: petData.breed || "", + size: petData.size || "", + age: petData.age || "", + pathologies: petData.pathologies || "" + }); + } + } catch (error) { setPetDetails(null); - } else { - const petData = await resp.json(); - setPetDetails(petData); - setEditedPet({ - name: petData.name || "", - animal_type: petData.animal_type || "", - breed: petData.breed || "", - size: petData.size || "", - age: petData.age || "", - pathologies: petData.pathologies || "" - }); + } finally { + setLoading(false); } - } catch (error) { - console.error("Error al obtener los detalles de la mascota", error); - setPetDetails(null); - } finally { - setLoading(false); - } - }; - - useEffect(() => { + }; getPetDetails(id); }, [id]); @@ -59,7 +56,6 @@ export const VistaMascota = () => { } }, [petDetails, id]); - useEffect(() =>{console.log(foodSuggestions)},[foodSuggestions]) useEffect(() => { if (!loading && petDetails === null) { navigate("/not-found"); @@ -69,18 +65,14 @@ export const VistaMascota = () => { const handleDelete = async () => { try { await actions.deletePet(id); - } catch (error) { - console.error("Error al eliminar la mascota (se ignora):", error); - } + } catch (error) {} navigate("/perfilUsuario"); }; const handleEdit = async () => { try { await actions.editPet(id, editedPet); - } catch (error) { - console.error("Error al editar la mascota (se ignora):", error); - } + } catch (error) {} setShowModal(false); navigate("/perfilUsuario"); }; @@ -90,149 +82,222 @@ export const VistaMascota = () => { return (
Especie: {petDetails.animal_type}
-Raza: {petDetails.breed}
-Tamaño: {petDetails.size}
-Edad: {petDetails.age}
-Patologías: {petDetails.pathologies}
- - -Raza: {petDetails.breed}
+Tamaño: {petDetails.size}
+Edad: {petDetails.age}
+Patologías: {petDetails.pathologies}
+ + {/* Contenedor de los botones alineados a la derecha */} +{food.description}
} -No se encontraron sugerencias de comida.
++ {food.description.length > 80 ? food.description.substring(0, 80) + "..." : food.description} +
)}No se encontraron sugerencias de comida.
+ )} +