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

import { userQueryKeys } from '../user-query-keys';
import { type PostGetProfileInfoReturn, userApi } from '../user-api';

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

export const usePostGetProfileInfoPublicQuery = (userId: number, enabled: boolean) => {
  return useQuery<Exclude<PostGetProfileInfoReturn, { email: null }>, BaseAxiosError>({
    queryKey: userQueryKeys.getProfileInfoPublic(),
    queryFn: async () => {
      const response = await userApi.getProfileInfoPublic(userId);
      return response.data;
    },
    enabled
  });
};
