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 usePostHideShowRequestMutation = () => {
  return useMutation<
    ResponseType,
    BaseAxiosError,
    { token: string; id: number; show: 0 | 1 },
    ResponseType
  >({
    mutationKey: friendsQueryKeys.updateFriendStatus(),
    mutationFn: async (variables) => {
      const response = await friendsApi.hideShowRequest(
        variables.token,
        variables.id,
        variables.show
      );
      return response.data;
    }
  });
};
