Skip to content

Commit 26d980a

Browse files
committed
[bug] fixed refresh on home sending users to /profile
1 parent f90285e commit 26d980a

2 files changed

Lines changed: 2 additions & 20 deletions

File tree

src/App.tsx

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,15 @@
1-
import React, { useEffect } from 'react';
2-
import { BrowserRouter as Router, Routes, Route, useNavigate } from 'react-router-dom';
1+
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
32
import Timetable from './pages/Timetable';
43
import Profile from './pages/Profile';
54
import ProtectedRoute from './components/features/generics/ProtectedRoute.tsx';
65
import AddEntryPage from './pages/AddEntryPage';
76
import SharePage from './pages/Share.tsx';
87
import NotFoundPage from './pages/NotFound.tsx';
9-
import { useAuth } from './hooks/auth/useAuth.ts';
108
import './App.css';
119

12-
const LoginRedirect: React.FC = () => {
13-
const { user } = useAuth();
14-
const navigate = useNavigate();
15-
const hasRedirected = React.useRef(false);
16-
17-
useEffect(() => {
18-
if (user && !hasRedirected.current) {
19-
hasRedirected.current = true;
20-
navigate('/profile');
21-
}
22-
}, [user, navigate]);
23-
24-
return null;
25-
};
26-
2710
function App() {
2811
return (
2912
<Router>
30-
<LoginRedirect />
3113
<Routes>
3214
<Route path="/" element={<Timetable />} />
3315
<Route path="/share/:hierarchy" element={<SharePage />} />

src/components/features/generics/Navbar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const Navbar: React.FC = () => {
3838
await supabase.auth.signInWithOAuth({
3939
provider: 'google',
4040
options: {
41-
redirectTo: window.location.origin,
41+
redirectTo: `${window.location.origin}/profile`,
4242
},
4343
});
4444
};

0 commit comments

Comments
 (0)