/**
 * useBulkOperations Hook
 * 
 * TanStack Query mutations for bulk operations
 */

import { useMutation, useQueryClient } from '@tanstack/react-query';
import { previewBulkUpdate, applyBulkUpdate } from '../services/bulk';
import type { BulkUpdateRequest } from '../types/bulk';

/**
 * Preview bulk update (dry-run)
 */
export function useBulkPreview() {
  return useMutation({
    mutationFn: (request: BulkUpdateRequest) => previewBulkUpdate(request),
  });
}

/**
 * Apply bulk update
 */
export function useBulkUpdate() {
  const queryClient = useQueryClient();
  
  return useMutation({
    mutationFn: (request: BulkUpdateRequest) => applyBulkUpdate(request),
    onSuccess: () => {
      // Invalidate variations queries to refetch updated data
      queryClient.invalidateQueries({ queryKey: ['variations'] });
    },
  });
}
