'use client';

import { useEffect } from 'react';
import { useRouter } from 'next/navigation';
import { useAuthStore } from '@/stores/auth-store';
import { defaultDespachoPathForRole } from '@/components/despachos/despacho-subnav';

export default function DespachosIndex() {
  const router = useRouter();
  const role = useAuthStore(s => s.user?.role);
  useEffect(() => {
    if (!role) return;
    router.replace(defaultDespachoPathForRole(role));
  }, [role, router]);
  return null;
}
