import { useMutation, useQuery } from '@tanstack/react-query';
import {
  CustomUseMutationOptions,
  CustomUseQueryOptions,
  ProcessTypes,
} from '../models';
import { createKieJob, getKieJob } from '../requests';

export function useKieJob(
  requestId,
  options?: CustomUseQueryOptions<Awaited<ReturnType<typeof getKieJob>>>,
) {
  return useQuery({
    queryKey: ['kie-job', requestId],
    queryFn: () => getKieJob(requestId),
    ...options,
  });
}

export function useCreateKieJob(
  options?: CustomUseMutationOptions<
    string,
    unknown,
    { file: File; processType: ProcessTypes }
  >,
) {
  return useMutation(createKieJob, options);
}
