import { avatarsQueryKeys } from '../avatars-query-keys';
import { type PostGetAvatars, avatarsApi } from '../avatars-api';
import { queryClient } from 'src/utils/queryClient';

export const fetchUpdatedAvatars = async (date: string) => {
  try {
    const data: PostGetAvatars = await queryClient.fetchQuery({
      queryKey: avatarsQueryKeys.getUpdatedAvatars(date),
      queryFn: async () => {
        const response = await avatarsApi.getUpdatedAvatars(date);
        return response.data;
      },
      gcTime: 0,
      staleTime: 0
    });
    
    return data;
  } catch (error) {
    console.error('Failed to fetch updated avatars:', error);
  }
};
