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 usePostFriendRequestMutation = () => {
  return useMutation<ResponseType, BaseAxiosError, { token: string; uid: number }, ResponseType>({
    mutationKey: friendsQueryKeys.sendFriendRequest(),
    mutationFn: async (variables) => {
      const response = await friendsApi.sendFriendRequest(variables.token, variables.uid);
      return response.data;
    }
  });
};
