import { friendsQueryKeys } from '../../friends/friends-query-keys';
import { friendsApi } from '../../friends/friends-api';
import { ResponseType } from '@api/response-type';

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

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

export const usePostUpdateFriendStatusMutation = () => {
  return useMutation<
    ResponseType,
    BaseAxiosError,
    { token: string; id: number; status: number },
    ResponseType
  >({
    mutationKey: friendsQueryKeys.updateFriendStatus(),
    mutationFn: async (variables) => {
      const response = await friendsApi.updateFriendStatus(
        variables.token,
        variables.id,
        variables.status
      );
      return response.data;
    }
  });
};
