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

import { travelsQueryKeys } from '../travels-query-keys';
import { travelsApi, type PostSetKyeReturn } from '../travels-api';

import type { BaseAxiosError } from '../../../../types';

export const usePostSetKye = () => {
  return useMutation<
    PostSetKyeReturn,
    BaseAxiosError,
    { token: string; qid: number; visited: 0 | 1 },
    PostSetKyeReturn
  >({
    mutationKey: travelsQueryKeys.setKye(),
    mutationFn: async (variables) => {
      const response = await travelsApi.setKye(variables.token, variables.qid, variables.visited);
      return response.data;
    }
  });
};
