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

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

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

export const usePostUpdateGroupSettingsMutation = () => {
  return useMutation<ResponseType, BaseAxiosError, PostUpdateGroupSettings, ResponseType>({
    mutationKey: chatQueryKeys.updateGroupSettings(),
    mutationFn: async (data) => {
      const response = await chatApi.updateGroupSettings(data);
      return response.data;
    }
  });
};
