Portal/rsconcept/frontend/src/components/wrap/RequireAuth.tsx

24 lines
721 B
TypeScript
Raw Normal View History

2024-06-07 20:17:03 +03:00
'use client';
import { useAuthSuspense } from '@/backend/auth/useAuth';
2024-06-07 20:17:03 +03:00
import TextURL from '../ui/TextURL';
2024-09-19 17:48:48 +03:00
function RequireAuth({ children }: React.PropsWithChildren) {
const { isAnonymous } = useAuthSuspense();
2024-06-17 21:30:58 +03:00
if (isAnonymous) {
2024-12-12 13:17:24 +03:00
return (
<div key='auth-no-user' 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>
);
}
return <>{children}</>;
2024-06-07 20:17:03 +03:00
}
export default RequireAuth;