import { useMutation } from '@tanstack/react-query';

import { fixersQueryKeys } from '../fixers-query-keys';
import { type PostAddFixer, fixersApi } from '../fixers-api';

import type { BaseAxiosError } from '../../../../types';
import { ResponseType } from '@api/response-type';

export const usePostAddFixerMutation = () => {
  return useMutation<ResponseType, BaseAxiosError, PostAddFixer, ResponseType>({
    mutationKey: fixersQueryKeys.addFixer(),
    mutationFn: async (data) => {
      const response = await fixersApi.addFixer(data);
      return response.data;
    }
  });
};
