import { useQuery } from '@tanstack/react-query';
import api from '../../../utils/api';

export const dashboardQueryKeys = {
  stats: {
    all: (type: string) => ['dashboard', 'stats', type] as const,
  },
};

export function useGetDashboardStats(params: { type: string }) {
  const { type } = params;
  return useQuery({
    queryKey: dashboardQueryKeys.stats.all(type),
    queryFn: async () => {
      const { data } = await api.get('/vendor/dashboard', { params: { type } });
      return data;
    },
    enabled: !!type,
  });
}
