From baa9b1e32c0afabf074f6c181274312d757a7099 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Wed, 18 Sep 2024 10:55:35 +0700
Subject: <iman> update no login page if auth

---
 src/pages/login.jsx | 12 ++++++++++++
 1 file changed, 12 insertions(+)

(limited to 'src/pages/login.jsx')

diff --git a/src/pages/login.jsx b/src/pages/login.jsx
index 9a1aa85b..07d13784 100644
--- a/src/pages/login.jsx
+++ b/src/pages/login.jsx
@@ -1,3 +1,5 @@
+import { useEffect } from 'react';
+import { useRouter } from 'next/router';
 import Seo from '@/core/components/Seo';
 import SimpleFooter from '@/core/components/elements/Footer/SimpleFooter';
 import BasicLayout from '@/core/components/layouts/BasicLayout';
@@ -5,8 +7,18 @@ import DesktopView from '@/core/components/views/DesktopView';
 import MobileView from '@/core/components/views/MobileView';
 import LoginComponent from '@/lib/auth/components/Login';
 import AccountActivation from '~/modules/account-activation';
+import useAuth from '@/core/hooks/useAuth';
 
 export default function Login() {
+  const router = useRouter();
+  const auth = useAuth();
+
+  useEffect(() => {
+    if (auth) {
+      router.push('/');
+    }
+  }, [auth, router]);
+
   return (
     <>
       <Seo title='Login - Indoteknik.com' />
-- 
cgit v1.2.3

