ConceptPortal-public/rsconcept/frontend/src/components/wrap/RequireAuth.tsx
2024-03-20 15:27:32 +03:00

28 lines
730 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use client';
import { useAuth } from '@/context/AuthContext';
import TextURL from '../ui/TextURL';
interface RequireAuthProps {
children: React.ReactNode;
}
function RequireAuth({ children }: RequireAuthProps) {
const { user } = useAuth();
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>
);
}
}
export default RequireAuth;