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

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

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

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