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

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

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

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