thunderhub/pages/index.tsx

23 lines
718 B
TypeScript
Raw Normal View History

// import App from 'next/app';
import React from 'react';
import { useAccount } from '../src/context/AccountContext';
import { SessionLogin } from '../src/views/login/SessionLogin';
import { useRouter } from 'next/router';
import { HomePageView } from '../src/views/homepage/HomePage';
2020-04-15 13:13:12 +02:00
import { appendBasePath } from '../src/utils/basePath';
const ContextApp: React.FC = () => {
const { push } = useRouter();
const { loggedIn, admin, viewOnly, sessionAdmin } = useAccount();
if (loggedIn) {
if (admin === '' || viewOnly !== '' || sessionAdmin !== '') {
2020-04-15 13:13:12 +02:00
push(appendBasePath('/home'));
}
}
return !loggedIn && admin === '' ? <HomePageView /> : <SessionLogin />;
};
export default ContextApp;