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

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

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

export const usePostGetGroupSettingsQuery = (
  token: string,
  group_token: string,
  enabled: boolean
) => {
  return useQuery<PostGetGroupSettingsReturn, BaseAxiosError>({
    queryKey: chatQueryKeys.getGroupSettings(token, group_token),
    queryFn: async () => {
      const response = await chatApi.getGroupSettings(token, group_token);
      return response.data;
    },
    enabled
  });
};
