Next.js template
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 730B

123456789101112131415161718192021222324252627282930
  1. import { getSession } from 'next-auth/react';
  2. import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
  3. import { useRouter } from 'next/router';
  4. import { useEffect } from 'react';
  5. import LoginForm from '../../components/forms/login/LoginForm';
  6. import { BASE_PAGE } from '../../constants/pages';
  7. const AuthPage = () => {
  8. const router = useRouter();
  9. useEffect(() => {
  10. getSession().then((session) => {
  11. if (session) {
  12. router.replace(BASE_PAGE);
  13. }
  14. });
  15. }, [router]);
  16. return <LoginForm />;
  17. };
  18. export async function getStaticProps({ locale }) {
  19. return {
  20. props: {
  21. ...(await serverSideTranslations(locale, ['forms', 'login'])),
  22. },
  23. };
  24. }
  25. export default AuthPage;