From 8d400232b36cde5da0047971c91713da625a3837 Mon Sep 17 00:00:00 2001 From: ItsJorgeRdz03 <82615294+ItsJorgeRdz03@users.noreply.github.com> Date: Mon, 3 Jun 2024 01:23:11 -0700 Subject: [PATCH] =?UTF-8?q?Correcciones=20con=20el=20bot=C3=B3n=20de=20fav?= =?UTF-8?q?orito=20(A=C3=BAn=20faltan=20m=C3=A1s=20correcciones)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/components/ui/PopupServicio.jsx | 30 ++++++++++++++- client/src/components/ui/Servicio.jsx | 37 ++++++++++++------- client/src/components/ui/ServiciosYFiltro.jsx | 3 +- .../components/ui/servicios/ServiciosSpa.jsx | 24 ++++++++++-- 4 files changed, 74 insertions(+), 20 deletions(-) diff --git a/client/src/components/ui/PopupServicio.jsx b/client/src/components/ui/PopupServicio.jsx index d548dd03..c512f74b 100644 --- a/client/src/components/ui/PopupServicio.jsx +++ b/client/src/components/ui/PopupServicio.jsx @@ -17,7 +17,7 @@ const StyledRating = styled(Rating)({ }, }); -const PopupServicio = ({ cerrar, check, datos, update }) => { +const PopupServicio = ({ cerrar, check, datos, update, st }) => { const sim = [ { nombre: "Cargando...", @@ -118,6 +118,31 @@ const PopupServicio = ({ cerrar, check, datos, update }) => { } }; + const callFav = async () => { + if (datos.id != 0) { + try { + const respuesta = await fetch("/api/admin/productos/setFavorito", { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + id: datos.idUser, + idPS: datos.id, + estado: datos.favorito, + }), + }); + + let respuestaJson = await respuesta.json(); + if ((await respuestaJson[0].res) == true) { + st(); + } + } catch (error) { + console.log(error, "error"); + } + } + }; + const mostrarSimilares = similares.slice(indexItem, indexItem + renderItems); return ( @@ -195,8 +220,9 @@ const PopupServicio = ({ cerrar, check, datos, update }) => {