date selection

This commit is contained in:
jackiettran
2025-07-18 00:31:23 -04:00
parent 1dbe821e70
commit f289022b5d
9 changed files with 852 additions and 253 deletions

View File

@@ -1,5 +1,5 @@
import React from 'react';
import { Navigate } from 'react-router-dom';
import { Navigate, useLocation } from 'react-router-dom';
import { useAuth } from '../contexts/AuthContext';
interface PrivateRouteProps {
@@ -8,6 +8,7 @@ interface PrivateRouteProps {
const PrivateRoute: React.FC<PrivateRouteProps> = ({ children }) => {
const { user, loading } = useAuth();
const location = useLocation();
if (loading) {
return (
@@ -19,7 +20,7 @@ const PrivateRoute: React.FC<PrivateRouteProps> = ({ children }) => {
);
}
return user ? <>{children}</> : <Navigate to="/login" />;
return user ? <>{children}</> : <Navigate to="/login" state={{ from: location }} replace />;
};
export default PrivateRoute;