ConceptPortal-public/rsconcept/frontend/src/pages/HomePage.tsx

31 lines
944 B
TypeScript
Raw Normal View History

2023-08-08 23:04:21 +03:00
import { useLayoutEffect } from 'react';
2023-07-25 20:27:29 +03:00
import { useAuth } from '../context/AuthContext';
2023-09-05 00:23:53 +03:00
import { useConceptNavigation } from '../context/NagivationContext';
2023-08-11 12:49:32 +03:00
import { TIMEOUT_UI_REFRESH } from '../utils/constants';
2023-07-15 17:46:19 +03:00
function HomePage() {
2023-09-05 00:23:53 +03:00
const { navigateTo } = useConceptNavigation();
2023-07-25 20:27:29 +03:00
const { user } = useAuth();
2023-08-08 23:04:21 +03:00
useLayoutEffect(() => {
if (!user) {
2023-08-11 12:49:32 +03:00
setTimeout(() => {
2023-09-05 00:23:53 +03:00
navigateTo('/manuals');
2023-08-11 12:49:32 +03:00
}, TIMEOUT_UI_REFRESH);
2023-09-02 01:11:27 +03:00
} else {
2023-08-11 12:49:32 +03:00
setTimeout(() => {
2023-09-05 00:23:53 +03:00
navigateTo('/library');
2023-08-11 12:49:32 +03:00
}, TIMEOUT_UI_REFRESH);
2023-08-08 23:04:21 +03:00
}
2023-09-05 00:23:53 +03:00
}, [navigateTo, user])
2023-07-25 20:27:29 +03:00
2023-07-15 17:46:19 +03:00
return (
<div className='flex flex-col items-center justify-center w-full px-4 py-2'>
2023-11-24 19:47:03 +03:00
{ user?.is_staff && <p>Лендинг находится в разработке. Данная страница видна только пользователям с правами администратора.</p> }
2023-07-15 17:46:19 +03:00
</div>
);
}
2023-07-25 20:27:29 +03:00
export default HomePage;