'use client';

import { useEffect } from 'react';
import { usePathname, useRouter } from 'next/navigation';
import { useAuth } from '@/services/hooks/useAuth';

export default function Home() {
  const { 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 (
    <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>
  );
}
