'use client';

import { useEffect } from 'react';
import { usePathname, useRouter } from 'next/navigation';
import { useAuth } from '@/services/hooks/useAuth';
import { redirectToSSO } from '@/lib/auth-helper';

export default function Home() {
  const { user, isLoadingUser } = useAuth();

  const router = useRouter();
  const pathname = usePathname();

  useEffect(() => {
    if (pathname === '/') {
      router.replace('/dashboard');
    }
  }, [pathname]);

  if (isLoadingUser) {
    return (
      <main className='w-full h-full min-h-screen flex flex-row justify-center items-center'>
        <span className='loading loading-spinner loading-lg'></span>
      </main>
    );
  }

  return <>Loading...</>;
}
