Skip to content

Commit 41678ea

Browse files
committed
actualización desde rama Develop
2 parents 56b4647 + de510c5 commit 41678ea

File tree

7 files changed

+462
-305
lines changed

7 files changed

+462
-305
lines changed

migrations/versions/02db57486dda_.py migrations/versions/e36c9457bade_.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
"""empty message
22
3-
Revision ID: 02db57486dda
3+
Revision ID: e36c9457bade
44
Revises:
5-
Create Date: 2025-03-20 08:44:01.875440
5+
Create Date: 2025-03-20 19:00:49.034691
66
77
"""
88
from alembic import op
99
import sqlalchemy as sa
1010

1111

1212
# revision identifiers, used by Alembic.
13-
revision = '02db57486dda'
13+
revision = 'e36c9457bade'
1414
down_revision = None
1515
branch_labels = None
1616
depends_on = None

src/front/js/component/navbar.js

+11-21
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,27 @@
11
import React, { useContext, useEffect } from "react";
22
import logo from "../../img/Icono puppereats.png";
33
import { Link } from "react-router-dom";
4-
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
5-
import { CiSearch } from "react-icons/ci";
64
import { Context } from "../store/appContext";
75
import { FaUserCircle, FaShoppingCart, FaSignOutAlt } from "react-icons/fa";
86

9-
export const Navbar = ({ setActiveCategory }) => { // Recibimos setActiveCategory como prop
7+
export const Navbar = ({ setActiveCategory }) => {
108
const { store, actions } = useContext(Context);
119
const { user, cart } = store;
1210

13-
useEffect(() => {
14-
console.log("Usuario en navbar:", user);
15-
}, [user, cart]);
11+
useEffect(() => {
12+
console.log("Usuario en navbar:", user);
13+
}, [user, cart]);
1614

17-
const totalUnidades = store.cart.reduce((total, producto) => total + (producto.cantidad || 1), 0)
15+
const totalUnidades = store.cart.reduce((total, producto) => total + (producto.cantidad || 1), 0);
1816

1917
if (typeof setActiveCategory !== "function") {
2018
console.error("⚠️ Error: setActiveCategory no es una función en Navbar.js.");
21-
return null; // Evitamos que falle si `setActiveCategory` no es válida
19+
return null;
2220
}
2321

2422
return (
2523
<nav className="navbar navbar-expand-lg shadow-lg" style={{
26-
background: "linear-gradient(180deg, #FBD989 5%, #F4C4A4 40%, #EC955B 95%)",
24+
background: "#EABDE6" ,
2725
padding: "15px 30px",
2826
}}>
2927
<div className="container-fluid">
@@ -33,25 +31,18 @@ export const Navbar = ({ setActiveCategory }) => { // Recibimos setActiveCatego
3331
</Link>
3432

3533
<div className="collapse navbar-collapse" id="navbarSupportedContent">
36-
<form className="d-flex me-auto" role="search">
37-
<input className="form-control me-2" type="search" placeholder="Buscar comida..." aria-label="Search" style={{ borderRadius: "8px", height: "30px", width: "250px", fontSize: "1.1rem" }} />
38-
<button className="btn btn-outline-dark" type="submit" style={{ borderRadius: "8px", padding: "2px 6px" }}>
39-
<CiSearch size={12} />
40-
</button>
41-
</form>
42-
4334
<ul className="navbar-nav mx-auto mb-2 mb-lg-0">
4435
<li className="nav-item m-2">
45-
<button className="nav-link fw-semibold btn btn-link text-dark" onClick={() => setActiveCategory("dogFood")}>Caninos</button>
36+
<Link to="/" className="nav-link fw-semibold btn btn-link text-dark" onClick={() => setActiveCategory("dogFood")}>Caninos</Link>
4637
</li>
4738
<li className="nav-item m-2">
48-
<button className="nav-link fw-semibold btn btn-link text-dark" onClick={() => setActiveCategory("catFood")}>Felinos</button>
39+
<Link to="/" className="nav-link fw-semibold btn btn-link text-dark" onClick={() => setActiveCategory("catFood")}>Felinos</Link>
4940
</li>
5041
<li className="nav-item m-2">
51-
<button className="nav-link fw-semibold btn btn-link text-dark" onClick={() => setActiveCategory("exoticFood")}>Exóticos</button>
42+
<Link to="/" className="nav-link fw-semibold btn btn-link text-dark" onClick={() => setActiveCategory("exoticFood")}>Exóticos</Link>
5243
</li>
5344
<li className="nav-item m-2">
54-
<button className="nav-link fw-semibold btn btn-link text-dark" onClick={() => setActiveCategory("accesories")}>Accesorios</button>
45+
<Link to="/" className="nav-link fw-semibold btn btn-link text-dark" onClick={() => setActiveCategory("accesories")}>Accesorios</Link>
5546
</li>
5647
</ul>
5748

@@ -63,7 +54,6 @@ export const Navbar = ({ setActiveCategory }) => { // Recibimos setActiveCatego
6354
<span className="fw-semibold">Perfil</span>
6455
</Link>
6556
<Link to="/carrito" className="btn btn-warning d-flex align-items-center">
66-
{/* <FaShoppingCart size={18} className="me-1" /> Cesta {cartItemCount > 0 && `(${cartItemCount})`} */}
6757
<FaShoppingCart size={18} className="me-1" /> Cesta {totalUnidades > 0 && `(${totalUnidades})`}
6858
</Link>
6959
<button className="btn btn-light text-muted border-0 d-flex align-items-center" onClick={actions.logout}>
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,100 @@
1-
import React, { useState } from 'react';
2-
import { useNavigate } from 'react-router-dom'; // ✅ Importamos useNavigate
1+
import React, { useState } from "react";
2+
import { useNavigate, Link } from "react-router-dom";
33

44
export const RecuperacionContraseña = () => {
5-
const [email, setEmail] = useState('');
6-
const navigate = useNavigate(); // ✅ Inicializamos el hook de navegación
5+
const [email, setEmail] = useState("");
6+
const navigate = useNavigate();
77

8-
const handleSubmit = async (e) => {
9-
e.preventDefault();
10-
11-
try {
12-
const response = await fetch(`${process.env.BACKEND_URL}/api/forgotpassword`, { // ✅ Asegúrate de que esta ruta es correcta
13-
method: 'POST',
14-
headers: { 'Content-Type': 'application/json' },
15-
body: JSON.stringify({ email })
16-
});
8+
const handleSubmit = async (e) => {
9+
e.preventDefault();
1710

18-
const data = await response.json();
19-
20-
if (response.ok) {
21-
alert("Correo enviado correctamente. Revisa tu bandeja de entrada."); // ✅ Alert con el mensaje
22-
navigate("/loginSignup"); // ✅ Redirigir al inicio de sesión después de aceptar el alert
23-
} else {
24-
alert(`Error: ${data.msg}`);
25-
}
26-
} catch (error) {
27-
alert("Error de conexión con el servidor.");
11+
try {
12+
const response = await fetch(
13+
`${process.env.BACKEND_URL}/api/forgotpassword`,
14+
{
15+
method: "POST",
16+
headers: { "Content-Type": "application/json" },
17+
body: JSON.stringify({ email }),
2818
}
29-
};
19+
);
3020

31-
return (
32-
<div>
33-
<h2>Recuperar contraseña</h2>
34-
<form onSubmit={handleSubmit}>
35-
<input
36-
type="email"
37-
placeholder="Introduce tu correo electrónico"
38-
value={email}
39-
onChange={(e) => setEmail(e.target.value)}
40-
required
41-
/>
42-
<button type="submit">Enviar</button>
43-
</form>
21+
const data = await response.json();
22+
23+
if (response.ok) {
24+
alert("Correo enviado correctamente. Revisa tu bandeja de entrada.");
25+
navigate("/loginSignup");
26+
} else {
27+
alert(`Error: ${data.msg}`);
28+
}
29+
} catch (error) {
30+
alert("Error de conexión con el servidor.");
31+
}
32+
};
33+
34+
return (
35+
<div
36+
className="d-flex justify-content-center align-items-center min-vh-100"
37+
style={{
38+
background: "linear-gradient(to bottom, #FFDCAE, #ffffff)",
39+
backgroundSize: "cover",
40+
padding: "2rem"
41+
}}
42+
>
43+
<div
44+
className="card shadow-lg p-5"
45+
style={{
46+
width: "100%",
47+
maxWidth: "35rem",
48+
borderRadius: "20px",
49+
backgroundColor: "#ffffff",
50+
border: "none",
51+
boxShadow: "0 10px 30px rgba(0, 0, 0, 0.1)"
52+
}}
53+
>
54+
<div className="card-body text-center">
55+
<h2 className="card-title mb-4" style={{ color: "#333", fontWeight: "bold" }}>Recuperar Contraseña</h2>
56+
<p className="text-muted mb-4" style={{ fontSize: "1.1rem" }}>
57+
Ingresa tu correo y te enviaremos instrucciones para restablecer tu contraseña.
58+
</p>
59+
<form onSubmit={handleSubmit}>
60+
<div className="mb-4">
61+
<input
62+
type="email"
63+
className="form-control p-3"
64+
style={{
65+
borderRadius: "10px",
66+
border: "2px solid #ddd",
67+
transition: "border-color 0.3s ease-in-out",
68+
}}
69+
placeholder="Introduce tu correo electrónico"
70+
value={email}
71+
onChange={(e) => setEmail(e.target.value)}
72+
required
73+
onFocus={(e) => e.target.style.borderColor = "#007bff"}
74+
onBlur={(e) => e.target.style.borderColor = "#ddd"}
75+
/>
76+
</div>
77+
<button
78+
type="submit"
79+
className="btn w-100 py-2"
80+
style={{
81+
backgroundColor: "#007bff",
82+
color: "#ffffff",
83+
fontSize: "1.1rem",
84+
borderRadius: "10px",
85+
transition: "0.3s ease-in-out",
86+
}}
87+
onMouseOver={(e) => e.target.style.backgroundColor = "#0056b3"}
88+
onMouseOut={(e) => e.target.style.backgroundColor = "#007bff"}
89+
>
90+
Enviar Correo
91+
</button>
92+
</form>
93+
<Link to="/" className="d-block mt-3 text-secondary" style={{ fontSize: "1rem", textDecoration: "none" }}>
94+
<i className="bi bi-arrow-left"></i> Volver a la página principal
95+
</Link>
4496
</div>
45-
);
97+
</div>
98+
</div>
99+
);
46100
};

src/front/js/layout.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ const Layout = () => {
7474
// Nuevo componente para manejar el Navbar
7575
const PageWithNavbar = ({ activeCategory, setActiveCategory }) => {
7676
const location = useLocation();
77-
const hideNavbarRoutes = ["/perfilUsuario", "/loginSignup"]; // Rutas donde ocultamos el Navbar
77+
const hideNavbarRoutes = ["/perfilUsuario","/RecuperacionContraseña",]; // Rutas donde ocultamos el Navbar
7878

7979
return (
8080
<>

src/front/js/pages/AlertComponent.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,17 @@ const AlertComponent = () => {
2424
<p className='mt-3'>Aww yeah..! Tu pedido se ha realizado correctamente. En unos minutos recibirás la confirmación en tu correo electrónico.</p>
2525
<p className="mb-0">Si necesitas cancelar algún producto o realizar cualquier modificación, ponte en contacto con nosotros a través del formulario de contacto.</p>
2626
<hr/>
27-
<Link className="text-center" to="/">
28-
<p><strong>Volver a la página principal</strong></p>
27+
<Link
28+
className="text-center"
29+
to="/"
30+
onClick={(e) => {
31+
e.preventDefault(); // Evita que React Router haga la navegación interna
32+
window.location.href = "/"; // Redirige y recarga correctamente
33+
}}
34+
>
35+
<p><strong>Volver a la página principal</strong></p>
2936
</Link>
37+
3038
</div>
3139
)}
3240

0 commit comments

Comments
 (0)