'use client';

import { useEffect } from 'react';
import { useRouter } from 'next/navigation';

import { AppLoader } from '@/components/AppLoader';
import { useAppStore } from '@/store/app.store';

export default function HomePage() {
  const router = useRouter();
  const defaultRoute = useAppStore((state) => state.defaultRoute);

  useEffect(() => {
    router.replace(defaultRoute ?? '/access');
  }, [defaultRoute, router]);

  return <AppLoader label="Opening workspace" />;
}
