Stay on the view after page reload
This commit is contained in:
10
src/App.tsx
10
src/App.tsx
@@ -13,7 +13,7 @@ import { getSystemLanguage } from './services/i18n';
|
|||||||
import { useAuth } from './context/AuthContext';
|
import { useAuth } from './context/AuthContext';
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const { currentUser, updateUser, logout } = useAuth();
|
const { currentUser, updateUser, logout, isLoading } = useAuth();
|
||||||
|
|
||||||
const [language, setLanguage] = useState<Language>('en');
|
const [language, setLanguage] = useState<Language>('en');
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@@ -37,6 +37,14 @@ function App() {
|
|||||||
navigate('/login');
|
navigate('/login');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (isLoading) {
|
||||||
|
return (
|
||||||
|
<div className="h-[100dvh] w-screen bg-surface flex items-center justify-center text-on-surface">
|
||||||
|
<div className="animate-pulse">Loading...</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (!currentUser && location.pathname !== '/login') {
|
if (!currentUser && location.pathname !== '/login') {
|
||||||
return <Navigate to="/login" />;
|
return <Navigate to="/login" />;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user