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

import { chatQueryKeys } from '../chat-query-keys';
import { chatApi } from '../chat-api';

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

export const usePostRemoveGroupFromListMutation = () => {
  return useMutation<
    ResponseType,
    BaseAxiosError,
    { token: string; group_token: string },
    ResponseType
  >({
    mutationKey: chatQueryKeys.removeGroupFromList(),
    mutationFn: async (data) => {
      const response = await chatApi.removeGroupFromList(data.token, data.group_token);
      return response.data;
    }
  });
};
