fix: redirect to dashboard if pathname is in root path

This commit is contained in:
ValdiANS
2025-12-10 17:07:44 +07:00
parent 017b081832
commit 30ab48e426
+4 -3
View File
@@ -1,7 +1,7 @@
'use client'; 'use client';
import { useEffect } from 'react'; import { useEffect } from 'react';
import { useRouter } from 'next/navigation'; import { usePathname, useRouter } from 'next/navigation';
import { useAuth } from '@/services/hooks/useAuth'; import { useAuth } from '@/services/hooks/useAuth';
import { redirectToSSO } from '@/lib/auth-helper'; import { redirectToSSO } from '@/lib/auth-helper';
@@ -9,10 +9,11 @@ export default function Home() {
const { user, isLoadingUser } = useAuth(); const { user, isLoadingUser } = useAuth();
const router = useRouter(); const router = useRouter();
const pathname = usePathname();
useEffect(() => { if (pathname === '/') {
router.replace('/dashboard'); router.replace('/dashboard');
}, [user, isLoadingUser]); }
if (isLoadingUser) { if (isLoadingUser) {
return ( return (