eli02 commited on
Commit
ed459b5
·
1 Parent(s): 5b953dd

refactor: Remove auto-redirect to dashboard and update navigation logic in Home component

Browse files
Files changed (1) hide show
  1. src/pages/Home.jsx +5 -10
src/pages/Home.jsx CHANGED
@@ -1,9 +1,8 @@
1
- import { useEffect } from 'react';
2
  import { useNavigate } from 'react-router-dom';
3
- import { useAuth } from '../hooks/useAuth';
4
  import { Button, Box } from '@mui/material';
5
  import { styled } from '@mui/system';
6
  import { fadeIn } from '../styles/animations';
 
7
 
8
  const HeroSection = styled('section')(({ theme }) => ({
9
  minHeight: '90vh',
@@ -66,14 +65,10 @@ const CTAButton = styled(Button)(({ theme }) => ({
66
  }));
67
 
68
  const Home = () => {
69
- const { isAuthenticated } = useAuth();
70
  const navigate = useNavigate();
71
-
72
- useEffect(() => {
73
- if (isAuthenticated) {
74
- navigate('/dashboard');
75
- }
76
- }, [isAuthenticated, navigate]);
77
 
78
  return (
79
  <HeroSection>
@@ -87,7 +82,7 @@ const Home = () => {
87
  variant="contained"
88
  color="primary"
89
  size="large"
90
- onClick={() => navigate('/login')}
91
  >
92
  Begin Your Journey
93
  </CTAButton>
 
 
1
  import { useNavigate } from 'react-router-dom';
 
2
  import { Button, Box } from '@mui/material';
3
  import { styled } from '@mui/system';
4
  import { fadeIn } from '../styles/animations';
5
+ import { useAuth } from '../hooks/useAuth';
6
 
7
  const HeroSection = styled('section')(({ theme }) => ({
8
  minHeight: '90vh',
 
65
  }));
66
 
67
  const Home = () => {
 
68
  const navigate = useNavigate();
69
+ const { isAuthenticated } = useAuth();
70
+
71
+ // Auto-redirect to dashboard removed to allow returning to homepage
 
 
 
72
 
73
  return (
74
  <HeroSection>
 
82
  variant="contained"
83
  color="primary"
84
  size="large"
85
+ onClick={() => navigate(isAuthenticated ? '/dashboard' : '/login')}
86
  >
87
  Begin Your Journey
88
  </CTAButton>