diff --git a/Front/src/Components/utils/ProtectedRoute.jsx b/Front/src/Components/utils/ProtectedRoute.jsx
index 3a3e82e..3a0d506 100644
--- a/Front/src/Components/utils/ProtectedRoute.jsx
+++ b/Front/src/Components/utils/ProtectedRoute.jsx
@@ -1,21 +1,38 @@
-import { Navigate } from 'react-router-dom';
+import React from 'react';
+import { Navigate, useLocation } from 'react-router-dom';
import PropTypes from 'prop-types';
import NotFound from '../../Routes/NotFound';
const ProtectedRoute = ({ children, onlyAdmin }) => {
const isAuthenticated = Boolean(localStorage.getItem('userData'));
+ const location = useLocation();
+
+ const currentPath = location.pathname;
+
+ const isReservationDetailRoute = currentPath === '/detailReservation';
+ const isFavsRoute = currentPath === '/profile/favs';
+
+ const getRedirectState = () => {
+ if (isReservationDetailRoute && !isAuthenticated) {
+ return { fromReserve: true };
+ } else if (isFavsRoute && !isAuthenticated) {
+ return { fromFavButton: true };
+ } else {
+ return { fromProtectedRoute: true };
+ }
+ };
+
if (!isAuthenticated) {
- return ;
+ return ;
}
-
+
const userData = JSON.parse(localStorage.getItem('userData'));
const isAdmin = userData.tipo == "ROLE_ADMIN" ? true : false;
if (onlyAdmin && !isAdmin) {
return ;
}
-
return children;
};
@@ -25,3 +42,4 @@ ProtectedRoute.propTypes = {
}
export default ProtectedRoute;
+
diff --git a/Front/src/Routes/Detail.jsx b/Front/src/Routes/Detail.jsx
index fa0ecc2..98fa691 100644
--- a/Front/src/Routes/Detail.jsx
+++ b/Front/src/Routes/Detail.jsx
@@ -107,7 +107,7 @@ const Detail = () => {
]);
};
- // const onClickReserve = () => {
+ const onClickReserve = () => {
// dataReserve.id = id
// dataReserve.titulo = result.titulo
// dataReserve.subtitulo = result.subtitulo
@@ -121,8 +121,8 @@ const Detail = () => {
// dataReserve.menores = numberOfChildren
// // localStorage.setItem('datosReserva', JSON.stringify(dataReserve));
- // // window.location.href = '/reserve';
- // };
+ window.location.href = '/detailReservation';
+ };
return (
@@ -341,10 +341,8 @@ const Detail = () => {
- {/* */}
-
+ {}
+ {/* */}
diff --git a/Front/src/Routes/Login.jsx b/Front/src/Routes/Login.jsx
index d23f363..f9aca3c 100644
--- a/Front/src/Routes/Login.jsx
+++ b/Front/src/Routes/Login.jsx
@@ -22,6 +22,15 @@ const Login = () => {
});
}
+ if (location.state?.fromReserve) {
+ Swal.fire({
+ title: 'Autenticación requerida',
+ text: 'El login es obligatorio para completar una reserva. Por favor, registrese.',
+ icon: 'info',
+ confirmButtonText: 'Ok'
+ });
+ }
+
if (location.state?.fromFavButton) {
Swal.fire({
title: 'Autenticación requerida',
@@ -113,7 +122,11 @@ const Login = () => {
tipo: "success",
texto: "Inicio de sesión exitoso.",
});
- navigate("/");
+ if (location.state?.fromReserve) {
+ navigate("/detailReservation");
+ } else {
+ navigate("/");
+ }
} else {
// Error en el inicio de sesión
setMensaje({
diff --git a/Front/src/main.jsx b/Front/src/main.jsx
index 0b277aa..0ad2606 100644
--- a/Front/src/main.jsx
+++ b/Front/src/main.jsx
@@ -16,7 +16,6 @@ import ProtectedRoute from "./Components/utils/ProtectedRoute";
// Toast notification
import { ToastContainer } from "react-toastify";
import Profile from "./Routes/Profile";
-import Reservation from "./Routes/Reservation";
createRoot(document.getElementById("root")).render(
@@ -24,7 +23,8 @@ createRoot(document.getElementById("root")).render(
}>
} />
- } />
+ } />
+ {} />}
} />
} />
@@ -33,13 +33,14 @@ createRoot(document.getElementById("root")).render(
} />
-
-
-
-
- } />
-
+
+ {/* { } */}
+
+ }
+ />
@@ -69,7 +70,6 @@ createRoot(document.getElementById("root")).render(
{/*
*/}
} />
-
} />
diff --git a/reporteErrores.log b/reporteErrores.log
index f6b453c..f194ffe 100644
--- a/reporteErrores.log
+++ b/reporteErrores.log
@@ -64,3 +64,10 @@
[2023-11-20 19:00:31] [ ERROR] [ExceptionController:21] IllegalArgumentException: No enum constant com.viajecito.api.model.TourDificultad.Baja
[2023-11-20 19:07:42] [ ERROR] [ExceptionController:21] NoSuchElementException: No value present
[2023-11-20 20:03:38] [ ERROR] [ExceptionController:21] MethodArgumentTypeMismatchException: Failed to convert value of type 'java.lang.String' to required type 'java.lang.Long'; nested exception is java.lang.NumberFormatException: For input string: "NaN"
+[2023-12-02 18:34:52] [ ERROR] [ExceptionController:21] MethodArgumentTypeMismatchException: Failed to convert value of type 'java.lang.String' to required type 'java.util.List'; nested exception is java.lang.NumberFormatException: For input string: "Septiembre-Febrero"
+[2023-12-02 18:35:00] [ ERROR] [ExceptionController:21] MethodArgumentTypeMismatchException: Failed to convert value of type 'java.lang.String' to required type 'java.util.List'; nested exception is java.lang.NumberFormatException: For input string: "Septiembre-Febrero"
+[2023-12-02 18:39:05] [ ERROR] [ExceptionController:21] NullPointerException: Cannot invoke "com.viajecito.api.model.Salida.getActivo()" because "salida" is null
+[2023-12-02 18:41:24] [ ERROR] [ExceptionController:21] NullPointerException: Cannot invoke "com.viajecito.api.model.Salida.getActivo()" because "salida" is null
+[2023-12-02 19:47:03] [ ERROR] [ExceptionController:21] NullPointerException: Cannot invoke "com.viajecito.api.model.Salida.getActivo()" because "salida" is null
+[2023-12-05 09:19:49] [ ERROR] [ExceptionController:21] MethodArgumentTypeMismatchException: Failed to convert value of type 'java.lang.String' to required type 'java.lang.Long'; nested exception is java.lang.NumberFormatException: For input string: "undefined"
+[2023-12-05 09:20:14] [ ERROR] [ExceptionController:21] MethodArgumentTypeMismatchException: Failed to convert value of type 'java.lang.String' to required type 'java.lang.Long'; nested exception is java.lang.NumberFormatException: For input string: "undefined"