2023-07-15 17:46:19 +03:00
|
|
|
|
import { useAuth } from '../context/AuthContext';
|
2023-11-27 12:11:39 +03:00
|
|
|
|
import TextURL from './Common/TextURL';
|
2023-07-15 17:46:19 +03:00
|
|
|
|
|
|
|
|
|
interface RequireAuthProps {
|
|
|
|
|
children: React.ReactNode
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-25 20:27:29 +03:00
|
|
|
|
function RequireAuth({ children }: RequireAuthProps) {
|
2023-07-31 23:47:18 +03:00
|
|
|
|
const { user } = useAuth();
|
|
|
|
|
|
2023-11-27 11:33:34 +03:00
|
|
|
|
if (user) {
|
|
|
|
|
return children;
|
|
|
|
|
} else {
|
|
|
|
|
return (
|
|
|
|
|
<div className='flex flex-col items-center gap-1 mt-2'>
|
|
|
|
|
<p className='mb-2'>Пожалуйста войдите в систему</p>
|
|
|
|
|
<TextURL text='Войти в Портал' href='/login'/>
|
|
|
|
|
<TextURL text='Зарегистрироваться' href='/signup'/>
|
|
|
|
|
<TextURL text='Начальная страница' href='/'/>
|
|
|
|
|
</div>);
|
|
|
|
|
}
|
2023-07-15 17:46:19 +03:00
|
|
|
|
}
|
|
|
|
|
|
2023-07-25 20:27:29 +03:00
|
|
|
|
export default RequireAuth;
|